private void DataBind()
 {
     //设置数据
     this.pieChart1.SeriesMember = "S";
     this.pieChart1.XValueMember = "X";
     this.pieChart1.YValueMember = "Y";
     dt = DemoGlobal.GetChartDemoTable();
     this.pieChart1.DataSource = dt;
     this.pieChart1.DataBind();
 }
Beispiel #2
0
 private void DataBind()
 {
     //设置数据
     this.barChart1.SeriesMember        = "S";
     this.barChart1.XValueMember        = "X";
     this.barChart1.YValueMember        = "Y";
     this.barChart1.XAxis.AxisLineColor = DemoGlobal.GetRandomColor();
     this.barChart1.XAxis.GridColor     = DemoGlobal.GetRandomColor();
     dt = DemoGlobal.GetChartDemoTable();
     this.barChart1.DataSource = dt;
     this.barChart1.DataBind();
 }
Beispiel #3
0
 private void DataBind()
 {
     //设置数据
     this.candleStickChart1.SeriesMember        = "S";
     this.candleStickChart1.XValueMember        = "X";
     this.candleStickChart1.YValueMember        = "Y";
     this.candleStickChart1.ValueHighMember     = "VH";
     this.candleStickChart1.ValueLowMember      = "VL";
     this.candleStickChart1.ValueOpenMember     = "VO";
     this.candleStickChart1.ValueCloseMember    = "VC";
     this.candleStickChart1.XAxis.AxisLineColor = DemoGlobal.GetRandomColor();
     this.candleStickChart1.XAxis.GridColor     = DemoGlobal.GetRandomColor();
     dt = DemoGlobal.GetChartDemoTable();
     this.candleStickChart1.DataSource = dt;
     this.candleStickChart1.DataBind();
 }
        private LineSeries GetNewSerie(LineData data)
        {
            Random countRandom = new Random();
            ChartYAxisValueCollection <ChartYAxisValue> yVals = new ChartYAxisValueCollection <ChartYAxisValue>();
            int count = data.XAxisCount;

            for (int i = 0; i < count; i++)
            {
                yVals.Add(new ChartYAxisValue(countRandom.Next(0, count)));
            }
            LineSeries set1 = new LineSeries(yVals, "DataSet 1");

            set1.Color           = DemoGlobal.GetRandomColor();
            set1.DrawFilled      = true;
            set1.DrawCubic       = true;
            set1.DrawFilledColor = DemoGlobal.GetRandomColor();
            return(set1);
        }
        private PieSeries GetNewSerie(PieData data)
        {
            Random countRandom = new Random();
            ChartYAxisValueCollection <ChartYAxisValue> yVals = new ChartYAxisValueCollection <ChartYAxisValue>();
            int count = data.XAxisCount;

            for (int i = 0; i < count; i++)
            {
                yVals.Add(new BarYAxisValue(countRandom.Next(0, count)));
            }
            PieSeries set1 = new PieSeries(yVals, "DataSet 1");

            set1.AddColor(DemoGlobal.GetRandomColor());
            set1.AddColor(DemoGlobal.GetRandomColor());
            set1.AddColor(DemoGlobal.GetRandomColor());

            return(set1);
        }
        private void DataBind()
        {
            //设置数据
            this.lineChart1.SeriesMember = "S";
            this.lineChart1.XValueMember = "X";
            this.lineChart1.YValueMember = "Y";
            dt = DemoGlobal.GetChartDemoTable();
            this.lineChart1.DataSource = dt;
            this.lineChart1.DataBind();

            //填充随机颜色
            int count = this.lineChart1.Data.SeriesCount;

            for (int i = 0; i < count; i += 1)
            {
                LineSeries series = this.lineChart1.Data.GetSeries(i);
                series.DrawFilled      = true;
                series.DrawFilledColor = DemoGlobal.GetRandomColor();
            }
        }
Beispiel #7
0
        private void popList1_Selected(object sender, EventArgs e)
        {
            switch (popList1.Selections[0].Text)
            {
            case "DataBind":
                DataBind();
                break;

            case "Legend":
                this.pieChart1.Legend.XEntrySpace = 10;
                this.pieChart1.Legend.YEntrySpace = 10;
                this.pieChart1.Legend.Position    = LegendPosition.BELOW_CHART_LEFT;
                this.pieChart1.Legend.XOffset     = 1;
                this.pieChart1.Legend.YOffset     = 1;
                this.pieChart1.Legend.TextSize    = 15;
                this.pieChart1.Legend.TextColor   = System.Drawing.Color.Red;
                break;

            case "LegendSize":
                if (this.pieChart1.Legend.Size == 0)
                {
                    this.pieChart1.Legend.Size = 10;
                }
                else
                {
                    this.pieChart1.Legend.Size = 0;
                }
                break;

            case "AddSet":
                this.pieChart1.Data.AddSeries(GetNewSerie(this.pieChart1.Data));
                break;

            case "RemoveSet":
                if (this.pieChart1.Data.SeriesCount > 0)
                {
                    this.pieChart1.Data.RemoveSeries(0);
                }
                break;

            case "ClearSet":
                this.pieChart1.Data.ClearValues();
                break;

            case "SetData":
                List <string> xLabels = new List <string>();
                xLabels.AddRange(new string[] { "1", "2", "3", "4" });
                PieData data = new PieData(xLabels);

                ChartYAxisValueCollection <ChartYAxisValue> yVals = new ChartYAxisValueCollection <ChartYAxisValue>();
                yVals.Add(new BarYAxisValue(1111111));
                yVals.Add(new BarYAxisValue(3333333));
                yVals.Add(new BarYAxisValue(666666666666));
                yVals.Add(new BarYAxisValue(333333333333));
                PieSeries set1 = new PieSeries(yVals, "DataSet 1");
                set1.AddColor(DemoGlobal.GetRandomColor());
                set1.AddColor(DemoGlobal.GetRandomColor());
                set1.AddColor(DemoGlobal.GetRandomColor());

                data.AddSeries(set1);
                this.pieChart1.Data = data;
                break;
            }
        }