locked
Title RRS feed

  • Question

  • I need a title exactly in between each range on the chart. For example along the y axis there are points 0-20, 20-40, 40-60, 60-80, 80-100. I need a title inbetween 0-20, 20-40 that represents these ranges respectively. Another example would be say we are measuring someones nicotine depence where 0-20 represented a very low depence. Could I place a title exactly within this range. Is this possible. Thanks !!!

    Thursday, May 16, 2013 9:16 PM

Answers

  • Yes you can, just use the custon label options,

    chart1.ChartAreas[0].AxisY.CustomLabels.Add(20, 40, "Range 2", 1, LabelMarkStyle.LineSideMark);

    The above line will add a title just below the x axis centers on 20 and 40, see this recent post, http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/6ac5902f-386b-4e6b-ad4b-cd32c31186ae for an example on the x axis


    George
    http://www.sharpstatistics.co.uk

    Friday, May 17, 2013 9:12 AM

All replies

  • Yes you can, just use the custon label options,

    chart1.ChartAreas[0].AxisY.CustomLabels.Add(20, 40, "Range 2", 1, LabelMarkStyle.LineSideMark);

    The above line will add a title just below the x axis centers on 20 and 40, see this recent post, http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/6ac5902f-386b-4e6b-ad4b-cd32c31186ae for an example on the x axis


    George
    http://www.sharpstatistics.co.uk

    Friday, May 17, 2013 9:12 AM
  • This code does not seem to work for me. I am using a bar chart. Thanks !!!
    Friday, June 7, 2013 4:01 PM
  • It should work with a bar chart, just remember that the x and y axis are the other way round.

    //Create a new chartarea
                ChartArea myArea = new ChartArea("ChartArea1");
                chart1.ChartAreas.Add(myArea);
                Series test1 = new Series("Test1");
                test1.ChartType = SeriesChartType.Bar;
                double[] d1 = new double[] {10, 20, 30, 40, 50, 60, 70, 80, 90,100 };
                double[] d2 = new double[] {3,5,2,0,5,7,3,4,1,3 };
                test1.Points.DataBindXY(d1,d2);
                chart1.Series.Add(test1);
                test1.ChartArea = "ChartArea1";
                //lables for the groups x and y axis the other way round on a bar chart
                chart1.ChartAreas[0].AxisX.CustomLabels.Add(0, 40, "Range 1", 1, LabelMarkStyle.LineSideMark);
                chart1.ChartAreas[0].AxisX.CustomLabels.Add(40, 60, "Range 2", 1, LabelMarkStyle.LineSideMark);
                chart1.ChartAreas[0].AxisX.CustomLabels.Add(60, 100, "Range 2", 1, LabelMarkStyle.LineSideMark);
                chart1.ChartAreas[0].AxisY.CustomLabels.Add(0, 2, "Range A", 1, LabelMarkStyle.LineSideMark);
                chart1.ChartAreas[0].AxisY.CustomLabels.Add(2, 5, "Range B", 1, LabelMarkStyle.LineSideMark);
                chart1.ChartAreas[0].AxisY.CustomLabels.Add(6, 8, "Range C", 1, LabelMarkStyle.LineSideMark);


    George
    http://www.sharpstatistics.co.uk

    Saturday, June 8, 2013 3:49 PM