Hi,
Is it possible to set in angle the x Label in a chart? And is it possible to set the interval with a multiplication factor? Like multiple of 10 i.e. 1,10,100,1000...
thanks,
x Label
Re: x Label
Support · Apr 26, 2012Hello,
Yes, you can set angle to the XAxis labels using Angle property of the XAxisLabelList class below is the sample code for it. It is not possible to set the interval with multiplication factor using our DynamicPDF Generator for .NET product.
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);
// Create a chart
Chart chart = new Chart(0, 0, 400, 230);
// Create a plot area
PlotArea plotArea = chart.PrimaryPlotArea;
// Create header titles and add it to the chart
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year - 2007");
chart.HeaderTitles.Add(title1);
chart.HeaderTitles.Add(title2);
// Create a indexed line series and add values to it
IndexedLineSeries lineSeries1 = new IndexedLineSeries("Website A");
lineSeries1.Values.Add(new float[] { 5, 7, 9, 6 });
IndexedLineSeries lineSeries2 = new IndexedLineSeries("Website B");
lineSeries2.Values.Add(new float[] { 4, 2, 5, 8 });
IndexedLineSeries lineSeries3 = new IndexedLineSeries("Website C");
lineSeries3.Values.Add(new float[] { 2, 4, 6, 9 });
// Add indexed line series to the plot area
plotArea.Series.Add(lineSeries1);
plotArea.Series.Add(lineSeries2);
plotArea.Series.Add(lineSeries3);
// Create a title and add it to the yaxis
Title lTitle = new Title("Visitors (in millions)");
lineSeries1.YAxis.Titles.Add(lTitle);
//Adding AxisLabels to the XAxis
lineSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Firsrt ", 0));
lineSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Second ", 1));
lineSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Third ", 2));
lineSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Fourth", 3));
XAxisLabelList Xlist = lineSeries1.XAxis.Labels;
Xlist.Angle = 45;
lineSeries1.YAxis.Interval = 2;
// Add the chart to the page
page.Elements.Add(chart);
// Save the PDF
document.Draw(@"C:/MyDocument.pdf");
Thanks,
ceTe Software Support Team.