problem setting custom axis range


Author
Message
Tal Harari
Tal Harari
Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)
Group: Forum Members
Posts: 19, Visits: 2
hi,

I'm trying to set custom axis min\max values, that i calculate based on the current min\max values of my cartesian chart.

I've come to realize that the scale's min\max values do not update, only until after the chart is painted, so I created a PaintCallback class that I use to recalculate the min\max values' and use them by creating a new RangeView for the axis.

The problem is that when I set the new min\max values to the chart in the paint callback class (doesn't matter if I do it on Before\After paint) the axis range doesn't update, but only after about a second or so.

here is a general example of what i'm doing (cant post the real code here):

class MyForm : Form
{
public MyForm()
{
InitializeComponents();

NCartesianChart chart = new NCartesianChart();

// ...
// Add the chart to the NChartControl
// ...
// Create series for chart
// ...
// bind chart to datatable
// ...

chart.PaintCallback = new MyPaintCallback();
}

// ...
// Other Methods
// ...
}

class MyPaintCallback : NPaintCallback
{
public override void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs)
{
double min = chart.Axis(StandardAxis.PrimaryY).SeriesRange.Begin - 20;
double max = chart.Axis(StandardAxis.PrimaryY).SeriesRange.End + 50;
chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(min, max), true, true);
}
}

Can i make the axis refresh its range after i change it?
Or perhaps i need change the min\max values in some other way?
Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Tal,

If you want to inflate the axis range in logical scale you can use:

NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
scale.ViewRangeInflateMode = ScaleViewRangeInflateMode.Logical;
scale.InflateViewRangeBegin = true;
scale.InflateViewRangeEnd = true;
scale.LogicalInflate = new NRange1DD(20, 20);

Otherwise you can force the chart to recalculate:

nChartControl1.Document.Calculate();
nChartControl1.Document.RecalcLayout(nChartControl1.View.Context);

then you can access the axis series range and not have to bother with the paint callbacks.



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search