SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0
0

Hi,

I have a surface with two x-axes and one y-axis. I am plotting 2 lines, which both have a numerical axis for their x-axis. I would like to be able to pan the lines so that I can align them for further analysis. However, I want the scaling on the two x-axes to stay identical. I have implemented the panning, which was straight forward using the XAxisDragModifier DragMode=”Pan”, so that is sorted. However, the scaling on the two axes is not identical, as each of the two lines have values for different x-ranges. This means that when I overlay them, one is more stretched out relative to the other.

Is there a way to lock the scaling for x-axes? See image below, I would like the red lines to be in sync, and equally big. So that 5 cm on the first x-axis is an equal amount of time as 5 cm on the second x-axis

Thank you,
-Lars

Version
v5.4.0
Images
  • You must to post comments
0
0

Hi Lars

SciChart automatically zooms to fit axis to fit the series on first load, and ZoomPanModifier (and other modifiers) treat each X,Y axis pair as unique, so when you pan the chart, you will pan all axis the same

The frequency of labels, gridlines and the scaling of the XAxis is a function of:

  • Axis.VisibleRange (
  • Axis.MajorDelta / MinorDelta (decides on how often labels are positioned)

If you want the two axis to have the same scaling then the VisibleRange and Major/Minor delta must be the same.

If you want the two axis to have different VisibleRanges but the same scaling then what I suggest you do is setup some kind of listener to the primary axis.VisibleRangeChanged event, then calculate a VisibleRange for the second axis which is the same min-max as the first.

For example, in psuedocode:

   primaryAxis.VisibleRangeChanged += (s,e) => {
            var secondaryAxisRange = CalculateRangeBasedOnPrimary(e.VisibleRange);
            secondaryAxis.VisibleRange = secondaryAxisRange;
   }

This would take a little bit of experimenting with, and you may need to exclude the second axis from ZoomPanModifiers so that its range is entirely based on the first axis.

Does this help?

-Andrew

  • Lars van der Lee
    Thank you for the quick reply Andrew! Just wanted to make sure there was no built in way before starting the maths.
  • Andrew Burnett-Thompson
    Hi Lars! There’s a built-in way to synchronise two XAxis and have them move in lockstep: just bind the XAxis.VisibleRange from axis B to axis A. However to have them move at the same rate, but not exactly the same range would require a little coding above. hope this helps!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.