Example #1
1
        protected internal void drawChartPie1(WebChartControl viewer, String title)
        {
            PieChart c = new PieChart(900, 380);

            // Set the center of the pie at (300, 140) and the radius to 120 pixels
            c.setPieSize(450, 140, 160);

            c.set3D(20);

            c.addTitle(title);

            // Set label format to display sector label, value and percentage in two lines
            c.setLabelFormat("<*block,width=200*> {label}<*br*>{value|0} ({percent}%)");
            c.setLabelLayout(Chart.SideLayout);

            // Set label style to 10 pts Arial Bold Italic font. Set background color to the
            // same as the sector color, with reduced-glare glass effect and rounded corners.
            ChartDirector.TextBox t = c.setLabelStyle("Arial Bold Italic", 10);
            t.setBackground(Chart.SameAsMainColor, Chart.Transparent, Chart.glassEffect(
                Chart.ReducedGlare));
            t.setRoundedCorners();

            // Use side label layout method
            c.setLabelLayout(Chart.SideLayout);

            String[] labels = new String[viewer.Items.Length];
            double[] data = new double[viewer.Items.Length];
            // Set the pie data and the pie labels
            int i = 0;
            double sum =0;
            foreach (ChartDataLayer item in viewer.Items)
            {
                item.subDataSetSize(item.Count);
                item.subDataGetTable();
                data[i] = item.subDataAverage;
                sum+= item.subDataAverage;
                labels[i++] = item.Text;
            }

            c.setData(data, labels);

            c.addText(700, 320, "Σύνολο:" + sum, "Arial Bold Italic", 12);

            c.setTransparentColor(0xffffff);
            viewer.Image = c.makeWebImage(Chart.PNG);

            viewer.ImageMap = (c.getHTMLImageMap("#", "{label}", "title='{label}: {value|0}({percent}%)'")).Replace("href=\"#?", "href=\"#");
        }