强制轴在 Visiblox 图表中使用给定数量的主要刻度线
当在 Visiblox 图表中使用 LinearAxis 作为 Y 轴时,我想强制轴使用给定数量的主要刻度线,同时仍然让工具包自动计算轴范围和刻度线位置。例如,我可能有一个主要 Y 轴和一个次要 Y 轴,并且我希望两个轴使用相同数量的主要刻度,以便它们的水平网格线重叠。这可能吗?
When using a LinearAxis for the Y axis in a Visiblox chart, I would like to force the axis to use a given number of major tick marks while still having the toolkit automatically calculate the axis range and tick mark locations. For instance, I may have a primary and secondary Y axis and I want both axes to use the same number of major ticks so that their horizontal gridlines overlap. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有几个选择。首先,您可以设置 MajorTickInterval< /a> 强制分配主要刻度。根据您的用例,您可能需要查看轴的实际范围,然后除以您想要获得合理间隔的刻度数。
另一种替代方法是对轴进行子类化并重写 GetMajorTickValues 方法,该方法是轴用来确定刻度放置位置的方法。
There are a couple of options. Firstly you can set the MajorTickInterval to force the distribution of major ticks. Depending on your use-case you may need to look at the actual range of the axis, and divide by the number of ticks you want to get a sensible interval.
The other alternative is to subclass the axis and override the GetMajorTickValues method which is what the axis uses to determine where to place ticks.
如果您需要强制主轴和辅助轴上的值之间的关系,可以通过
ElementName
绑定来实现。例如,您可以将辅助轴MajorTickInterval
绑定到主轴计算的刻度间隔ActualMajorTickInterval
,如下所示:但是,根据您的数据,具有相同的刻度间隔每个轴可能不会导致您的主要刻度网格线重合。在这种情况下,您可能还想绑定范围:
如果您需要更复杂的逻辑,可以通过值转换器来完成此操作。
If you need to enforce a relationship between the values on your primary and secondary axis, this can be achieved via
ElementName
binding. For example, you can bind the secondary axisMajorTickInterval
to the computed tick interval of the primary axis,ActualMajorTickInterval
as follows:However, depending ion your data, having the same tick interval for each axis may not cause your major tick gridlines to coincide. In this case, you might want to bind the range alse:
If you need more complex logic, it might be possible to do this via value converters.