confusedMind
confusedMind

Reputation: 2643

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.

Line Chart

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 :

enter image description here

Thank you

Upvotes: 1

Views: 169

Answers (1)

LarsTech
LarsTech

Reputation: 81610

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;

Upvotes: 2

Related Questions