Friday, July 5, 2013

Create 3D Pie Chart in Winforms

This post shows how to create 3D Pie Chart in Winforms using ChartDirector (http://www.advsofteng.com/),

        private void CreatePieChart(WinChartViewer viewer, string title, double[] data, string[] data_labels)
        {
            int width = viewer.Width;
            int height = viewer.Height;

            PieChart c = new PieChart(width, height);


            c.setPieSize(width / 2, height / 2, System.Math.Max(System.Math.Min(width / 2 - 40, height / 2 - 40), 100));


            c.addTitle(title);

            c.set3D();

            c.setSectorStyle(Chart.RoundedEdgeShading, 0xffffff, 1);


            // Set the pie data and the pie labels

            c.setData(data, data_labels);
            // Output the chart
            viewer.Chart = c;
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                "title='{label}: {value} ({percent}%)'");
        }

No comments:

Post a Comment