Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
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());
        }