We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding text for series points on a bar chart

Thread ID:





98058 Jan 31,2011 05:46 AM UTC Feb 3,2011 01:37 PM UTC ASP.NET MVC (Classic) 1
Tags: Chart
Mike Gold
Asked On January 31, 2011 05:46 AM UTC


I'm reviewing your product on C# Corner and can't figure out how to add text to the x-axis point of a bar chart to the MVCChartModel. All I see on the series in the data model is Points which only takes integers. Any ideas how to do this in the MVC version without doing the following?

(saw this in the classic ASP.NET forum)

this.simpleChart.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.simpleChart.PrimaryXAxis.Labels.Add(new ChartAxisLabel("0-30", Color.Black, new Font("Caliber", 8), 1, "", ChartValueType.Custom));
this.simpleChart.PrimaryXAxis.Labels.Add(new ChartAxisLabel("31-60", Color.Black, new Font("Caliber", 8), 2, "", ChartValueType.Custom));
this.simpleChart.PrimaryXAxis.Labels.Add(new ChartAxisLabel("61-90", Color.Black, new Font("Caliber", 8), 3, "", ChartValueType.Custom));

Krishnaraj D [Syncfusion]
Replied On February 3, 2011 01:37 PM UTC

Hi Mike,

Thanks for your interest in Syncfusion products.

We can add text to the x-axis point of a bar chart through "ChartFormatAxisLabelEventHandler".

Refer the below code snippets.

In this code, we have formatted the x-axis point which is of type DateTime.

public ActionResult Index()
MVCChartModel chartModel = new MVCChartModel();
chartModel.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(dt, dtend, 1,ChartDateTimeIntervalType.Months);
chartModel.PrimaryYAxis.Range = new MinMaxInfo(50, 500, 100);
chartModel.PrimaryXAxis.DateTimeFormat = "MM-dd";
chartModel.PrimaryXAxis.ValueType = ChartValueType.DateTime;
DateTime dt = new DateTime(2011, 2, 3);
DateTime dtend = new DateTime(2011, 8, 3);
ChartSeries s1 = new ChartSeries();
s1.Points.Add(dt.AddMonths(0), 100);

ChartSeries s2 = new ChartSeries();
s2.Points.Add(dt.AddMonths(0), 150);

//Formatting the axis label text through ChartFormatAxisLabelEventHandler
chartModel.ChartFormatAxisLabel += new ChartFormatAxisLabelEventHandler(this.chartFormatAxisLabel);

. . . . . . .
. . . . . . .

return View();

//handling the chart format axis label event
void chartFormatAxisLabel(object sender, ChartFormatAxisLabelEventArgs e)
if (e.AxisOrientation == ChartOrientation.Horizontal)
if (e.Label == "02-03")
e.Label = "Feb";
else if (e.Label == "03-03")
e.Label = "Mar";
else if (e.Label == "04-03")
e.Label = "Apr";
else if (e.Label == "05-03")
e.Label = "May";
else if (e.Label == "06-03")
e.Label = "Jun";
else if (e.Label == "07-03")
e.Label = "Jul";

e.Handled = true;

Please let us know if you have any queries.

Krishnaraj D


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon