0

I'm using TeeChart Pocket running on .NET 3.5. The target application is running Windows CE 6.0 with .NET 3.5. I made a small forms application that draws a pie chart, but when I add an edge style I'm getting a NullReferenceException.

The minimal code (sans designer code) that produces this exception looks like this:

public class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        var series = new Pie();
        series.FillSampleValues(6);

        series.BevelPercent = 20;
        series.EdgeStyle = EdgeStyles.Curved;

        var chart = new TChart();
        chart.Series.Add(series);

        this.Controls.Add(chart);
    }
}

This exception is also thrown for the following program:

chart.Series.Add(series);
series.FillSampleValues(6);

series.BevelPercent = 20;
series.EdgeStyle = EdgeStyles.Curved;

chart.Location = new Point(0, 0);
chart.Width = this.Width;
chart.Height = this.Height;

this.Controls.Add(chart);

Why am I getting a NullReferenceException? If I uncomment the line setting the EdgeStyle, no exceptions are thrown. Here's the full stack trace:

System.NullReferenceException was unhandled
  Message="NullReferenceException"
  StackTrace:
       at System.Drawing.Graphics.FillPolygon(Brush brush, Point[] points)
       at Steema.TeeChart.Drawing.Graphics3DGdiPlus.Polygon(PointDouble[] p)
       at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DrawPoints()
       at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DoTopGradient(Int32 zDepth)
       at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DoCurvedGradient(Int32 zDepth)
       at Steema.TeeChart.Drawing.Graphics3D.Pie3D.DrawLighting(EdgeStyles edgeStyle)
       at Steema.TeeChart.Drawing.Graphics3D.Pie3D.Pie(Int32 xCenter, Int32 yCenter, Int32 xRadius, Int32 yRadius, Int32 z0, Int32 z1, Double startAngle, Double endAngle, Boolean darkSides, Boolean drawSides, Int32 donutPercent, Int32 bevelPercent, EdgeStyles edgeStyle)
       at Steema.TeeChart.Drawing.Graphics3D.Pie(Int32 xCenter, Int32 yCenter, Int32 xRadius, Int32 yRadius, Int32 z0, Int32 z1, Double startAngle, Double endAngle, Boolean darkSides, Boolean drawSides, Int32 donutPercent, Int32 bevelPercent, EdgeStyles edgeStyle)
       at Steema.TeeChart.Drawing.Graphics3D.Pie(Int32 xCenter, Int32 yCenter, Int32 xOffset, Int32 yOffset, Int32 xRadius, Int32 yRadius, Int32 z0, Int32 z1, Double startAngle, Double endAngle, Boolean darkSides, Boolean drawSides, Int32 donutPercent, Int32 bevelPercent, EdgeStyles edgeStyle)
       at Steema.TeeChart.Styles.Pie.DrawPie(Graphics3D g, Int32 valueIndex)
       at Steema.TeeChart.Styles.Pie.DrawPie(Int32 valueIndex)
       at Steema.TeeChart.Styles.Pie.DrawValue(Int32 valueIndex)
       at Steema.TeeChart.Styles.Pie.Draw()
       at Steema.TeeChart.Styles.Series.DrawSeries()
       at Steema.TeeChart.Chart.DrawAllSeries(Graphics3D g)
       at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools)
       at Steema.TeeChart.Chart.InternalDraw(Graphics g)
       at Steema.TeeChart.Pocket.TChart.Draw(Graphics g)
       at Steema.TeeChart.Pocket.TChart.OnPaint(PaintEventArgs e)
       at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
       at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
       at Microsoft.AGL.Forms.WL.Update(IntPtr hwnThis)
       at System.Windows.Forms.Control.Update()
       at System.Windows.Forms.Control.Refresh()
       at Steema.TeeChart.Pocket.TChart.OnResize(EventArgs e)
       at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
       at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
       at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
       at System.Windows.Forms.Application.Run(Form fm)
       at Demo.Form1.Main()
  InnerException: 
Mike Bailey
  • 12,479
  • 14
  • 66
  • 123

1 Answers1

2

Since there's no GradientBrush in .net compact framework, I'm afraid the Gradients aren't supported in the PocketPC version of TeeChart .NET either. This also means the EdgeStyle doesn't work either in the Compact Framework However, the Exception you've found shouldn't appear when you try to set it. I've just corrected it for the next maitenance release.

Yeray
  • 5,009
  • 1
  • 13
  • 25
  • I have encountered this bug a second time. Why is the `EdgeStyles.Curved` option so tricky? I've just discovered two configurations that throw exceptions with no useful information. The only thing they have in common is `EdgeStyles.Curved`. – Mike Bailey Aug 31 '12 at 13:28
  • Sorry, after looking deeper into the sources I found we are returning a null on pocket devices that is producing the error. I wasn't getting the exception probably because the legend was so big that the pie had no space to be drawn. I'm still investigating it and I guess we'll be able to skip this exception in next releases but I think the PocketPC version doesn't support gradients so it won't probably support this feature either. – Yeray Sep 03 '12 at 12:13
  • Corrected. I'll edit my reply since the original wasn't actually correct. – Yeray Sep 03 '12 at 15:38
  • Thanks for the information. So this would rule out the possibility of having lighting on the CF version of TeeChart? – Mike Bailey Sep 04 '12 at 01:11
  • I'm afraid yes. Without supporting gradients, the lighting can't be supported. – Yeray Sep 04 '12 at 07:29
  • Are there any plans to support gradients in the future? – Mike Bailey Sep 04 '12 at 14:44
  • As far as we know, there is no GradientBrush in .Net Compact Framework. And we don't have plans to implement our own gradient. – Yeray Sep 05 '12 at 07:17