1

I am using Chart control from .NET framework in my project. I have added chart control to the form and configured as shown below.

// Add a new series.
chart1.Series.Add("1");
var series = chart1.Series[0];
series.ChartType = SeriesChartType.Spline;
// Hide the legend.
series.IsVisibleInLegend = false;

// configure x axis.
var cArea = chart1.ChartAreas[0];
cArea.AxisX.IntervalType = DateTimeIntervalType.Number;

cArea.AxisX.LabelStyle.Format = "00";
cArea.AxisY.LabelStyle.Format = "0.000";
cArea.AxisY.LabelStyle.IsEndLabelVisible = true;

cArea.AxisX.Minimum = 0;
cArea.AxisX.Maximum = 100;
cArea.AxisX.Interval = 20;

cArea.AxisY.Minimum = 0;
cArea.AxisY.Maximum = 100;
cArea.AxisX.Interval = 20;

Data point values are as below:

chart1.Series[0].Points.AddXY(0, 5);
chart1.Series[0].Points.AddXY(5, 10);
chart1.Series[0].Points.AddXY(10, 30);
chart1.Series[0].Points.AddXY(20, 100);
chart1.Series[0].Points.AddXY(30, 100);
chart1.Series[0].Points.AddXY(40, 90);
chart1.Series[0].Points.AddXY(50, 80);

For the above data points, series is not smooth. Upper edge is getting cut. Refer attached image. enter image description here

How to make it smooth so that whole line is visible ?

TaW
  • 53,122
  • 8
  • 69
  • 111
Rocky
  • 405
  • 7
  • 17

2 Answers2

3

It's not visible because of the smoothing, adapt the scale (using cArea.AxisX.Maximum = 150; for example) or remove the smoothing to make the whole curve visible.

Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
2

As with the DrawCurves GDI+ method you can control the tension of the splines, i.e. how close they are to the points and their connecting lines and how much smoothing they create. Too much 'smoothing' creates the fantasy tops you see and also crazy whirls from even small bumps in the data..

Setting the tension it is done via the LineTension Custom attribute.

Lower it from the default of 0.8 to something smaller. Test to see what you prefer.

Here is an example for a Series S :

S.SetCustomProperty("LineTension", "0.4");

Note that you still should make the y-axis Maximum a little larger or else you may need to bring the tension down to 0, which will look like a line type..

Here are a few variations:

enter image description here

TaW
  • 53,122
  • 8
  • 69
  • 111
  • I am not aware of LineTension property. Thanks for that. Actually increasing the maximum value of y-axis will be a better solution for my case. – Rocky Jun 30 '16 at 05:43