Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
630
Creating a custom Y2 Axis on a LineChart
posted

Is it possible to create a custom Y2 axis on a linechart? I need to create another axis, ideally the Y2 (right) axis using  the max and min values from the Y axis and multipled by a certain factor. For example in the chart attached, if I had a factor of 2, could I draw a Y2 axis with its min value = 0 and its max value = 200 and have it labeled as such.

  • 26458
    Verified Answer
    Offline posted

    Yes, you can add a Y2 axis in such a way, as long as you either know what the min and max values are or have a way to extract/calculate them. You should be able to get min and max from the datasource.

    The process of adding Y2 can be slightly different depending on whether you have a simple line chart or a composite chart with a line layer. In case of a simple chart, you have to set the following:

    ultraChart1.Axis.Y2.Visible = true;
    ultraChart1.Axis.Y2.Labels.Visible = true;
    ultraChart1.Axis.Y2.Labels.ItemFormat = AxisItemLabelFormat.DataValue;
    ultraChart1.Axis.Y2.RangeMin = yourMinValue;
    ultraChart1.Axis.Y2.RangeMax = yourMaxValue;
    ultraChart1.Axis.Y2.RangeType = AxisRangeType.Custom;

    For composite charts, the procedure is similar, but first you have to add a Y2 oriented axis to the ChartArea.Axes collection.