Articles in this section

How to handle different types of axes and display them in reverse order in WinForms Chart?

WinForms Charts include default primary X and Y axes, along with an optional secondary Y-axis for displaying data on different scalesYou can programmatically add a ChartAxis for more flexibility, such as when plotting x and y values together. To move an axis, set OpposedPosition as true for the secondary Y-axis or Inversed as true for the X-axis. 


//Assign the X and Y axes
this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Category;
this.chartControl1.PrimaryXAxis.Inversed = true;
this.chartControl1.PrimaryYAxis.ValueType = ChartValueType.Double;

//Configure the secondary axis
ChartAxis secYAxis = new ChartAxis();
secYAxis.Orientation = ChartOrientation.Vertical;
secYAxis.Range = new MinMaxInfo(0, 100, 20);
secYAxis.OpposedPosition = true;
this.chartControl1.Axes.Add(secYAxis);

//Configure the chart series1
ChartSeries chartSeries1 = new ChartSeries("Series 1");
chartSeries1.CategoryModel = new CategoryAxisDataBindModel(dataSource)
{
    CategoryName = "Year",
    YNames = new string[] { "Sales" }
};
this.chartControl1.Series.Add(chartSeries1);

//Configure the chart series2
ChartSeries chartSeries2 = new ChartSeries("Series 2");
chartSeries2.CategoryModel = new CategoryAxisDataBindModel(dataSource)
{
    CategoryName = "Year",
    YNames = new string[] { "YValue" }
};
chartSeries2.YAxis = secYAxis;
this.chartControl1.Series.Add(chartSeries2);
'Assign the X and Y axes
columnChart.PrimaryXAxis.ValueType = ChartValueType.Category
columnChart.PrimaryXAxis.Inversed = True
columnChart.PrimaryYAxis.ValueType = ChartValueType.Double

'Configure the secondary Y axis
Dim secYAxis = New ChartAxis()
secYAxis.Orientation = ChartOrientation.Vertical
secYAxis.Range = New MinMaxInfo(0, 100, 20)
secYAxis.OpposedPosition = True
columnChart.Axes.Add(secYAxis)

'Configure the chart series1
Dim ChartSeries1 As ChartSeries = New ChartSeries("Series 1")
Dim dataSeriesModel = New CategoryAxisDataBindModel(viewModel.PlantDetails)
dataSeriesModel.CategoryName = "Year"
dataSeriesModel.YNames = New String() {"Sales"}
ChartSeries1.CategoryModel = dataSeriesModel
columnChart.Series.Add(ChartSeries1)

'Configure the chart series2
Dim ChartSeries2 = New ChartSeries("Series 2")
dataSeriesModel.CategoryName = "Year"
dataSeriesModel.YNames = New String() {"YValue"}
ChartSeries2.CategoryModel = dataSeriesModel
ChartSeries2.YAxis = secYAxis
columnChart.Series.Add(ChartSeries2)
Output:

multiple axis and reverse order


Conclusion

I hope you enjoyed learning about how to work with different types of axes and display them in reverse direction in WinForms Chart.

You can refer to our WinForms Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms Chart examples to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you! 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied