2

It's very difficult for me to explain in English. Currently, I have created chart as the below picture.

My Chart

with this code:

public void CreateChart(DataTable chartTable ,string serieName)
{

    var chartArea = new ChartArea();
    chartArea.AxisX.LabelStyle.Format = "dd/MM/yyy";
    chartArea.AxisX.MajorGrid.LineColor = Color.LightGray;
    chartArea.AxisY.MajorGrid.LineColor = Color.LightGray;
    chartArea.AxisX.LabelStyle.Font = new Font("Consolas", 6);
    chartArea.AxisY.LabelStyle.Font = new Font("Consolas", 6);
    chart1.ChartAreas.Add(chartArea);


    var series = new Series();
    series.Name = "TEMP_STACK_BOILER_1";
    series.ChartType = SeriesChartType.FastLine;
    series.XValueType = ChartValueType.DateTime;
    series.YValueType = ChartValueType.Double;
    chart1.Series.Add(series);



    int lastrow = chartTable.Rows.Count - 4;

    string[] xval = new string[lastrow];
    int[] yval = new int[lastrow];


    // bind the datapoints

    chart1.ChartAreas[0].AxisY.Maximum = 1000;
    chart1.ChartAreas[0].AxisY.Minimum = 0;

    for (int i = 0; i < lastrow; i++)
    {
        xval[i] =  chartTable.Rows[i][1].ToString() + "\r\n" +chartTable.Rows[i][0].ToString() ;
        yval[i] = Convert.ToInt32(chartTable.Rows[i][serieName]);           
    }

   chart1.Series[serieName].Points.DataBindXY(xval, yval);
   chart1.Invalidate();
}

But I want to display Yvalue as the description in the picture I don't know what is it called. (please see the below picture )

Here is the Chart which I want:

The Chart which i want

I tried to search on google but still can't do it. I'm really sorry for my bad English .

Hope anyone can help me.

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76

1 Answers1

3

You have to switch to ChartType.Line.

There are certain restrictions for FastLine charts:

The FastLine chart type is a variation of the Line chart that significantly reduces the drawing time of a series that contains a very large number of data points. Use this chart in situations where very large data sets are used and rendering speed is critical.

Some charting features are omitted from the FastLine chart to improve performance. The features omitted include control of point level visual attributes, markers, data point labels, and shadows.

This is by design to keep the drawing fast. Other than performance and those restrictions they are the same, i.e. they will look alike..

Now you can set either

yourSeries.IsValueShownAsLabel = true;

for a whole Series or pick some values and show their values as Labels:

yourSeries.Points[someIndex].IsValueShownAsLabel = true;
TaW
  • 53,122
  • 8
  • 69
  • 111