在 Visiblox 图表中平移或缩放后自动缩放轴
我有一个 Visiblox 折线图,允许在 X 轴(但不能在 Y 轴)上缩放和平移。缩放或平移到图表的特定区域后,我希望仅根据可见数据重新计算 YAxis 范围和刻度。我尝试在 YAxis 上设置 AutoScaleToVisibleData="True",但这不起作用,因为缩放和平移不会设置 XAxis.Range,并且必须更改 XAxis.Range 才能使 YAxis 的 AutoScaleToVisibleData 属性生效。
编辑
我现在尝试使用 IAxis.AdoptZoomAsRange() 函数,但似乎无法弄清楚。相关示例代码如下:
XAML:
<charts:Chart Name="chart">
<charts:Chart.Behaviour>
<charts:BehaviourManager AllowMultipleEnabled="True">
<charts:PanBehaviour IsEnabled="True" YPanEnabled="False" PanEnded="PanBehaviour_PanEnded" />
<charts:ZoomBehaviour IsEnabled="True" YZoomEnabled="False" AnimationEnabled="False" ZoomMode="MouseWheel" ZoomEnded="ZoomBehaviour_ZoomEnded" />
</charts:BehaviourManager>
</charts:Chart.Behaviour>
<charts:Chart.XAxis>
<charts:DateTimeAxis />
</charts:Chart.XAxis>
<charts:Chart.YAxis>
<charts:LinearAxis AutoScaleToVisibleData="True" />
</charts:Chart.YAxis>
</charts:Chart>
代码隐藏:
public MainWindow()
{
InitializeComponent();
DataSeries<DateTime, double> dataSeries = new DataSeries<DateTime, double>();
for (int i = 0; i < 100; i++)
dataSeries.Add(new DataPoint<DateTime, double>(DateTime.Now.AddMonths(i), i));
LineSeries lineSeries = new LineSeries();
lineSeries.DataSeries = dataSeries;
chart.Series.Add(lineSeries);
}
private void PanBehaviour_PanEnded(object sender, EventArgs e)
{
chart.YAxis.AdoptZoomAsRange();
}
private void ZoomBehaviour_ZoomEnded(object sender, EventArgs e)
{
chart.YAxis.AdoptZoomAsRange();
}
I have a Visiblox line chart that allows zooming and panning on the XAxis (but not the YAxis). After zooming or panning to a particular region of the chart, I would like to have the YAxis range and ticks recalculated based on the visible data only. I tried setting AutoScaleToVisibleData="True" on the YAxis, but this does not work as zooming and panning do not set XAxis.Range, and XAxis.Range must change in order for the YAxis's AutoScaleToVisibleData property to have an effect.
EDIT
I am now attempting to use the IAxis.AdoptZoomAsRange() function but can't seem to figure it out. Relevant example code below:
XAML:
<charts:Chart Name="chart">
<charts:Chart.Behaviour>
<charts:BehaviourManager AllowMultipleEnabled="True">
<charts:PanBehaviour IsEnabled="True" YPanEnabled="False" PanEnded="PanBehaviour_PanEnded" />
<charts:ZoomBehaviour IsEnabled="True" YZoomEnabled="False" AnimationEnabled="False" ZoomMode="MouseWheel" ZoomEnded="ZoomBehaviour_ZoomEnded" />
</charts:BehaviourManager>
</charts:Chart.Behaviour>
<charts:Chart.XAxis>
<charts:DateTimeAxis />
</charts:Chart.XAxis>
<charts:Chart.YAxis>
<charts:LinearAxis AutoScaleToVisibleData="True" />
</charts:Chart.YAxis>
</charts:Chart>
Code-behind:
public MainWindow()
{
InitializeComponent();
DataSeries<DateTime, double> dataSeries = new DataSeries<DateTime, double>();
for (int i = 0; i < 100; i++)
dataSeries.Add(new DataPoint<DateTime, double>(DateTime.Now.AddMonths(i), i));
LineSeries lineSeries = new LineSeries();
lineSeries.DataSeries = dataSeries;
chart.Series.Add(lineSeries);
}
private void PanBehaviour_PanEnded(object sender, EventArgs e)
{
chart.YAxis.AdoptZoomAsRange();
}
private void ZoomBehaviour_ZoomEnded(object sender, EventArgs e)
{
chart.YAxis.AdoptZoomAsRange();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IAxis 上的 AdoptZoomAsRange 方法可能就是您正在寻找的 - 有一个可下载的示例,该示例在此 博客文章 希望能让这一点更清楚。
[披露:我在 Visiblox 工作]
The AdoptZoomAsRange method on IAxis is probably what you're looking for - there's a downloadable example it being used in this blog post which should hopefully make that clearer.
[disclosure: I work on Visiblox]