Difficulty Setting X-Axis Labels

I am using the Chart control for a Winforms app.  I am loading the control with two data series - each with its own datatable.

tblRevenue.jpgtblBookings.jpg


Here is my code for the control (chrtCharts):

            ChartDataBindModel modelBooking = null;

            ChartDataBindModel modelInvoicing = null;

            ChartDataBindAxisLabelModel xAxisModel = null;


            modelBooking = new ChartDataBindModel(dtBooking);

            modelBooking.XIndex = 0;

            modelBooking.YIndexes = new int[] { 1 };


            modelInvoicing = new ChartDataBindModel(dtInvoicing);

            modelInvoicing.XIndex = 0;

            modelInvoicing.YIndexes = new int[] { 1 };


            ChartSeries seriesBookings = new ChartSeries("BOOKINGS");

            seriesBookings.Text = seriesBookings.Name;

            seriesBookings.SeriesModel = modelBooking;

            seriesBookings.Type = ChartSeriesType.Column;

            seriesBookings.Style.DisplayText = true;

            chrtCharts.Series.Add(seriesBookings);


            ChartSeries seriesRevenue = new ChartSeries("REVENUE");

            seriesRevenue.Text = seriesRevenue.Name;

            seriesRevenue.SeriesModel = modelInvoicing;

            seriesRevenue.Type = ChartSeriesType.Column;

            seriesRevenue.Style.DisplayText = true;

            chrtCharts.Series.Add(seriesRevenue);


            xAxisModel = new ChartDataBindAxisLabelModel(dtBooking);

            //xAxisModel.PositionName = "DATES";

            //xAxisModel.PositionIndex = 0;

            xAxisModel.LabelName = "DATES";

            //xAxisModel.LabelIndex = 0;

            chrtCharts.PrimaryXAxis.LabelsImpl = xAxisModel;

            chrtCharts.PrimaryXAxis.CustomLabelsParameter = ChartCustomLabelsParameter.Position;


            chrtCharts.PrimaryXAxis.HidePartialLabels = true;

            chrtCharts.PrimaryXAxis.ValueType = ChartValueType.Custom;

            chrtCharts.PrimaryXAxis.Range = new MinMaxInfo(0, dtBooking.Rows.Count + 1, 1);

            chrtCharts.PrimaryXAxis.PointOffset = 1;

            chrtCharts.PrimaryXAxis.LabelAlignment = StringAlignment.Center;

            chrtCharts.PrimaryXAxis.LabelRotate = true;

            chrtCharts.PrimaryXAxis.LabelRotateAngle = 70;

            chrtCharts.PrimaryXAxis.Title = "";


            chrtCharts.PrimaryYAxis.ValueType = ChartValueType.Double;

            chrtCharts.PrimaryYAxis.Format = "C";

            chrtCharts.PrimaryYAxis.Title = "";


            chrtCharts.ShowLegend = true;

            chrtCharts.LegendsPlacement = ChartPlacement.Inside;

            chrtCharts.LegendPosition = ChartDock.Top;

            chrtCharts.AutoHighlight = false;

            chrtCharts.SeriesHighlight = false;


            chrtCharts.Refresh();

            chrtCharts.Visible = true;


However, the chart displays as this:
chrtData.jpg

* Please note that the X-Axis labels are all correct, but the data is all plotted on top of itself.

If I change the line of code:

                  chrtCharts.PrimaryXAxis.ValueType = ChartValueType.Custom;

to:

                  chrtCharts.PrimaryXAxis.ValueType = ChartValueType.Catagory;

then I get the following chart:

chrtLabels.jpg

* Note that now the X-Axis labels are not correct, but the data is plotted correctly (out of order, but not on top of itself.)


How can I get the data to be displayed correctly with the correct X-Axis labels?

Thanks,

Greg


5 Replies 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team June 6, 2022 12:53 AM UTC

Hi Greg,


We will check and update you with complete details on June 06, 2022.


Regards,

Yuvaraj.



DD Devakumar Dhanapoosanam Syncfusion Team June 7, 2022 03:40 AM UTC

Hi Greg,


We still need some more time and will update details on or before June 8, 2020. We appreciate your patience until then.


Regards,

Devakumar D



DD Devakumar Dhanapoosanam Syncfusion Team June 7, 2022 12:46 PM UTC

Hi Greg,


We can resolve the reported problem by removing the XIndex set as “0” for both modelBooking and modelInvoicing ChartDataBindModel as per in the below code example.


modelBooking = new ChartDataBindModel(dtBooking);

modelBooking.XIndex = 0;

modelBooking.YIndexes = new int[] { 1 };

modelInvoicing = new ChartDataBindModel(dtInvoicing);

modelInvoicing.XIndex = 0;

modelInvoicing.YIndexes = new int[] { 1 };


Output:

Chart, bar chart

Description automatically generated


Please find the example sample from the attachment below and let us know if you need any further assistance on this.


Regards,

Devakumar D


Attachment: SF_175415_abb9694.zip

Marked as answer

GS Greg Saladino June 9, 2022 03:56 PM UTC

Thank you very much!!



DD Devakumar Dhanapoosanam Syncfusion Team June 10, 2022 06:39 AM UTC

Hi Greg,


Thanks for your update.


Please let us know if you need any further assistance.


Regards,

Devakumar D


Loader.
Up arrow icon