Exemple #1
0
        /// <summary>
        /// 画折线方法
        /// </summary>
        /// <param name="chartControl"></param>
        /// <param name="dt"></param>
        /// <param name="fieldN"></param>
        /// <param name="seriesN"></param>
        /// <param name="title"></param>
        public void DrawDiagram(ChartControl chartControl, DataTable dt, string[] fieldN, string[] seriesN, string title)
        {
            Color[] COLORS  = new Color[] { Color.Blue, Color.Orange, Color.Black, Color.Crimson, Color.Brown, Color.BurlyWood, Color.Cyan };
            Color[] COLORS2 = new Color[] { Color.LightGreen, Color.LightPink };

            chartControl.ClearCache();
            //chartControl.Dispose();

            for (int i = 0; i < seriesN.Count(); i++)
            {
                Series series = new Series(seriesN[i], ViewType.Line);
                series.DataSource         = dt;
                series.ArgumentScaleType  = ScaleType.DateTime;                                                    //x轴参数类型
                series.ArgumentDataMember = "时间";                                                                  //x轴获取指定字段的列
                series.ValueDataMembers.AddRange(seriesN[i]);                                                      //y轴获取指定字段的列
                ((LineSeriesView)series.View).Color = COLORS[i];
                chartControl.Series.Add(series);
            }

            XYDiagram diagram = (XYDiagram)chartControl.Diagram;

            diagram.Panes.Clear();
            diagram.AxisY.Title.Text = "";
            diagram.SecondaryAxesY.Clear();

            diagram.AxisX.DateTimeScaleOptions.MeasureUnit   = DateTimeMeasureUnit.Day;                          //最小刻度
            diagram.AxisX.DateTimeScaleOptions.GridAlignment = DateTimeGridAlignment.Month;                      //最小显示刻度

            diagram.AxisX.DateTimeOptions.Format       = DateTimeFormat.Custom;
            diagram.AxisX.DateTimeOptions.FormatString = "yyyy-MM";
            diagram.AxisX.MinorCount = 1;

            diagram.AxisX.Title.Visible = true;
            diagram.AxisY.Title.Visible = true;


            diagram.AxisX.Title.Text = "时间";

            diagram.AxisY.Title.Alignment = StringAlignment.Far;
            diagram.AxisY.Title.Visible   = true;
            diagram.AxisY.Title.Font      = new Font("宋体", 9.0f);
            diagram.AxisX.Title.Alignment = StringAlignment.Far;
            diagram.AxisX.Title.Visible   = true;
            diagram.AxisX.Title.Font      = new Font("宋体", 9.0f);

            ((XYDiagram)chartControl.Diagram).EnableAxisXZooming   = true;                                        //允许x轴缩放
            ((XYDiagram)chartControl.Diagram).EnableAxisXScrolling = true;                                        //允许x轴移动
            ((XYDiagram)chartControl.Diagram).EnableAxisYScrolling = true;                                        // 允许 y轴移动
            ((XYDiagram)chartControl.Diagram).EnableAxisYZooming   = true;                                        // 允许 y 轴缩放
            chartControl.CrosshairOptions.ShowArgumentLabels       = true;                                        //移动鼠标时动态显示Y轴数据标签
            chartControl.CrosshairOptions.ShowArgumentLine         = true;                                        //显示Y轴线
            chartControl.CrosshairOptions.ArgumentLineColor        = Color.Blue;
            chartControl.Legend.Visibility          = DevExpress.Utils.DefaultBoolean.True;                       //增加示意图
            chartControl.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;

            chartControl.Titles.Add(new ChartTitle());                                                             //增加表名
            chartControl.Titles[0].Text = title;
        }
Exemple #2
0
        public static void GetChartData(string playerName, string chartID, string statsBase, ChartControl chartControl)
        {
            chartControl.ClearCache();

            chartControl.AppearanceNameSerializable = UserSettings.ChartAppearance;
            chartControl.PaletteName = UserSettings.ChartPalette;

            GraphFields gf       = new GraphsSettings(new MessageQueue()).FieldValues(chartID);
            string      newChart = chartID + gf.Caption + gf.DataField + gf.InnerText + gf.Name + gf.Period + gf.StatsBase + gf.Type + playerName + UserSettings.BattleMode;

            if (_currentChart != newChart)
            {
                _currentChart = chartID + gf.Caption + gf.DataField + gf.InnerText + gf.Name + gf.Period + gf.StatsBase + gf.Type + playerName;

                if (statsBase == "Overall")
                {
                    OverallChart(playerName, chartID, gf, chartControl);
                }
                else
                {
                    TankChart(playerName, chartID, gf, chartControl);
                }
            }
        }