Frage

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: 
War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top