简体   繁体   中英

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 :

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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