Пример #1
0
        private void setViewByData(int gid, double num)
        {
            double tar = 0;

            if (num > ColumnChart.Series[0].Points[gid].YValues[0])
            {
                tar = num - ColumnChart.Series[0].Points[gid].YValues[0];
                for (int i = 1; i <= tar; i++)
                {
                    ColumnChart.Invoke(new EventHandler(delegate {
                        ColumnChart.Series[0].Points[gid].YValues = new Double[] { ColumnChart.Series[0].Points[gid].YValues[0] + 1 };
                        int cur = (int)ColumnChart.Series[0].Points[gid].YValues[0];
                        if (cur >= 0 && cur < 10)
                        {
                            ColumnChart.Series[0].Points[gid].Color = Color.Green;
                        }
                        else if (cur >= 10 && cur < 50)
                        {
                            ColumnChart.Series[0].Points[gid].Color = Color.Blue;
                        }
                        else if (cur >= 50 && cur < 80)
                        {
                            ColumnChart.Series[0].Points[gid].Color = Color.Orange;
                        }
                        else if (cur >= 80 && cur < 100)
                        {
                            ColumnChart.Series[0].Points[gid].Color = Color.Red;
                        }
                        Thread.Sleep(10);
                        RefreshTheChart();
                    }));
                }
                if (num < ColumnChart.Series[0].Points[gid].YValues[0])
                {
                    tar = ColumnChart.Series[0].Points[gid].YValues[0] - num;
                    for (int i = 1; i <= tar; i++)
                    {
                        ColumnChart.Invoke(new EventHandler(delegate
                        {
                            ColumnChart.Series[0].Points[gid].YValues = new Double[] { ColumnChart.Series[0].Points[gid].YValues[0] - 1 };
                            int cur = (int)ColumnChart.Series[0].Points[gid].YValues[0];
                            if (cur >= 0 && cur < 10)
                            {
                                ColumnChart.Series[0].Points[gid].Color = Color.Green;
                            }
                            else if (cur >= 10 && cur < 50)
                            {
                                ColumnChart.Series[0].Points[gid].Color = Color.Blue;
                            }
                            else if (cur >= 50 && cur < 80)
                            {
                                ColumnChart.Series[0].Points[gid].Color = Color.Orange;
                            }
                            else if (cur >= 80 && cur < 100)
                            {
                                ColumnChart.Series[0].Points[gid].Color = Color.Red;
                            }
                        }));
                    }
                }
            }
        }