Useful Chart Code

+2 Chris Blum · September 26, 2014

Hi guys,
Just wanted to put up some reference text in case anyone is toying with charts.

//Set up chart size
//These can also be used with AxisY
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisX.Maximum = 30;
chart1.ChartAreas[0].AxisX.Interval = 1;

//Naming your charts and legend
chart1.Titles.Add("Title of Chart");
chart1.Series[0].LegendText = "Name of series that appears in the legend";//Remember that this is accessed by the series element, not series name

//Adding a new series
Series S1 = new Series();
chart1.Series.Add(S1); //Remember to add the series to your chart!

//Changing the type of graph (bar, pie, line, etc)
S1.ChartType = SeriesChartType.Line;

//Change the color of a series
chart1.Series[0].Color = Color.Green;

//Removing the grid of a chart (looks cleaner)
chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;//Can be used on X or Y Axis

//Make your series larger (stands out more and looks better)
chart1.Series[0].BorderWidth = 3;

//Adding points to a series

Post a Reply


Oldest  Newest  Rating
+1 Chris Blum · September 26, 2014
I wouldn't even know where to start without this library. I've been having some fun with it so far, when I actually get a chance to work on it.

How long have you been programming Eugene? You seem very knowledgable
+1 Eugene Botma · September 26, 2014
Wish i had known about this chart library before. about a year ago i wrote a betting bot that could draw profit charts for the person using it. I wrote my own charting library from scratch for that. while it worked great, this one works so much better and would have saved me hours of work.
  • 1



C# is an object-oriented language designed for improving the development of web applications.