Ejemplo n.º 1
0
        private Chart BindChartData(RawChartData data)
        {
            Chart chart = new Chart();
            chart.Width = CHART_WIDTH;
            chart.Height = CHART_HEIGHT;
            chart.Attributes.Add("align", "left");

            chart.Titles.Add(data.Title); // Display a Title  
            chart.ChartAreas.Add(new ChartArea());

            chart.Legends.Add(new Legend("Legend"));
            chart.Legends[0].TableStyle = LegendTableStyle.Auto;
            chart.Legends[0].Docking = Docking.Bottom;

            chart.Series.Add(new Series());
            chart.Series[0].Legend = chart.Legends[0].Name;
            chart.Series[0].ChartType = data.ChartType; // SeriesChartType.Pie, SeriesChartType.Bar
            chart.Series[0].BackGradientStyle = GradientStyle.DiagonalLeft;
            chart.Series[0].BackSecondaryColor = System.Drawing.Color.LightGray;

            switch (data.ChartType)
            {
                case SeriesChartType.Pie:
                    {
                        chart.Series[0]["PieLabelStyle"] = "Inside";
                        chart.Series[0]["PieLabelStyle"] = "Disabled";
                        chart.Series[0]["PieLineColor"] = "Black";
                        chart.Series[0]["PieDrawingStyle"] = "Concave";
                        break;
                    }
            }

            for (int i = 0; i < data.xValues.Length; i++)
            {
                string x = data.xValues[i];
                decimal y = data.yValues[i];
                int ptIdx = chart.Series[0].Points.AddXY(x, y);

                /*
                var c = data.Data[i];
                int dbaId = data.Data[i].ContactID;
                DataPoint pt = chart.Series[0].Points[ptIdx];
                pt.Url = "/Instance/Index/" + dbaId.ToString();
                pt.ToolTip = c.FirstName + " " + c.LastName + ": #VALY";
                pt.LegendText = "#VALX: #VALY";
                pt.LegendUrl = "/Contact/Details/" + dbaId.ToString();
                pt.LegendToolTip = "Click to view " + c.FirstName + "'s contact information...";
                */

                string pointId = data.Data[i];
                DataPoint pt = chart.Series[0].Points[ptIdx];
                pt.Url = data.pointUrl + pointId;
                pt.ToolTip = "Drilldown";
                pt.LegendText = "#VALX: #VALY";
                pt.LegendUrl = data.legendUrl + pointId;
                pt.LegendToolTip = "Click to view " + pointId + "'information...";
            }

            return chart;
        }
Ejemplo n.º 2
0
        private Chart BuildChart6()
        {
            var data = new RawChartData
            {
                ChartType = SeriesChartType.Area,
                Title = "Area",
                Data = new string[] { "A", "B", "C", "D" },
                xValues = new string[] { "A", "B", "C", "D" },
                yValues = new decimal[] { 1, 2, 3, 4 }
            };

            return BindChartData(data);
        }