Page 1 of 1

Multiple Graphs with a common axis

Posted: Wed Jun 04, 2014 6:18 am
by 16566546
I wish to plot a range of different graphs using a common left axis but with separate chart areas. To illustrate, in the attached example, I would like the bar chart in one area and the line chart in a separate but contiguous area, with separate properties (e.g. vertical zoom in the bar chart, general zoom in the line chart.

To complicate this, I cannot assume any axis ranges for the line chart - normally the graphs will auto-range. Furthermore, I want to be able to hide the bar chart or the line chart area if no data of that type is present.

Any general suggestions would be greatly appreciated.

Best regards

Errol

Re: Multiple Graphs with a common axis

Posted: Wed Jun 04, 2014 2:57 pm
by yeray
Hi Errol,
Errol wrote:I wish to plot a range of different graphs using a common left axis but with separate chart areas. To illustrate, in the attached example, I would like the bar chart in one area and the line chart in a separate but contiguous area, with separate properties (e.g. vertical zoom in the bar chart, general zoom in the line chart.
I can think on three options:

- Custom axes would probably be the easiest solution. However, the zoom and scroll features will be dependant.
See the Opaque Zones example shipped with the features demo (All Features\Welcome !\Axes\Opaque Zones).

- The SubChart tool allows you to draw a second chart in the same area where the first chart is. This allows you to have zoom and scroll independant.
See SubChart tool examples shipped with the features demo (All Features\Welcome !\Tools\SubCharts).

- Create two charts and set the margins manually to make one to be draw next to the other.
Errol wrote:To complicate this, I cannot assume any axis ranges for the line chart - normally the graphs will auto-range.
I'm not sure to understand what do you exactly mean here. If you set the axes to be automatic, the chart will calculate the axis range to fit the values visible in it. If you set the axis to be manual, you'll have to calculate and set the minimum and maximim yourself.
Errol wrote:Furthermore, I want to be able to hide the bar chart or the line chart area if no data of that type is present.
If you work with custom axes, hiding all the series linked to an axis makes the axis not to be drawn. So, in this situation, you just need to recalculate the visible axes positions.
If you work with SubCharts, you can always hide or make visible the charts in the subchart tool. After it, you will also have to recalculate the position and size of the visible chart.
If you are working with two different charts, you should proceed as with the chart into the subchart tool. You can hide a chart and recalculate the position and size of the visible one.

Axis Scroll and Axis Popup Interference

Posted: Wed Jun 25, 2014 5:38 am
by 16566546
I have implemented the Axis Scroll tool on all axes of my chart. However, these axes already have a right-click popup function, used to change units (e.g. from meters to feet or °C to °F). Now, when I right-click to activate the popup, the Axis Scroll activates, and I have to click the mouse button to turn it off. How can I prevent Axis Scroll when I select axis popup?

Thanks in advance for your comments.

Regards

Errol

Re: Multiple Graphs with a common axis

Posted: Wed Jun 25, 2014 10:06 am
by yeray
Hi Errol,

I think it's a quite different question that would justify a new thread, but anyway, with the following code you could disable the TAxisScrollTool when the axis is clicked with the right mouse button:

Code: Select all

var oldAllowPanning: TPanningMode=pmBoth;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (ChartTool1.Axis.Clicked(X, Y)) and (Button=mbRight) then
  begin
    ChartTool1.Active:=false;
    oldAllowPanning:=Chart1.AllowPanning;
    Chart1.AllowPanning:=pmNone;
  end;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ChartTool1.Active:=true;
  Chart1.AllowPanning:=oldAllowPanning;
end;

Re: Multiple Graphs with a common axis

Posted: Wed Jun 25, 2014 10:31 pm
by 16566546
Hi Yeray

Thanks for your suggestion to solve the Axis Scroll / Popup conflict. I will try this out.

I apologise for not starting a new thread - the reason for this is that when I use your forum, I always first view my posts and there is no New Topic option available there. I then had a temporary brain freeze about how to find it. Given that the forum appears to know the group you are working in (in my case VCL / CLX), then is there any reason not to have a New Topic option available on the View your posts page.

Best regards

Errol

Re: Multiple Graphs with a common axis

Posted: Thu Jun 26, 2014 8:54 am
by yeray
Hi Errol,
Errol wrote:I apologise for not starting a new thread - the reason for this is that when I use your forum, I always first view my posts and there is no New Topic option available there. I then had a temporary brain freeze about how to find it. Given that the forum appears to know the group you are working in (in my case VCL / CLX), then is there any reason not to have a New Topic option available on the View your posts page.
Thanks for the explanation.
Browsing into the VCL/CLX forum, here, you should be able to see the "New topic" button. Don't hesitate to let us know if you don't.
Note the "View your posts" button returns a search per your user so there's no forum or category selected there. And I don't think the forum knows what's your area VCL/NET/Java. It could have a "default" category/forum section per user so the button can appear even when you are out of any forum/category. But this would be a wish for phpbb developers more than for us. And also note this is a modified version of phpbb forums, adapted to use Steema licensing system, so we should move the modifications to the new version of the forums when they will include this new option.
I see easier and faster if you save the VCL/CLX link in your bookmarks ;)