Profile Picture

How to show bar graph with margin in bar

Posted By shweta jain Last Year
Author
Message
shweta jain
Problem Posted Last Year
View Quick Profile
Junior Member

Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)

Group: Forum Members
Last Active: 4 Months Ago
Posts: 16, Visits: 192
hello,

I am using bar series like attached image, but due to large no of values, it is looking like an area.
Issue - bar chart loooking like an area.
I want to show bars which should be thinner with a margin that divides the bars.
How can update chart with thinner bar  with a margin that divides the bars?


Nevron Support
This post has been flagged as an answer
Posted Last Year
View Quick Profile
Supreme Being

Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)Supreme Being (4,112 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 2,974, Visits: 3,420
Hi Shweta,

You can control the bar width using the WidthPercent property:

NChart chart = nChartControl1.Charts[0];

NBarSeries bar = new NBarSeries();
bar.DataLabelStyle.Visible = false;
bar.BorderStyle.Width = new NLength(0);
bar.EnableXPixelSnapping = false;
bar.WidthPercent = 50;
chart.Series.Add(bar);

for (int i = 0; i < 1000; i++)
{
bar.Values.Add(i);
}
this will only work in the case the bar series is operating in categorical mode (e.g. you do not supply the xvalues). In case you provide xvalues you need to use BarWidthMode in combination with LogicalBarWidth or BarWidth depending on the mode:

NChart chart = nChartControl1.Charts[0];

NBarSeries bar = new NBarSeries();
bar.DataLabelStyle.Visible = false;
bar.BorderStyle.Width = new NLength(0);
bar.EnableXPixelSnapping = false;
bar.UseXValues = true;
bar.BarWidthMode = BarWidthMode.Logical;
bar.LogicalBarWidth = 0.5f;

chart.Series.Add(bar);

for (int i = 0; i < 1000; i++)
{
bar.Values.Add(i);
bar.XValues.Add(i);
}

Note that in both cases we would advise you to disable x pixel snapping. 
We hope this helps - let us know if you have any questions.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic