Profile Picture

Auto Label Style using XValues

Posted By Simon Milne 11 Years Ago
Author
Message
Simon Milne
questionmark Posted 11 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 2, Visits: 6
Hi,
I have a line chart where we are plotting dates along with numberic values.
We have set the flag for useXValues and are posting the dates to these values.
A sample of the values we have are:

18/02/2013 100
02/04/2013 106.2230437
03/04/2013 106.1614295
23/04/2013 107.0856439

When these values are plotted to the chart (we have an overlapped line style chart)
instead of just showing the 4 ticks added, it attempts to scale the chart based on the dates and fill in the dates inbetween.

Is there a way you can force it to just show the 4 entries withour scaling the ticks?

Im sure this is very simple and im just being a bit blind but i cant seem to get it to work!

for info we are using the nDateTimeScaleConfigurator

Any help would be appreciated

Thanks

Simon


Nevron Support
Posted 11 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: Last Week
Posts: 3,054, Visits: 4,009
Hi Simon,

You can use a categorical scale in this case (no need to use x values). For example:

         NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
         NBarSeries bar = new NBarSeries();

         bar.Values.Add(100);
         bar.Values.Add(106.2230437);
         bar.Values.Add(106.1614295);
         bar.Values.Add(107.0856439);

         chart.Series.Add(bar);

         NOrdinalScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;
         scale.AutoLabels = false;
         scale.Labels.Add("18/02/2013");
         scale.Labels.Add("02/04/2013");
         scale.Labels.Add("03/04/2013");
         scale.Labels.Add("23/04/2013");

Creates a simple categorical chart. Let us know if you meet any problems.



Best Regards,
Nevron Support Team



Simon Milne
Posted 11 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 2, Visits: 6
Hi,
Many thanks for the reply.
I had originally tried adding the scale values manually, but found when testing the chart that as some lines had more entries than others, the ones with say only 3 entries were not plotted against the correct position (originally i had thought each series had the same number of entries but then found they didnt) what of course happens is the one with say five entries is correct, but the one with less gets potted against the first three labels thus making the data invalid.

For this reason i ended up plotting the actual x values, and of course this solved the problem with data being against the correct dates, but introduced the issue with it applying scale to the actual x values.

Technically the data is correct, but for the purposes of the chart we are building the extended time periods are not needed and make the chart harder to read.

Is there any way around this or would i need to somehow fudge the data so all lines have the same dates and manually populate the scale.

Thanks again

Simon

Nevron Support
Posted 11 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: Last Week
Posts: 3,054, Visits: 4,009
Hi Simon,

Not sure if we understand the problem properly, but first guess is that you want to have a scale which is decorated each day (or number of days) regardless of whether there are data points in this day or not. You probably also want to exclude weekends and other non working days. There are generally two ways to achieve this:

1. Using an ordinal scale you can add labels to the x axis for each category and either pass a value or fill the value with empty data point. For example if you have data for three non adjacent days:

1/1/2013
1/2/2013
1/4/2013

this can be plotted as:

NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
NBarSeries bar = new NBarSeries();

bar.Values.Add(100);
bar.Values.Add(106.2230437);
bar.Values.Add(DBNull.Value);
bar.Values.Add(107.0856439);

chart.Series.Add(bar);

NOrdinalScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;
scale.AutoLabels = false;
scale.Labels.Add("01/01/2013");
scale.Labels.Add("01/02/2013");
scale.Labels.Add("01/03/2013");
scale.Labels.Add("21/04/2013");

in other words adding empty data points to the values in the category allows you to "catch up" with the labels in the X axis.

2. Alternatively you can use a DateTime scale with XY scatter mode. In order to filter the weekends you can apply a working calendar.

Also can you post a screenshot of the chart you want to create?

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic