Profile Picture

Stacked bar problem

Posted By Vitaly Slobodyan 15 Years Ago
Author
Message
Vitaly Slobodyan
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 15 Years Ago
Posts: 3, Visits: 1

Hi All,

I have two charts. Each chart should show two series (Orange and Blue).
First problem is different scale for charts.
Bar for 432 value on right chart is narrow than bar for 406 value on left chart.
Is it possible to set some 'Max value' for chart, so chart will draw all bars scaling them to that 'Max value' ?

Next problem with data labels. They are overlapped.
Is it possible to configure chart so it will show data labels astride bar as on picture below?

Thank you!



Attachments
stacked labels.JPG (41 views, 14.00 KB)
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 Vitaly,

You can easily change the range displayed by the axis by modifying the axis range view - for example:

NChart chart = nChartControl1.Charts[0];
chart.Axis(
StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 500), true, true);

will force the axis to always display the range [0, 500] regardless of the data.

As for the data labels - there is still no way to resolve the overlapping, but in vol2 this will be addressed.

Let me know if you have any questions/comments.

Best regards,
Bob



Vitaly Slobodyan
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 15 Years Ago
Posts: 3, Visits: 1
Hi Bob!

Thank you very much!
Solution with axis range view works fine.

>As for the data labels - there is still no way to resolve the overlapping, but in vol2 this will be addressed.
>Let me know if you have any questions/comments.
I'm looking forward for Vol.2 but still need some solution for data labels.
Please advice is it possible to draw data labels manually?
There always will be two series on chart, so it's acceptable for me just draw data labels before and over the stacked bar.

Best regards,
Vitaly.

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 Vitaly,

You can use custom drawing - check out the following examples:

All Examples\Custom Painting\

Alternatively you can use custom value labels in combination with XML formatted texts:

NChart chart = nChartControl1.Charts[0];
NBarSeries bar = new NBarSeries();
bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(30);
chart.Series.Add(bar);
NOrdinalScaleConfigurator ordinalScale = new NOrdinalScaleConfigurator();
ordinalScale.AutoLabels =
false;
ordinalScale.LabelStyle.TextStyle.TextFormat =
TextFormat.XML;
ordinalScale.Labels.Add(
"Articles");
ordinalScale.Labels.Add(
"<font color = 'red' fontstyle = 'bold'> 406</font> Awards");
ordinalScale.Labels.Add(
"Buyers Guide");
ordinalScale.Labels.Add(
"Directories");
ordinalScale.Labels.Add(
"Events");
chart.Axis(
StandardAxis.PrimaryX).ScaleConfigurator = ordinalScale;

Let me know if you meet any problems.

Best regards,
Bob



Vitaly Slobodyan
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 15 Years Ago
Posts: 3, Visits: 1
Hi Bob,

Thank you for your answer.
Please note that red numbers 20 and 406 on attached picture is data labels not axis labels.
I intend to draw data label between axis and axis label.
Please advise is there any way to move axis label far from axis?
To set padding or some like this?

Best regards,
Vitaly

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 Vitaly,

 

You can change the data label style alignment (either per data point or per series). The following code snippet shows how to change it in both cases:

 

// to modify the data labels style applied on

// on all data points in a series:

NBarSeries bar = new NBarSeries();

 

// to align at the top

bar.DataLabelStyle.VertAlign = VertAlign.Top;

bar.DataLabelStyle.ArrowLength = new NLength(5);

bar.DataLabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.Red);

 

// to align at the bottom

bar.DataLabelStyle.VertAlign = VertAlign.Bottom;

bar.DataLabelStyle.ArrowLength = new NLength(5);

bar.DataLabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.Red);

 

// for example to modify the first data point data label style,

// so that it differs from the one specified by the series you can use:

NDataLabelStyle dls = new NDataLabelStyle();

dls.VertAlign = VertAlign.Bottom;

dls.ArrowLength = new NLength(5);

dls.TextStyle.FillStyle = new NColorFillStyle(Color.Red);

bar.DataLabelStyles[0] = dls;

 

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

 

Best regards,
Bob





Similar Topics


Reading This Topic