PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DisplayBlanksAs not implemented

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
ldelabre



Joined: 12 Apr 2008
Posts: 10

PostPosted: Sun Apr 13, 2008 12:32 pm    Post subject: DisplayBlanksAs not implemented Reply with quote

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
View user's profile Send private message
ldelabre



Joined: 12 Apr 2008
Posts: 10

PostPosted: Thu Apr 17, 2008 5:44 pm    Post subject: Reply with quote

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 Wink

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
View user's profile Send private message
ldelabre



Joined: 12 Apr 2008
Posts: 10

PostPosted: Sun Jun 15, 2008 1:59 pm    Post subject: Reply with quote

Oups... bug Embarassed

I do correct myself Very Happy

Code:

              if (pts.Length > 2)


should be

Code:

              if (pts.Length >= 2)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com