Recent

Author Topic: Pan one series but limit direction of other series  (Read 1895 times)

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Pan one series but limit direction of other series
« on: September 14, 2019, 11:55:08 am »
Is there a way to pan one series in x and y directions, but limit a second series to only panning the in x directions?

I am currently using the ChartToolSet PanDragTool. And all my axis have an AxisTransformation:AutoScaleAxisTransform.

After panning in a diagonal direction, I would like the first series to pan diagonally, but the second series to pan only horizontally and keep the same vertical position on the chart.

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: Pan one series but limit direction of other series
« Reply #1 on: September 14, 2019, 12:25:13 pm »
I guess this is not working with the standard tools because panning affects the extent of the entire chart, not that of a series. The PanDrag tool (like the other extent tools) does not know which series you clicked to drag, you even can begin dragging when you click on an empty space on the chart.

What you need is a combination of an extent tool with a datapoint tool. You either must write your own chart tool, or you use a TUserDefinedTool and take advantage of the mouse events available here for any purpose. Your code must detect the series clicked (study TDataPointTool.FindNearestPoint in TATools.pas), and it must follow the mouse motion such as in TBasicPanTool.PanBy (same unit), but discard the change of the y direction in the new extent (variable "ext").

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Pan one series but limit direction of other series
« Reply #2 on: September 15, 2019, 01:37:31 am »
It appears that the TBasicPanTool.panby procedure deals with the whole chart (FChart.LogicalExtent := ext;) because LogicalExtent refers to the whole chart.

Is there a way to just replot one of the series with a new Y range so that it appears fixed while the other series has been panned?

I actually need the fixed series to stay there after zooming the moveable series also.

Would be easier to write my own pan and zoom code that changes the range values by disabling the ChartAxisTransformationsAutoScaleAxisTransform for the moveable series?

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: Pan one series but limit direction of other series
« Reply #3 on: September 15, 2019, 11:01:03 am »
I fear I still don't understand the question to the level that I could write a demo based on ChartTools alone...

But here is another approach which uses two charts and a TChartExtentLink component to link the x axis ranges of both charts to each other. The bottom chart contains the series which can only be dragged horizontally. For this purpose a PanDragTool has been added and assigned to this chart. Its LimitToExtent property has been set to [pdDown, pdUp] so that the drag tool in ineffective in the vertical direction.

The essiential property changes have been made in the source code instead of the Object Inspector so that you can easily see what is happening.

Note that the demo uses some features added only recently. Therefore Laz trunk is needed to compile this demo.

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Pan one series but limit direction of other series
« Reply #4 on: September 15, 2019, 03:23:38 pm »
Thank you for the suggestion. Can two separate charts be overlapped?

I need the series to overlap in the same visible area (like one chart). Having two separate charts is not desirable in my case.

I'm probably making this sound more complicated than necessary.

I have attached a simplified image of the chart operation.

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: Pan one series but limit direction of other series
« Reply #5 on: September 15, 2019, 03:41:13 pm »
I can't get the logics behind it:

Going from the left to the center image I see that you zoom the red curve, but the blue curve remains unzoomed! You pan the zoomed red curve upward - the blue (unzoomed) curve stays where it is.

From the center to the right image, you pan the zoomed red curve to the right, the unzoomed blue curve follows. But at which speed? The red curve is zoomed and has a different x axis scale than the blue axis.

Maybe it would be clearer if you would explain what this chart is supposed to express.


AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Pan one series but limit direction of other series
« Reply #6 on: September 15, 2019, 03:50:10 pm »
The blue curve is locked to the same X-axis as the red curve. In my case, the x-axis is time.

From left image to center:
 - zoom in on a part of the red curve and pan it upwards to have the red curve details shown near the vertical center of the chart.

From the center to the right image:
 - zoom in the red curve a bit more and pan it to the right.
 - The blue curve follows the x-axis panning of the red curve.

The reason I want this operation is that both curves use different y axis units of measurement, but both have the same x-as (time) unit of measurement, and I only want zoom/pan related to the red curve for closer examination.

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: Pan one series but limit direction of other series
« Reply #7 on: September 15, 2019, 04:05:28 pm »
The blue curve is locked to the same X-axis as the red curve. In my case, the x-axis is time.

From left image to center:
 - zoom in on a part of the red curve and pan it upwards to have the red curve details shown near the vertical center of the chart.

From the center to the right image:
 - zoom in the red curve a bit more and pan it to the right.
 - The blue curve follows the x-axis panning of the red curve.

The reason I want this operation is that both curves use different y axis units of measurement, but both have the same x-as (time) unit of measurement, and I only want zoom/pan related to the red curve for closer examination.
What I don't understand is: How can you use the same x axis for both curves and zoom x only for the red curve and keep the x units for the blue curve unchanged? Shouldn't the x axis be zoomed also for the blue curve?

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Pan one series but limit direction of other series
« Reply #8 on: September 15, 2019, 04:16:18 pm »
Oops, sorry about that confusion!!! I have attached a proper image sequence.

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: Pan one series but limit direction of other series
« Reply #9 on: September 15, 2019, 05:05:32 pm »
Is the blue curve always a sine as shown?

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Pan one series but limit direction of other series
« Reply #10 on: September 15, 2019, 05:19:55 pm »
In my case, the blue curve is the Sun elevation which is computed depending on latitude/longitude. It happens to be a sine.

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: Pan one series but limit direction of other series
« Reply #11 on: September 15, 2019, 05:38:40 pm »
So you have a formula for it. You could use a TFuncSeries for the blue curve and specify the formula in its OnCalculate event. You can adjust the amplitude and baseline so that the sine always is always full-screen, before as well as after zooming.

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Pan one series but limit direction of other series
« Reply #12 on: September 15, 2019, 06:05:43 pm »
That looks very workable. Thank you!!

 

TinyPortal © 2005-2018