Hi guys,
Thank you so much for the solution. It saved my life. I don't know how this was not implemented because it's a must on a lot of line charts types.
I used that solution but was not working on the version of PdfSharp that I've downloaded from that link
https://sourceforge.net/projects/pdfsharp/ provided on that official website
http://www.pdfsharp.net/Downloads.ashxOn that version, there're some differences between the solution given of this post and I had to change it. I past here my code that is currently working on that version.
/**/
// <summary>
/// Draws the content of the line plot area.
/// </summary>
internal override void Draw()
{
ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo;
XRect plotAreaRect = cri.plotAreaRendererInfo.Rect;
if (plotAreaRect.IsEmpty)
return;
XGraphics gfx = _rendererParms.Graphics;
XGraphicsState state = gfx.Save();
//gfx.SetClip(plotAreaRect, XCombineMode.Intersect);
gfx.IntersectClip(plotAreaRect);
//TODO Treat null values correctly.
// Points can be missing. Treat null values accordingly (NotPlotted, Interpolate etc.)
// Draw lines and markers for each data series.
XMatrix matrix = cri.plotAreaRendererInfo._matrix;
double xMajorTick = cri.xAxisRendererInfo.MajorTick;
foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
{
int count = sri._series.Elements.Count;
double[] values = new double[count];
double left = double.NaN;
int leftIdx = 0;
for (int idx = 0; idx < count; idx++)
{
double v = sri._series.Elements[idx].Value;
if (double.IsNaN(v))
{
switch (cri._chart._displayBlanksAs)
{
case BlankType.NotPlotted:
v = double.NaN;
break;
case BlankType.Interpolated:
double right;
int rightIdx;
right = double.NaN; rightIdx = 0;
for (int jdx = idx + 1; jdx < count; jdx++)
{
double w = sri._series.Elements[jdx].Value;
if (!double.IsNaN(w))
{
right = w;
rightIdx = jdx;
break;
}
}
if (double.IsNaN(rightIdx) || double.IsNaN(leftIdx))
v = double.NaN;
else
v = (right - left) / (rightIdx - leftIdx);
break;
case BlankType.Zero:
v = 0;
break;
default:
throw new NotImplementedException();
}
}
else
left = v;
values[idx] = v;
}
List<List<XPoint>> points;
points = new List<List<XPoint>>();
points.Add(new List<XPoint>());
for (int idx = 0; idx < count; idx++)
{
double v = sri._series.Elements[idx].Value;
if (double.IsNaN(v))
{
if (points[points.Count - 1].Count > 0)
points.Add(new List<XPoint>());
}
else
points[points.Count - 1].Add(new XPoint(idx + xMajorTick / 2, v));
}
foreach (List<XPoint> lines in points)
{
if (lines.Count > 0)
{
XPoint[] pts;
pts = lines.ToArray();
matrix.TransformPoints(pts);
if (pts.Length >= 2)
gfx.DrawLines(sri.LineFormat, pts);
DrawMarker(gfx, pts, sri);
}
}
}
//gfx.ResetClip();
gfx.Restore(state);
}
/**/
Also, big thanks to "ldelabre" to provide us a working version so I only had to change some part of the code to be able to work for me.