예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Title title = new Option.Title();

            title.Text    = "某站点用户访问来源";
            title.Subtext = "纯属虚构";
            title.X       = Enums.XAlign.Center;
            EChartsCtrl1.chart.SetTitle(title);

            ToolTip tt = new ToolTip();

            tt.Trigger = Enums.TriggerType.Item;
            StringFormatter sf = new StringFormatter();

            sf.Formatter = "{a} <br/>{b} : {c} ({d}%)";
            tt.Formatter = sf;
            EChartsCtrl1.chart.SetToolTip(tt);

            Legend legend = new Legend();

            legend.Orient = Enums.OrientType.Vertical;
            legend.X      = Enums.XAlign.Left;
            legend.Data   = new string[] { "直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎" };
            EChartsCtrl1.chart.SetLegend(legend);

            ToolBox tb = new ToolBox();

            tb.Show                   = true;
            tb.Feature                = new Option.ToolBoxButton.Feature();
            tb.Feature.Mark           = new Option.ToolBoxButton.Mark();
            tb.Feature.Mark.Show      = true;
            tb.Feature.MagicType      = new Option.ToolBoxButton.MagicType();
            tb.Feature.MagicType.Show = true;
            tb.Feature.MagicType.Type = new string[] { Enums.EChartsTypes.Pie.ToString().ToLower(),
                                                           Enums.EChartsTypes.Funnel.ToString().ToLower() };
            tb.Feature.MagicType.Option                    = new Option.ToolBoxButton.Option();
            tb.Feature.MagicType.Option.Funnel             = new Option.ToolBoxButton.Funnel();
            tb.Feature.MagicType.Option.Funnel.FunnelAlign = Enums.XAlign.Left;
            tb.Feature.MagicType.Option.Funnel.X           = "25%";
            tb.Feature.MagicType.Option.Funnel.Width       = "50%";
            tb.Feature.MagicType.Option.Funnel.Max         = 1548;

            tb.Feature.Restore          = new Option.ToolBoxButton.Restore();
            tb.Feature.Restore.Show     = true;
            tb.Feature.SaveAsImage      = new Option.ToolBoxButton.SaveAsImage();
            tb.Feature.SaveAsImage.Show = true;
            EChartsCtrl1.chart.SetToolBox(tb);

            EChartsCtrl1.chart.Calculable = true;

            List <Series> list = new List <Series>();
            Series        s    = new Series();

            s.Name   = "访问来源";
            s.Type   = Enums.EChartsTypes.Pie;
            s.Radius = new string[] { "55%" };
            s.Center = new string[] { "50%", "60%" };
            s.Data   = new PieDataItem[] {
                new PieDataItem()
                {
                    Name = "直接访问", Value = 335
                },
                new PieDataItem()
                {
                    Name = "邮件营销", Value = 311
                },
                new PieDataItem()
                {
                    Name = "联盟广告", Value = 234
                },
                new PieDataItem()
                {
                    Name = "视频广告", Value = 135
                },
                new PieDataItem()
                {
                    Name = "搜索引擎", Value = 1548
                },
            };
            list.Add(s);

            EChartsCtrl1.chart.SetSeries(list.ToArray());
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Title title = new Option.Title();

            title.Text    = "某地区蒸发量和降水量";
            title.Subtext = "纯属虚构";
            EChartsCtrl1.chart.SetTitle(title);

            ToolTip tt = new ToolTip();

            tt.Trigger = Enums.TriggerType.Axis;
            EChartsCtrl1.chart.SetToolTip(tt);

            Legend legend = new Legend();

            legend.Data = new string[] { "蒸发量", "降雨量" };
            EChartsCtrl1.chart.SetLegend(legend);

            ToolBox tb = new ToolBox();

            tb.Show                   = true;
            tb.Feature                = new Option.ToolBoxButton.Feature();
            tb.Feature.Mark           = new Option.ToolBoxButton.Mark();
            tb.Feature.Mark.Show      = true;
            tb.Feature.MagicType      = new Option.ToolBoxButton.MagicType();
            tb.Feature.MagicType.Show = true;
            tb.Feature.MagicType.Type = new string[] { Enums.EChartsTypes.Line.ToString().ToLower(),
                                                           Enums.EChartsTypes.Bar.ToString().ToLower() };
            tb.Feature.Restore          = new Option.ToolBoxButton.Restore();
            tb.Feature.Restore.Show     = true;
            tb.Feature.SaveAsImage      = new Option.ToolBoxButton.SaveAsImage();
            tb.Feature.SaveAsImage.Show = true;
            EChartsCtrl1.chart.SetToolBox(tb);

            EChartsCtrl1.chart.Calculable = true;

            XAxis[] x = new XAxis[1];
            x[0]      = new XAxis();
            x[0].Type = Enums.AxisType.Category;
            x[0].Data = new string[] {
                "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
            };

            EChartsCtrl1.chart.SetXAxis(x);

            YAxis[] y = new YAxis[1];
            y[0]      = new YAxis();
            y[0].Type = Enums.AxisType.Value;
            EChartsCtrl1.chart.SetYAxis(y);

            Series zf = new Series();

            zf.Name           = "蒸发量";
            zf.Type           = Enums.EChartsTypes.Bar;
            zf.Data           = new double[] { 2.0, 4.9, 7.0, 23.2, 76.7, 135.6, 162.5, 32.3, 20.0, 6.4, 5.3, 3.0 };
            zf.MarkPoint      = new MarkPoint();
            zf.MarkPoint.Data = new MarkPointDataItem[] {
                new MarkPointDataItem()
                {
                    Type = "max", Name = "最大值"
                },
                new MarkPointDataItem()
                {
                    Type = "min", Name = "最小值"
                }
            };
            zf.MarkLine = new MarkLine();
            MarkPointDataItem[] lineArr =
            {
                new MarkPointDataItem()
                {
                    Type = "average", Name = "平均值"
                }
            };
            zf.MarkLine.Data = lineArr;

            Series jy = new Series();

            jy.Name           = "降雨量";
            jy.Type           = Enums.EChartsTypes.Bar;
            jy.Data           = new double[] { 2.5, 5.9, 9.0, 25.2, 86.7, 125.6, 152.5, 62.3, 30.0, 16.4, 13.3, 6.6 };
            jy.MarkPoint      = new MarkPoint();
            jy.MarkPoint.Data = new MarkPointDataItem[] {
                new MarkPointDataItem()
                {
                    Name = "年最高", Type = "max"
                },
                new MarkPointDataItem()
                {
                    Name = "年最低", Type = "min"
                }
            };
            jy.MarkLine = new MarkLine();
            MarkPointDataItem[] lineArr2 =
            {
                new MarkPointDataItem()
                {
                    Type = "average", Name = "平均值"
                }
            };
            jy.MarkLine.Data = lineArr2;

            List <Series> ls = new List <Series>();

            ls.Add(zf);
            ls.Add(jy);

            EChartsCtrl1.chart.SetSeries(ls.ToArray());
        }