Thanks for the response. It should be noted that these charts are being generated in a Web Forms application.
Here's the configuration:
protected NChartControl _nChartCtrl;
protected NChart _nChart;
public MyStackedBarChart(int width, int height, int exportWidth, int exportHeight, int exportResolution)
{
_exportWidth = exportWidth;
_exportHeight = exportHeight;
_exportResolution = exportResolution;
_nChart = _nChartCtrl.Charts[0];
_nChart.PaintCallback = new ShrmStackedBarChartPaintCallback();
if ( width > 0 && height > 0 )
{
_nChart.Width = width;
_nChart.Height = height;
}
_nChart.BackgroundFillStyle = new NColorFillStyle(Color.Transparent);
_nChart.Axis(StandardAxis.Depth).Visible = false;
_nChart.PredefinedChartStyle = PredefinedChartStyle.HorizontalLeft;
_nChart.Dock = System.Windows.Forms.DockStyle.Fill;
_nChart.Padding = new NMarginsL(
new NLength(0, NRelativeUnit.ParentPercentage),
new NLength(2, NRelativeUnit.ParentPercentage),
new NLength(2, NRelativeUnit.ParentPercentage),
new NLength(2, NRelativeUnit.ParentPercentage)
);
_nChart.Wall(ChartWallType.Back).Visible = false;
NAxis xAxis = _nChart.Axis(StandardAxis.PrimaryX);
NOrdinalScaleConfigurator xScaleConfig = (NOrdinalScaleConfigurator)xAxis.ScaleConfigurator;
xScaleConfig.AutoLabels = false;
xScaleConfig.LabelStyle.ContentAlignment = ContentAlignment.MiddleRight;
xScaleConfig.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(25, 25, 25));
xScaleConfig.RulerStyle.BorderStyle = new NStrokeStyle(Color.FromArgb(25, 25, 25));
xScaleConfig.OuterMajorTickStyle.LineStyle = new NStrokeStyle(Color.FromArgb(25, 25, 25));
xScaleConfig.MajorTickMode = MajorTickMode.CustomStep;
xScaleConfig.CustomStep = 1;
xScaleConfig.InnerMajorTickStyle.Visible = false;
xScaleConfig.DisplayDataPointsBetweenTicks = false;
NAxis yAxis = _nChart.Axis(StandardAxis.PrimaryY);
// we need this for a little bit of space between the bars and the x-axis
yAxis.View = new NRangeAxisView(new NRange1DD(-0.02, 1));
NLinearScaleConfigurator yScaleConfig = (NLinearScaleConfigurator)yAxis.ScaleConfigurator;
yScaleConfig.RulerStyle.BorderStyle = new NStrokeStyle(Color.FromArgb(25, 25, 25));
yScaleConfig.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(25, 25, 25));
yScaleConfig.OuterMajorTickStyle.Visible = false;
yScaleConfig.InnerMajorTickStyle.Visible = false;
yScaleConfig.MajorGridStyle.LineStyle.Color = Color.Transparent;
// small offset from x-axis
yScaleConfig.MajorTickMode = MajorTickMode.CustomTicks;
yScaleConfig.CustomMajorTicks.Add(0);
yScaleConfig.CustomMajorTicks.Add(.2);
yScaleConfig.CustomMajorTicks.Add(.4);
yScaleConfig.CustomMajorTicks.Add(.6);
yScaleConfig.CustomMajorTicks.Add(.8);
yScaleConfig.CustomMajorTicks.Add(1);
// finally, turn y-axis values into percentages
yScaleConfig.LabelValueFormatter.FormatSpecifier = "0%";
_nChartCtrl.Legends.Clear();
}
Here's how the labels are being configured:
public void AddLabels(string[] labels)
{
NAxis xAxis = _nChart.Axis(StandardAxis.PrimaryX);
NOrdinalScaleConfigurator xScaleConfig = (NOrdinalScaleConfigurator)xAxis.ScaleConfigurator;
xScaleConfig.LabelStyle.ContentAlignment = ContentAlignment.MiddleCenter;
for (int i = 0; i < labels.Length; i++)
{
xScaleConfig.Labels.Add((string)labels[i]);
}
}
When data is added to a chart, it uses this configuration:
barSeries.MultiBarMode = MultiBarMode.StackedPercent;
barSeries.Values.AddRange(values);
if ( _hasSeenClustered )
{
barSeries.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength( barSeries.DataLabelStyle.TextStyle.FontStyle.EmSize.Value - 2 );
barSeries.BorderStyle.Color = Color.Transparent;
}
else
{
barSeries.DataLabelStyle.TextStyle.FontStyle.Style = FontStyle.Bold;
barSeries.BorderStyle.Color = color.Start;
}
barSeries.DataLabelStyle.Visible = true;
barSeries.DataLabelStyle.VertAlign = Nevron.VertAlign.Center;
barSeries.DataLabelStyle.ArrowLength = new NLength(0);
barSeries.DataLabelStyle.TextStyle.BackplaneStyle.Visible = false;
barSeries.DataLabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.White);
// fix up our percentages
barSeries.DataLabelStyle.Format = "
";
System.Globalization.CultureInfo newCulture = (System.Globalization.CultureInfo)barSeries.PercentValueFormatter.CultureInfo.Clone();
newCulture.NumberFormat.PercentSymbol = "";
newCulture.NumberFormat.PercentDecimalDigits = 0;
newCulture.NumberFormat.PercentPositivePattern = 1;
newCulture.NumberFormat.PercentNegativePattern = 1;
barSeries.PercentValueFormatter.CultureInfo = newCulture;
barSeries.FillStyle = new NGradientFillStyle(color.Start, color.End);
Thanks for your assistance!