简体   繁体   English

Chart Winform C#的问题

[英]Issue with Chart Winform c#

I am drawing a line chart but the issue is it is not making data points as described in chart properties it just breaks line (a small white space) and move ahead to draw the remaining line .Chart and code attached. 我正在绘制折线图,​​但问题是它没有按图表属性中的描述制作数据点,只是折线(一个小的空白)并继续绘制其余的线图和代码。

折线图

Here is the code: 这是代码:

            var series = new System.Windows.Forms.DataVisualization.Charting.Series();
            series.ChartType = SeriesChartType.Line;
            series.Points.DataBind(dv1, "DateCreated", "Visibility", "");
            chart1.Series[0].MarkerStyle = MarkerStyle.Diamond;
            chart1.Series[0].MarkerSize = 100;
            chart1.Series[0].IsValueShownAsLabel = true;
            chart1.Series[0].MarkerColor = Color.Red;
            chart1.Series.Add(series);
            chart1.SaveImage(pdfFile, ChartImageFormat.Png);

What am i missing here ? 我在这里想念什么?

UPDATE: 更新:

Dv1 is basically : Dv1基本上是:

Visibility       DateCreated
  10              2017-10-21
  20              2017-10-22
  30              2017-10-23
  45              2017-10-24
  90              2017-10-25

I am trying to make graph as below : 我正在尝试制作如下图:

在此处输入图片说明

Thank you 谢谢

Per my comment, your code is referencing the wrong "series" in the chart control. 根据我的评论,您的代码在图表控件中引用了错误的“系列”。 Instead of this: 代替这个:

chart1.Series[0].MarkerStyle = MarkerStyle.Diamond;

it should reference the series variable you created: 它应该引用您创建的系列变量:

series.MarkerStyle = MarkerStyle.Diamond;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM