public JsonResult EChartPie()
        {
            List <EChart> charts = new List <EChart>();

            httpClient.DefaultRequestHeaders.Add("Authorization", HttpContext.Session.GetString("Token"));
            var responseTask = httpClient.GetAsync("Products");

            responseTask.Wait();
            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsAsync <IEnumerable <Product> >();
                readTask.Wait();
                var list = readTask.Result;
                foreach (var report in list)
                {
                    EChart chart = new EChart();
                    chart.Name  = report.Name;
                    chart.Value = report.Stock;
                    charts.Add(chart);
                }
            }
            return(Json(new { data = charts, legend = charts.Select(c => c.Name).ToArray() }));
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            KLineList list  = InitData();
            EChart    chart = EChartsCtrl1.chart;

            Title title = new Title();

            title.Text            = "2013年上半年上证指数";
            title.TextStyle       = new TextStyle();
            title.TextStyle.Color = Color.Aqua;
            chart.SetTitle(title);

            ToolTip tt = new ToolTip();

            tt.Trigger = TriggerType.Axis;
            StringBuilder sbf = new StringBuilder();

            sbf.Append("function (params) {");
            sbf.Append(" var res = params[0].seriesName + ' ' + params[0].name;");
            sbf.Append(" res += '<br/>  开盘 : ' + params[0].value[0] + '  最高 : ' + params[0].value[3];");
            sbf.Append(" res += '<br/>  收盘 : ' + params[0].value[1] + '  最低 : ' + params[0].value[2];");
            sbf.Append(" return res;");
            sbf.Append(" }");

            StringFormatter jsf = new StringFormatter();

            jsf.Formatter  = sbf.ToString();
            jsf.isFunction = true;
            tt.Formatter   = jsf;
////////            tt.Formatter = @"function (params) {
////////                var res = params[0].seriesName + ' ' + params[0].name;
////////                res += '<br/>  开盘 : ' + params[0].value[0] + '  最高 : ' + params[0].value[3];
////////                res += '<br/>  收盘 : ' + params[0].value[1] + '  最低 : ' + params[0].value[2];
////////                return res;
////////            }";
            chart.SetToolTip(tt);

            Legend leg = new Legend();

            leg.Data = new string[] { "上证指数" };
            chart.SetLegend(leg);

            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.DataZoom         = new Option.ToolBoxButton.DataZoom();
            tb.Feature.DataZoom.Show    = true;
            tb.Feature.MagicType        = new Option.ToolBoxButton.MagicType();
            tb.Feature.MagicType.Show   = true;
            tb.Feature.MagicType.Type   = new string[] { "line", "bar" };
            tb.Feature.Restore          = new Option.ToolBoxButton.Restore();
            tb.Feature.Restore.Show     = true;
            tb.Feature.SaveAsImage      = new Option.ToolBoxButton.SaveAsImage();
            tb.Feature.SaveAsImage.Show = true;
            chart.SetToolBox(tb);

            XAxis xAxis = new XAxis();

            xAxis.Type           = AxisType.Category;
            xAxis.BoundaryGap    = new BoundaryGapType("true");
            xAxis.axisTick       = new AxisTick();
            xAxis.axisTick.OnGap = false;
            xAxis.splitLine      = new SplitLine();
            xAxis.splitLine.Show = false;
            xAxis.Data           = list.ToAxisData();
            chart.SetXAxis(xAxis.ToArray());

            YAxis yAxis = new YAxis();

            yAxis.Type        = AxisType.Value;
            yAxis.Scale       = true;
            yAxis.BoundaryGap = new BoundaryGapType("[0.01,0.01]");;

            chart.SetYAxis(yAxis.ToArray());

            Series series = new Series();

            series.Name = "上证指数";
            series.Type = EChartsTypes.K;
            series.Data = list.ToSeriesData();

            chart.SetSeries(series.ToArray());
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            EChart chart = EChartsCtrl1.chart;
            Title  title = new Title();

            title.Text    = "未来一周气温变化";
            title.Subtext = "纯属虚构";
            chart.SetTitle(title);

            ToolTip tt = new ToolTip();

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

            Legend leg = new Legend();

            leg.Data = new string[] { "最高气温", "最低气温" };
            chart.SetLegend(leg);

            ToolBox tb = new ToolBox();

            tb.Show = true;
            tb.Feature.Mark.Show        = true;
            tb.Feature.Restore.Show     = true;
            tb.Feature.SaveAsImage.Show = true;
            tb.Feature.MagicType.Show   = true;
            tb.Feature.MagicType.Type   = new string[] { "line", "bar" };
            chart.SetToolBox(tb);

            chart.Calculable = true;

            XAxis xa = new XAxis();

            xa.Type        = AxisType.Category;
            xa.BoundaryGap = new Helpers.BoundaryGapType("false");
            xa.Data        = new string[] { "周一", "周二", "周三", "周四", "周五", "周六", "周日" };
            chart.SetXAxis(xa.ToArray());

            YAxis ya = new YAxis();

            ya.Type                = AxisType.Value;
            ya.AxisLabel           = new Option.Label();
            ya.AxisLabel.Formatter = "{value}°C";
            chart.SetYAxis(ya.ToArray());

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

            Series s1 = new Series();

            s1.Name           = "最高气温";
            s1.Type           = EChartsTypes.Line;
            s1.Data           = new int[] { 11, 11, 15, 13, 12, 13, 10 };
            s1.MarkPoint      = new MarkPoint();
            s1.MarkPoint.Data = new MarkPointDataItem[] {
                new MarkPointDataItem()
                {
                    Type = "max", Name = "最大值"
                },
                new MarkPointDataItem()
                {
                    Type = "min", Name = "最小值"
                }
            };
            s1.MarkLine      = new MarkLine();
            s1.MarkLine.Data = new MarkPointDataItem[] {
                new MarkPointDataItem()
                {
                    Type = "average", Name = "平均值"
                }
            };
            list.Add(s1);
            Series s2 = new Series();

            s2.Name           = "最低气温";
            s2.Type           = EChartsTypes.Line;
            s2.Data           = new int[] { 1, -2, 2, 5, 3, 2, 0 };
            s2.MarkPoint      = new MarkPoint();
            s2.MarkPoint.Data = new MarkPointDataItem[] {
                new MarkPointDataItem()
                {
                    Name = "周最低", Value = -2, X = 1, Y = -1.5
                }
            };
            s2.MarkLine      = new MarkLine();
            s2.MarkLine.Data = new MarkPointDataItem[] {
                new MarkPointDataItem()
                {
                    Type = "average", Name = "平均温度"
                }
            };

            list.Add(s2);

            chart.SetSeries(list.ToArray());
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            EChart chart = EChartsCtrl1.chart;

            chart.IsExtendMap = true;
            chart.SVGPath     = "svg/jinzhongBuilding.svg";
            Title title = new Title();

            title.Text            = "测试用";
            title.TextStyle       = new TextStyle();
            title.TextStyle.Color = Color.Aqua;

            chart.SetTitle(title);

            Legend legend = new Legend();

            legend.BackgroundColor = Color.AntiqueWhite;
            legend.Data            = new string[] { "group1" };

            chart.SetLegend(legend);

            chart.SetColor(new Color[] { Color.Blue });

            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.Restore      = new Option.ToolBoxButton.Restore();
            tb.Feature.Restore.Show = true;

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

            wwb.ECharts.Option.ToolTip tt = new wwb.ECharts.Option.ToolTip();
            tt.Trigger   = TriggerType.Item;
            tt.Formatter = new StringFormatter("{b}");
            chart.SetToolTip(tt);



            Series s1 = new Series();

            s1.Data                          = new string[0];
            s1.Name                          = "group1";
            s1.ItemStyle                     = new ItemStyle();
            s1.ItemStyle.Normal              = new Normal();
            s1.ItemStyle.Normal.Color        = Color.Gold;
            s1.ItemStyle.Normal.Label        = new wwb.ECharts.Option.Label();
            s1.ItemStyle.Normal.Label.Show   = true;
            s1.ItemStyle.Emphasis            = new Emphasis();
            s1.ItemStyle.Emphasis.Label      = new wwb.ECharts.Option.Label();
            s1.ItemStyle.Emphasis.Label.Show = true;
            s1.Type                          = EChartsTypes.Map;
            s1.Roam                          = true;
            s1.MarkPoint                     = new MarkPoint();
            s1.MarkPoint.Symbol              = SymbolType.Circle;
            s1.MarkPoint.SymbolSize          = 3;

            List <MarkPointDataItem> list = new List <MarkPointDataItem>();

            list.Add(new MarkPointDataItem("张三", 44, 71));
            list.Add(new MarkPointDataItem("李四", 84, 71));

            s1.MarkPoint.Data = list.ToArray();

            s1.MarkLine                                 = new MarkLine();
            s1.MarkLine.Effect                          = new Effect();
            s1.MarkLine.Effect.Show                     = true;
            s1.MarkLine.Effect.Loop                     = true;
            s1.MarkLine.Effect.Color                    = Color.HotPink;
            s1.MarkLine.Symbol                          = new SymbolType[] { SymbolType.Circle, SymbolType.Arrow };
            s1.MarkLine.ItemStyle                       = new ItemStyle();
            s1.MarkLine.ItemStyle.Normal                = new Normal();
            s1.MarkLine.ItemStyle.Normal.BorderWidth    = 1;
            s1.MarkLine.ItemStyle.Normal.LineStyle      = new LineStyle();
            s1.MarkLine.ItemStyle.Normal.LineStyle.Type = LineStyleType.Solid;

            //List<MarkLineDataItem> lineList = new List<MarkLineDataItem>();
            //lineList.Add(new MarkLineDataItem(new MarkPointDataItem("A", 88, 222), new MarkPointDataItem("B", 44, 232)));
            //s1.MarkLine.Data = lineList.ToArray();
            MarkPointDataItem[,] lineArr =
            {
                { new MarkPointDataItem("A",  88, 222), new MarkPointDataItem("B",  44, 232) },
                { new MarkPointDataItem("C", 123, 222), new MarkPointDataItem("D", 123, 282) }
            };
            s1.MarkLine.Data = lineArr;


            Series s2 = new Series();

            s2.Data                       = new string[0];
            s2.Type                       = EChartsTypes.Map;
            s2.MarkPoint                  = new MarkPoint();
            s2.MarkPoint.Effect           = new Effect();
            s2.MarkPoint.Effect.Show      = true;
            s2.MarkPoint.Effect.ScaleSize = 8;
            s2.MarkPoint.Effect.Color     = Color.DeepSkyBlue;
            s2.MarkPoint.Data             = (new List <MarkPointDataItem>()
            {
                new MarkPointDataItem("MMM", 33, 99), new MarkPointDataItem("aaaaaaaa", 66, 123)
            }).ToArray();
            s2.MarkPoint.Symbol           = SymbolType.EmptyDiamond;
            List <Series> slist = new List <Series>();

            slist.Add(s1);
            slist.Add(s2);
            chart.SetSeries(slist.ToArray());
        }