VS2010 Chart control, how to display a blank chart?

前端 未结 1 1127
时光取名叫无心
时光取名叫无心 2020-12-22 11:03

I\'m trying to use the chart control on a windows form and have it working, plotting some real time data, however before the data arrives nothing is displayed. I would like

相关标签:
1条回答
  • 2020-12-22 11:21

    You can hide all data of a Series by making its line color Transparent. If you also set its LegendText to be " " all you can see are the Axis ticks. you can control them by adding a few Points and by setting the Minimum and Maximum values:

    // short reference for our dummy:
    Series S0 = chart1.Series[0];
    // a simple type
    S0.ChartType = SeriesChartType.Line;
    // set 10 point with x-values going from 0-100 and y-values going from 1-10:
    for (int i = 0; i < 100; i +=10)  S0.Points.AddXY(i , i / 10);
    // or add only a few, e.g. the first and last points:
    //S0.Points.AddXY(100, 10);
    //S0.Points.AddXY(0, 10);
    // hide the line:
    S0.Color = Color.Transparent;
    // hide the legend text (it will still take up a little space, though)
    S0.LegendText = " ";
    // limit the axis to the target values
    chart1.ChartAreas[0].AxisX.Maximum = 100;
    chart1.ChartAreas[0].AxisX.Minimum = 0;
    

    The result looks like an empty chart:

    emtpy chart

    0 讨论(0)
提交回复
热议问题