Profile Picture

Quick question on scale

Posted By Jason Brigham 15 Years Ago
Author
Message
Jason Brigham
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 5, Visits: 8
I think I have a pretty quick question on getting the Min and Max values of a particular scale.

I have a line chart that I populate with a series. My X-Axis are my ordinal parts and my Y-Axis is the actual values (decimal). By default, I'm not setting a specific scale for the Y-Axis so the chart automatically creates a scale that will show all my data as I plot it. This is nice. However, I need to find out the Max and Min on the Y-Axis for what it created. I've tried several properties in the View, ViewRange and all appear to be empty.

Where can I find the Max and Min values of the scale as set by the chart automatically?
Thanks!
Jason

bob milanov
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Jason,

 

You need to install a custom paint call back as the actual axis range is computed at layout phase, before the component is painted. This is because the range may be affected by the size of the control on the screen/printer due to tick rounding and automatic tick step generation - the following code snippet shows how to get the actual range shown on the Y axis:

 

class NCustomPaintCallback : INPaintCallback

{

    #region INPaintCallback Members

 

    public void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)

    {

        NChart chart = (NChart)panel;

       

        NRange1DD rulerRange = chart.Axis(StandardAxis.PrimaryY).Scale.RulerRange;

       

        // rulerRange.Begin contains scale begin after tick rounding

        // rulerRange.End contains scale begin after tick rounding

    }

   

    public void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs)

    {

    }

 

    #endregion

}

 

private void Form1_Load(object sender, EventArgs e)

{

    NChart chart = nChartControl1.Charts[0];

    chart.PaintCallback = new NCustomPaintCallback();

   

    NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

   

    bar1.Values.Add(10);

    bar1.Values.Add(23);

    bar1.Values.Add(13);

}

Hope this helps - let me know if you meet any problems or have any questions.

Best regards,
Bob



Jason Brigham
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 5, Visits: 8
Hmm.. OK.. I thought it was something a little simpler. Here is the end goal. I'd like to add a vertical line to the plot, but since the Y-Axis is automatically drawn, I don't know what values to use for the begin and end. If the numbers are too big, it auto-adjusts and flattens out the data. If the line is too small, it looks odd. I was trying to determine the min and max because I wanted to draw the line from Min to Max.

In the Help documentation, in the section Chart for .NET > User's Guide > Axes > Scale > Scale Configurators > Custom Labels, there is a picture of a custom value with "reference line", but there isn't anywhere I can find that describes how to do this. Maybe this is a solution?

In the end, I would like a dashed line to run vertically in the middle of the chart at a particular ordinal position (the X-Axis is ordinal in this case).

Thanks!
Jason

Jason Brigham
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 5, Visits: 8
Woops.. I just found the ConstLines. I don't know why I didn't see it before. Please disregard my last question.

Thanks!
Jason

bob milanov
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Jason,

Glad you found it - I just was about to suggest it . If you meet any problems let me know...

Best regards,
Bob





Similar Topics


Reading This Topic