C# 快速折线图

标签 c# charts

我很难用英语解释。 目前,我已经创建了如下图所示的图表。

My Chart

使用此代码:

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值显示为图片中的描述 我不知道它叫什么。 (请看下图)

这是我想要的图表:

The Chart which i want

我尝试在谷歌上搜索,但仍然无法搜索到。 我真的很抱歉我的英语不好。

希望有人能帮助我。

最佳答案

您必须切换到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/

相关文章:

javascript - AmCharts 股票图表 : remove Compare to selection box

javascript - 如果 OHLC 中的开盘价和收盘价相同,我可以在烛台上使用不同的颜色吗?

java - StackedBarchart 中不同行键的自定义颜色

javascript - Highcharts 主从图表的问题

c# - 如何修改 ListView 栏?

c# - 如何使用c#从后面的代码中查找SQL Server实例名称和服务器名称?

c# - 如果删除 *.exe.config 会发生什么?

c# - 类中的类,实例化为单个对象

c# - 访问 token 不包含通过 Microsoft Graph 的 SCP(角色)声明

javascript - d3.js同心环图