使用两组不同的值绘制单个 X 轴 - 图表 - WPF Codeplex
我正在使用两组不同的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。这段代码是正确的..这与我的值分配有关(我注意到我在使用 X2 之前清除了 X1 值。但是为了使代码正常工作,所有值 X1、Y1、X2、Y2 应保留,直到图表已创建)..谢谢!
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!