By Vahid Mesri - 6 Years Ago
|
Hi, I've created the attached float bar chart.
Y-Axis font size: The y-axis labels are quite lengthy and I wanted to increase y-axis font, however, I haven't been able to do so. Moreover I tried to break labels into separate lines but again unfortunately I couldn't find any way to break the lines. X-Axis font size: I cannot change the font size for the x-axis even though I have changed all relevant settings Axis -> Scale -> Label Text Style. I would like to keep the size of the chart area as it is but resize the font of the axis.
It seems that the font sizes are handled automatically for both the y-axis and x-axis hence my settings are overwritten. Can you kindly let me know how I can change the font sizes?
Best Regards, Vahid
|
By Nevron Support - 6 Years Ago
|
Hi Vahid,
The following code shows how to limit the width of the axis labels as well as how to modify the font size of both the X and Y axis labels:
// configure the chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.Axis(StandardAxis.Depth).Visible = false; chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft);
// setup X axis NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.AutoLabels = false; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.DisplayDataPointsBetweenTicks = false;
// set range labels with wrapping NRangeScaleLabelStyle labelStyle = new NRangeScaleLabelStyle(); labelStyle.TickMode = RangeLabelTickMode.None; labelStyle.MaxWidth = new NLength(100); labelStyle.WrapText = true; labelStyle.TextStyle.FontStyle.EmSize = new NLength(12); scaleX.LabelStyle = labelStyle;
scaleX.Labels.Add("Some Long Label Some Long Label 1"); scaleX.Labels.Add("Some Long Label Some Long Label 2");
// add interlaced stripe to the Y axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(12);
// create the float bar series NFloatBarSeries floatBar = (NFloatBarSeries)chart.Series.Add(SeriesType.FloatBar); floatBar.DataLabelStyle.Visible = false;
// add bars floatBar.AddDataPoint(new NFloatBarDataPoint(2, 10)); floatBar.AddDataPoint(new NFloatBarDataPoint(5, 16));
Hope this helps - let us know if you meet any problems or have any questions.
|
|