Posted by a ceTe Software moderator
Hi,
You can achieve your requirements by creating a new NumericXAxis and adding it to the plot area. Make sure to set the AnchorType and correct Min and Max values for the Axis.
Here is a code sample to add top and bottom X-Axes:
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Chart chart = new Chart(0, 0, 400, 230);
PlotArea plotArea = chart.PrimaryPlotArea;
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year 2007");
chart.HeaderTitles.Add(title1);
chart.HeaderTitles.Add(title2);
// Create a indexed bar series and add values to it
IndexedBarSeries barSeries1 = new IndexedBarSeries("Website A");
barSeries1.Values.Add(new float[] { 5 });
// Add indexed bar series to the plot area
plotArea.Series.Add(barSeries1);
NumericXAxis customXAxis = new NumericXAxis();
customXAxis.AnchorType = XAxisAnchorType.Top;
customXAxis.Min = 0;
customXAxis.Max = 5.5f;
plotArea.XAxes.Add(customXAxis);
// Create a title and add it to the xaxis
Title lTitle = new Title("Visitors (in millions)");
barSeries1.XAxis.Titles.Add(lTitle);
//Adding AxisLabels to the yAxis
barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q1", 0));
barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q2", 1));
barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q3", 2));
barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q4", 3));
// Add the chart to the page
page.Elements.Add(chart);
// Save the PDF
string pdfFilePath = @"C:\Temp\MyChart.pdf";
document.Draw(pdfFilePath);
Thanks,
ceTe Software Support Team