使用两组不同的值绘制单个 X 轴 - 图表 - WPF Codeplex

发布于 2024-10-30 01:07:22 字数 879 浏览 1 评论 0原文

我正在使用两组不同的 X 和 Y 值绘制 XY 图。这就是我的数据集的样子 -> [ X1 = {1,3,5,...}, Y1 = {104, 98, 36,....} 且 X2 = {2,4,6..}, Y2 = { 76, 65, 110 ..}]。

这是我正在使用的代码:

series1.DependentValueBinding = new System.Windows.Data.Binding("Y1"); series1.IndependentValueBinding = new System.Windows.Data.Binding("X1");

series1.DependentRangeAxis = YAxis;

series1.IndependentAxis = XAxis;

series2.DependentValueBinding = new System.Windows.Data.Binding("Y2"); series2.IndependentValueBinding = new System.Windows.Data.Binding("X2");

series2.DependentRangeAxis = YAxis;

series2.IndependentAxis = XAxis;

此代码适用于将两个系列分配给单个 Y 轴,但是当将具有不同 X 和 Y 值的两个系列分配给 X 轴时,它会弄乱第一个系列。它相对于 X2 = {2,4,6..} 绘制 Y1 = {104, 98, 36,....} 和 Y2 = { 76, 65, 110..},而不是相对于 X1 绘制Y1 和 X2 相对于 Y2 且只有一个 X 轴和 Y 轴。

请建议我如何将两组不同的值分配给单个 X 轴。

先感谢您!

-安娜

I am plotting a XY graph with two different sets of X and Y values. This is how my dataset looks -> [ X1 = {1,3,5,...}, Y1 = {104, 98, 36,....} and X2 = {2,4,6..}, Y2 = { 76, 65, 110..}].

This is the code I am using:

series1.DependentValueBinding = new System.Windows.Data.Binding("Y1");
series1.IndependentValueBinding = new System.Windows.Data.Binding("X1");

series1.DependentRangeAxis = YAxis;

series1.IndependentAxis = XAxis;

series2.DependentValueBinding = new System.Windows.Data.Binding("Y2");
series2.IndependentValueBinding = new System.Windows.Data.Binding("X2");

series2.DependentRangeAxis = YAxis;

series2.IndependentAxis = XAxis;

This code works fine for assigning two series to single Y-Axis, but when two series with different X and Y values are assigned to X-Axis it messes up the first series. It plots both Y1 = {104, 98, 36,....} and Y2 = { 76, 65, 110..} with respect to X2 = {2,4,6..}, instead of plotting X1 with respect to Y1 and X2 with respect to Y2 and having only one X and Y axis.

Please advice me on what needs to be done to assign two different set of values to single X-axis.

Thank you in advance!

-Anna

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缪败 2024-11-06 01:07:22

问题解决了。这段代码是正确的..这与我的值分配有关(我注意到我在使用 X2 之前清除了 X1 值。但是为了使代码正常工作,所有值 X1、Y1、X2、Y2 应保留,直到图表已创建)..谢谢!

series1.DependentValueBinding = new System.Windows.Data.Binding("Y1");
series1.IndependentValueBinding = new System.Windows.Data.Binding("X1");

series1.DependentRangeAxis = YAxis;

series1.IndependentAxis = XAxis;

series2.DependentValueBinding = new System.Windows.Data.Binding("Y2");
series2.IndependentValueBinding = new System.Windows.Data.Binding("X2");

series2.DependentRangeAxis = YAxis;

series2.IndependentAxis = XAxis;

Problem is solved. This code is correct.. There is something to do with my value assignment (I noticed that I was clearing X1 value before using X2. But to make the code work all the values X1, Y1, X2, Y2 should be preserved until the chart is created)..Thank you!

series1.DependentValueBinding = new System.Windows.Data.Binding("Y1");
series1.IndependentValueBinding = new System.Windows.Data.Binding("X1");

series1.DependentRangeAxis = YAxis;

series1.IndependentAxis = XAxis;

series2.DependentValueBinding = new System.Windows.Data.Binding("Y2");
series2.IndependentValueBinding = new System.Windows.Data.Binding("X2");

series2.DependentRangeAxis = YAxis;

series2.IndependentAxis = XAxis;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文