Ejemplo n.º 1
0
        public void AddData(ChartLegend legendMod, List <ChartSeries> seriesList, string tag)
        {
            this.legend = legendMod;//主要获取行数据
            this.series = seriesList;
            switch (tag)
            {
            case "empy":
                for (int i = 0; i < series.Count; i++)
                {
                    series[i].type      = "pie";
                    series[i].radius    = new string[] { "50%", "70%" };
                    series[i].center    = new string[] { "50%", "60%" };
                    series[i].itemStyle = new SeriesItemStyle()
                    {
                        normal = new ChartNormal()
                        {
                            label = new ChartLabel()
                            {
                                show = false
                            }, labelLine = new ChartLabelLine()
                            {
                                show = false
                            }
                        }
                        ,
                        emphasis = new Emphasis()
                        {
                            label = new ChartLabel()
                            {
                                show = true, position = "center", textStyle = new TextStyle()
                                {
                                    fontSize = "30", fontWeight = "bold"
                                }
                            }
                        }
                    };
                }
                break;

            case "inside":
                series[0].type         = "pie";
                series[0].selectedMode = "single";
                series[0].radius       = new int[] { 0, 70 };
                series[0].itemStyle    = new SeriesItemStyle()
                {
                    normal = new ChartNormal()
                    {
                        label = new ChartLabel()
                        {
                            position = "inside"
                        }, labelLine = new ChartLabelLine()
                        {
                            show = false
                        }
                    }
                };
                series[1].type   = "pie";
                series[1].radius = new int[] { 100, 140 };
                break;

            case "areanan":   //面积南丁玫瑰
            case "nanpie":    //南丁玫瑰
                this.legend.x  = "center";
                this.legend.y  = "bottom";
                series[0].type = "pie";
                if (tag.Equals("areanan"))
                {
                    series[0].radius    = new int[] { 30, 90 };
                    series[0].roseType  = "area";
                    series[0].itemStyle = null;
                }
                else
                {
                    series[0].radius    = new int[] { 20, 90 };
                    series[0].roseType  = "radius";
                    series[0].itemStyle = new SeriesItemStyle()
                    {
                        normal = new ChartNormal()
                        {
                            label = new ChartLabel()
                            {
                                show = false
                            }, labelLine = new ChartLabelLine()
                            {
                                show = false
                            }
                        }
                        ,
                        emphasis = new Emphasis()
                        {
                            label = new ChartLabel()
                            {
                                show = true
                            }, labelLine = new ChartLabelLine()
                            {
                                show = true
                            }
                        }
                    };
                }
                series[0].center = new string[] { "50%", "50%" };
                break;

            case "doublearea":    //双玫瑰
                this.legend.x = "center";
                this.legend.y = "bottom";
                series.Add(new ChartSeries());
                series[0].radius    = new int[] { 20, 90 };
                series[0].roseType  = "radius";
                series[0].itemStyle = new SeriesItemStyle()
                {
                    normal = new ChartNormal()
                    {
                        label = new ChartLabel()
                        {
                            show = false
                        }, labelLine = new ChartLabelLine()
                        {
                            show = false
                        }
                    }
                    ,
                    emphasis = new Emphasis()
                    {
                        label = new ChartLabel()
                        {
                            show = true
                        }, labelLine = new ChartLabelLine()
                        {
                            show = true
                        }
                    }
                };
                series[0].type     = "pie";
                series[0].center   = new object[] { "25%", 150 };
                series[1].radius   = new int[] { 30, 90 };
                series[1].roseType = "area";
                series[1].type     = "pie";
                series[1].center   = new object[] { "75%", 150 };
                ChartData[] seriess = (ChartData[])(series[0].data);
                ChartData[] cdata   = new ChartData[seriess.Length];
                seriess.CopyTo(cdata, 0);
                series[1].data = cdata;
                series[1].name = "面积模式";
                break;

            default:
                for (int i = 0; i < series.Count; i++)
                {
                    series[i].type   = "pie";
                    series[i].radius = "55%";
                    series[i].center = new string[] { "50%", "60%" };
                }
                break;
            }
        }
Ejemplo n.º 2
0
        public override void AddDatas(string name, string cdatas)//cdatas格式:name,value|name,value|name,value
        {
            if (!string.IsNullOrEmpty(cdatas))
            {
                DataTable     dt     = JsonHelper.JsonToDT(cdatas);
                string[]      names  = null;
                List <string> legend = new List <string>();
                foreach (DataRow item in dt.Rows)
                {
                    string itemName = item["name"].ToString();
                    switch (itemName)
                    {
                    case "legend":
                        names = JsonHelper.JsonDeserialize <string[]>(item["value"].ToString());
                        break;

                    case "series":
                        object[] objs = JsonHelper.JsonDeserialize <object[]>(item["value"].ToString());
                        for (int i = 0; i < objs.Length; i++)
                        {
                            object[]    curdatas = (object[])objs[i];
                            ChartData[] cdata    = new ChartData[curdatas.Length];
                            for (int j = 0; j < curdatas.Length; j++)
                            {
                                object[] c_curdata = (object[])curdatas[j];
                                cdata[j] = new ChartData {
                                    name = c_curdata[0].ToString(), value = Convert.ToInt32(c_curdata[1])
                                };
                                legend.Add(c_curdata[0].ToString());
                            }
                            this.series.Add(new ChartSeries()
                            {
                                name = names[i], type = "funnel", x = "15%", x2 = "15%", y2 = "10%", max = 100
                            });
                            this.series[i].itemStyle.normal.labelLine        = new ChartLabelLine();
                            this.series[i].itemStyle.normal.labelLine.show   = false;
                            this.series[i].itemStyle.emphasis.labelLine      = new ChartLabelLine();
                            this.series[i].itemStyle.emphasis.labelLine.show = false;
                            this.series[i].data = cdata;
                        }
                        break;
                    }
                }
                this.legend.data = legend.ToArray();
            }
            //string[] datas = cdatas.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            //ChartData[] cdata = new ChartData[datas.Length];
            //for (int i = 0; i < datas.Length; i++)
            //{
            //    string[] value = datas[i].Split(',');
            //    cdata[i] = new ChartData() { name = value[0], value = Convert.ToInt32(value[1]) };
            //}
            //this.series.Add(new ChartSeries()
            //{
            //    name = name,
            //    type = "funnel",
            //    x = "15%",
            //    x2 = "15%",
            //    y2 = "10%",
            //    max = 100,
            //});
            //this.series[0].itemStyle.normal.labelLine = new ChartLabelLine();
            //this.series[0].itemStyle.normal.labelLine.show = false;
            //this.series[0].itemStyle.emphasis.labelLine = new ChartLabelLine();
            //this.series[0].itemStyle.emphasis.labelLine.show = false;
            //this.series[0].data = cdata;
        }