|
PDFsharp - moved to http://forum.pdfsharp.net/ Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
|
Important Notice:
We regret to inform you that our free phpBB forum hosting service will be discontinued by the end of June 30, 2024.
If you wish to migrate to our paid hosting service, please contact billing@hostonnet.com.
View previous topic :: View next topic |
Author |
Message |
ldelabre
Joined: 12 Apr 2008 Posts: 10
|
Posted: Sun Apr 13, 2008 12:32 pm Post subject: DisplayBlanksAs not implemented |
|
|
Hello!
I'm using charts with series containing possible "blank" values. At first, I was happy to discover a DisplayBlanksAs property...
Then I realize that this property is not yet implemented....(quick search throught the source code) ;-(
Is anyone working on this already ?
Thanks
Ludovic. |
|
Back to top |
|
|
ldelabre
Joined: 12 Apr 2008 Posts: 10
|
Posted: Thu Apr 17, 2008 5:44 pm Post subject: |
|
|
Since I received no answers, I assumed noboby's working on it..
So here's a first try - I know it's kindda ugly... (sorry ! :oups:) And I've not tested all modes yet ... Just wanted to shared this
Code: |
/// <summary>
/// Draws the content of the line plot area.
/// </summary>
internal override void Draw()
{
ChartRendererInfo cri = (ChartRendererInfo)this.rendererParms.RendererInfo;
XRect plotAreaRect = cri.plotAreaRendererInfo.Rect;
if (plotAreaRect.IsEmpty)
return;
XGraphics gfx = this.rendererParms.Graphics;
XGraphicsState state = gfx.Save();
gfx.SetClip(plotAreaRect, XCombineMode.Intersect);
//TODO null-Values müssen berücksichtigt werden.
// Verbindungspunkte können fehlen, je nachdem wie null-Values behandelt werden sollen.
// (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);
}
|
|
|
Back to top |
|
|
ldelabre
Joined: 12 Apr 2008 Posts: 10
|
Posted: Sun Jun 15, 2008 1:59 pm Post subject: |
|
|
Oups... bug
I do correct myself
Code: |
if (pts.Length > 2)
|
should be
Code: |
if (pts.Length >= 2)
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|