Programmer Programmer - 15 days ago 6
C# Question

Can we draw Tertiary Y Axis with the use of chart control

I want to draw a graph which has 2 different Y axis with one X Axis. Can we take different Y axis for different series? In first series I want candlestick graph and in second column chart, both charts should be in same chart area and should not be mixed with each other.

For example you can see the picture below


TaW TaW
Answer

A ChartArea can have two x-axes and two y-axes.

The secondary axes are called

 chartArea.AxisX2 

and

 chartArea.AxisY2

Enable them like this:

  chartArea.AxisY2.Enabled = AxisEnabled.True;

Now you can style them as usual..

You can relate a Series to one of the Axes by setting the AxisType like this:

 yourSeries.YAxisType = AxisType.Secondary;

Talking about axes: It is worth knowing that you can move them relative to each other by setting their Crossing; see here for an example..

Comments