How to set a custom origin for an axis in WinForms Chart?
In Syncfusion® WinForms Chart, by default, the axis calculates its origin based on the data within the series. Utilizing the CustomOrigin property of an axis, you can modify this origin. To allow the origin to be set manually with the Origin property, ensure that CustomOrigin is set to true.
//Assign the X and Y axes
this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Category;
this.chartControl1.PrimaryYAxis.ValueType = ChartValueType.Double;
//Configure the chart series
CategoryAxisDataBindModel dataSeriesModel = new CategoryAxisDataBindModel(dataSource);
dataSeriesModel.CategoryName = "Year";
dataSeriesModel.YNames = new string[] { "Sales" };
ChartSeries chartSeries = new ChartSeries("Sales");
chartSeries.Type = ChartSeriesType.Column;
chartSeries.CategoryModel = dataSeriesModel;
//Assign a custom origin value for the Y-axis
this.chartControl1.PrimaryYAxis.CustomOrigin = true;
this.chartControl1.PrimaryYAxis.Origin = 30;
'Assign the X and Y axes
columnChart.PrimaryYAxis.ValueType = ChartValueType.Double
columnChart.PrimaryXAxis.ValueType = ChartValueType.Category
'Configure the chart series
Dim chartdatabindmodel1 As CategoryAxisDataBindModel = New CategoryAxisDataBindModel(viewmodel.PlantDetails)
chartdatabindmodel1.CategoryName = "Year"
chartdatabindmodel1.YNames = New String() {"Sales"}
Dim chartseries1 As ChartSeries = New ChartSeries("Sales")
chartseries1.CategoryModel = chartdatabindmodel1
chartseries1.Type = ChartSeriesType.Column
columnChart.Series.Add(chartseries1)
'Assign a custom origin value for the Y-axis
columnChart.PrimaryYAxis.CustomOrigin = True
columnChart.PrimaryYAxis.Origin = 30Output:
Conclusion
I hope you enjoyed learning about how to set a custom origin for an axis 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!