Profile Picture

Adding min max labels on y axis

Posted By Manal Goyal 6 Years Ago
Author
Message
Manal Goyal
Question Posted 6 Years Ago
View Quick Profile
Forum Member

Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 29, Visits: 405
Hi Team,

I want to add min, max labels on y axis to highlight minimum and maximum values achieved by the series. What I managed to come up with is this:



You can see that labels are inside the graph, but I want labels to be present on the scale itself(But the important thing is that I don't want labels to interfere with the tick values, they can appear next to tick values).

This is the code I am currently using:


private void AddMinMaxLabel(NAxis axis, double min, double max)
   {
    NAxisConstLine constLine1 = new NAxisConstLine
    {
      StrokeStyle = { Color = Color.Gray },
      Value = min,
      TextAlignment = ContentAlignment.MiddleLeft,
      Text = " Min " + min.ToString("0.000")
    };
    constLine1.TextStyle.FontStyle.Style = FontStyle.Bold;
    NAxisConstLine constLine2 = new NAxisConstLine
    {
      StrokeStyle = { Color = Color.Gray },
      Value = max,
      TextAlignment = ContentAlignment.TopLeft,
      Text = " Max " + max.ToString("0.000")
    };
    constLine2.TextStyle.FontStyle.Style = FontStyle.Bold;
    axis.ConstLines.Add(constLine1);
    axis.ConstLines.Add(constLine2);
   }


Can you guide me for the right way to do it?
Thanks and regards
Manal


Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Today @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Manal,
You can use custom value labels for this purpose:

NChart chart = nChartControl1.Charts[0];

NBarSeries bar = new NBarSeries();
bar.Values.Add(10);
chart.Series.Add(bar);

NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
NCustomValueLabel maxValue = new NCustomValueLabel();
maxValue.Text = "Max";
maxValue.Value = 10;
scale.CustomLabels.Add(maxValue);
scale.CreateNewLevelForCustomLabels = false;

the above code also shows how to merge the custom value labels with the automatically generated ones so that when they overlap the custom labels will show only.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic