我很难用英语解释。 目前,我已经创建了如下图所示的图表。
使用此代码:
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();
}
但是我想将Y值显示为图片中的描述 我不知道它叫什么。 (请看下图)
这是我想要的图表:
我尝试在谷歌上搜索,但仍然无法搜索到。 我真的很抱歉我的英语不好。
希望有人能帮助我。
最佳答案
您必须切换到ChartType.Line
。
有一些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.
这是为了保持绘图速度而设计的。除了性能和这些限制之外,它们是相同的,即它们看起来很相似。
现在您可以设置其中一个
yourSeries.IsValueShownAsLabel = true;
对于整个系列
或选择一些值并将其值显示为标签
:
yourSeries.Points[someIndex].IsValueShownAsLabel = true;
关于C# 快速折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41929926/