X Axes show both Top and Bottom

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v11)  /  Re: X Axes show both Top and Bottom

DynamicPDF CoreSuite for .NET (v11) Forum

 Sep 29 2021 6:11 AM
Hello, just want to ask if how will I put both top and bottom the xAxes with type HorizontalBar
I want it both the same, even I only have 1 bar.

 Sep 29 2021 9:41 AM
Posted by a ceTe Software moderator

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();

            Chart chart = new Chart(0, 0, 400, 230);
            PlotArea plotArea = chart.PrimaryPlotArea;

            Title title1 = new Title("Website Visitors");
            Title title2 = new Title("Year 2007");
            // 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

            NumericXAxis customXAxis = new NumericXAxis();
            customXAxis.AnchorType = XAxisAnchorType.Top;
            customXAxis.Min = 0;
            customXAxis.Max = 5.5f;

            // Create a title and add it to the xaxis
            Title lTitle = new Title("Visitors (in millions)");

            //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
            // Save the PDF
            string pdfFilePath = @"C:\Temp\MyChart.pdf";
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 4:50 PM.