DevExpress.XtraCharts.chartControl

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DevExpress.XtraCharts;

namespace ChartControl {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }

private Dictionary<string, double> chartPieDataDic = new Dictionary<string, double>();         private Dictionary<string, double> chartBarDataDic = new Dictionary<string, double>();         private void Form1_Load(object sender, EventArgs e)         {             comboBox1.SelectedIndex = 0;             InitPieChartData();             InitBarChartData();             showPie();                      }         private void showPie()         {             ChartTitle title = new ChartTitle();             title.Text = "全省话务分析饼图-话务类型分布";

chartControl1.Titles.Clear();             chartControl1.Titles.Add(title);

Series series1 = new Series("话务类型", ViewType.Pie);             ((PiePointOptions)series1.PointOptions).PointView = PointView.ArgumentAndValues;

foreach (KeyValuePair<string, double> keyvalue in chartPieDataDic)             {                 series1.Points.Add(new SeriesPoint(keyvalue.Key, new double[] { keyvalue.Value }));             }

chartControl1.Series.Clear();             chartControl1.Series.Add(series1);         }         private void InitPieChartData()         {             try             {                 chartPieDataDic.Add("大连", 0.2);                 chartPieDataDic.Add("沈阳", 0.26);                 chartPieDataDic.Add("锦州", 0.15);                 chartPieDataDic.Add("盘锦", 0.15);                 chartPieDataDic.Add("本溪", 0.1);                 chartPieDataDic.Add("抚顺", 0.12);                 chartPieDataDic.Add("营口", 0.02);             }             catch { }         }         private void InitBarChartData()         {             try             {                 chartBarDataDic.Add("2001", 0.05);                 chartBarDataDic.Add("2002", 0.02);                 chartBarDataDic.Add("2003", 0.08);                 chartBarDataDic.Add("2004", 0.15);                 chartBarDataDic.Add("2005", 0.1);                 chartBarDataDic.Add("2006", 0.3);                 chartBarDataDic.Add("2007", 0.2);                 chartBarDataDic.Add("2008", 0.1);             }             catch { }         }         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)         {             if (comboBox1.Text.IndexOf("饼图") != -1)             {                 showPie();             }             else if (comboBox1.Text.IndexOf("柱图") != -1)             {                 showBar();             }             else if (comboBox1.Text.IndexOf("线图") != -1)             {                 showLine();             }             else if (comboBox1.Text.IndexOf("点图") != -1)             {                 showPoint();             }         }

private void showBar()         {             try             {                 ChartTitle title = new ChartTitle();                 title.Text = "市网元容量增长率统计分析柱图";

chartControl1.Titles.Clear();                 chartControl1.Titles.Add(title);

Series series2 = new Series("大连", ViewType.Bar);                 Series series3 = new Series("沈阳", ViewType.Bar);                 Series series4 = new Series("本溪", ViewType.Bar);                 foreach (KeyValuePair<string, double> kvp in chartBarDataDic)                 {                     series2.Points.Add(new SeriesPoint(kvp.Key, new double[] {kvp.Value}));                     series3.Points.Add(new SeriesPoint(kvp.Key, new double[] {kvp.Value + 0.08}));                     series4.Points.Add(new SeriesPoint(kvp.Key, new double[] {kvp.Value + 0.02}));                 }

chartControl1.Series.Clear();                 chartControl1.Series.Add(series2);                 chartControl1.Series.Add(series3);                 chartControl1.Series.Add(series4);

chartControl1.Legend.Visible = true; // 显示标签(旁边的标注哪个颜色代表哪个城市)             }             catch { }         }

private void showLine()         {             ChartTitle title = new ChartTitle();             title.Text = "线图";             chartControl1.Titles.Clear();             chartControl1.Titles.Add(title);

Series series1 = new Series("辽宁", ViewType.Line);             series1.ArgumentScaleType = ScaleType.Numerical;

series1.Points.Add(new SeriesPoint(1, new double[] { 10 }));             series1.Points.Add(new SeriesPoint(2, new double[] { 12 }));             series1.Points.Add(new SeriesPoint(3, new double[] { 14 }));             series1.Points.Add(new SeriesPoint(4, new double[] { 17 }));             series1.Points.Add(new SeriesPoint(5, new double[] { 21 }));             series1.Points.Add(new SeriesPoint(6, new double[] { 26 }));             series1.Points.Add(new SeriesPoint(7, new double[] { 29 }));             series1.Points.Add(new SeriesPoint(8, new double[] { 30 }));

((PointSeriesView)series1.View).PointMarkerOptions.Kind = MarkerKind.Triangle;

Series series2 = new Series("山东", ViewType.Line);             series2.ArgumentScaleType = ScaleType.Numerical; //这句话必须有,否则点画不出来.             ((LineSeriesView)series2.View).LineStyle.DashStyle = DashStyle.DashDotDot;             series2.Points.Add(new SeriesPoint(1, new double[] { 4 }));             series2.Points.Add(new SeriesPoint(2, new double[] { 14 }));             series2.Points.Add(new SeriesPoint(3, new double[] { 17 }));             series2.Points.Add(new SeriesPoint(4, new double[] { 22 }));             series2.Points.Add(new SeriesPoint(5, new double[] { 20 }));             series2.Points.Add(new SeriesPoint(6, new double[] { 15 }));             series2.Points.Add(new SeriesPoint(7, new double[] { 18 }));             series2.Points.Add(new SeriesPoint(8, new double[] { 11 }));

((PointSeriesView)series2.View).PointMarkerOptions.Kind = MarkerKind.Cross;

chartControl1.Series.Clear();             chartControl1.Series.Add(series1);             chartControl1.Series.Add(series2);             chartControl1.Legend.Visible = true;         }         private void showPoint()         {             ChartTitle title = new ChartTitle();             title.Text = "点图";             chartControl1.Titles.Clear();             chartControl1.Titles.Add(title);

Series series1 = new Series("上线人数", ViewType.Point);             series1.ArgumentScaleType = ScaleType.Numerical;

series1.Points.Add(new SeriesPoint(1, new double[] { 20 }));             series1.Points.Add(new SeriesPoint(2, new double[] { 12 }));             series1.Points.Add(new SeriesPoint(3, new double[] { 11 }));             series1.Points.Add(new SeriesPoint(4, new double[] { 17 }));             series1.Points.Add(new SeriesPoint(5, new double[] { 21 }));             series1.Points.Add(new SeriesPoint(6, new double[] { 21 }));             series1.Points.Add(new SeriesPoint(7, new double[] { 29 }));             series1.Points.Add(new SeriesPoint(8, new double[] { 30 }));

((PointSeriesView)series1.View).PointMarkerOptions.Kind = MarkerKind.Triangle;

Series series2 = new Series("下线人数", ViewType.Point);             series2.ArgumentScaleType = ScaleType.Numerical; //这句话必须有,否则点画不出来.

series2.Points.Add(new SeriesPoint(1, new double[] { 4 }));             series2.Points.Add(new SeriesPoint(2, new double[] { 14 }));             series2.Points.Add(new SeriesPoint(3, new double[] { 17 }));             series2.Points.Add(new SeriesPoint(4, new double[] { 22 }));             series2.Points.Add(new SeriesPoint(5, new double[] { 20 }));             series2.Points.Add(new SeriesPoint(6, new double[] { 15 }));             series2.Points.Add(new SeriesPoint(7, new double[] { 18 }));             series2.Points.Add(new SeriesPoint(8, new double[] { 11 }));

((PointSeriesView)series2.View).PointMarkerOptions.Kind = MarkerKind.Cross;

chartControl1.Series.Clear();             chartControl1.Series.Add(series1);             chartControl1.Series.Add(series2);             chartControl1.Legend.Visible = true;         }     } }

时间: 2024-12-28 00:52:40

DevExpress.XtraCharts.chartControl的相关文章

DevExpress之ChartControl用法

DevExpress中的ChartControl顾名思义就是数据基于图表展示,其关键在于Series上的处理. using System; using System.Drawing; using DevExpress.XtraCharts; namespace DevExpressUtilHelpV3 { public static class ChartToolV3 { /// <summary> /// 创建Series /// </summary> /// <param

DevExpress之ChartControl实现时间轴实例 z

using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; namespace DevExpressChart { public partial class winDateTime : Form { public winDateTime() { InitializeComponent(); } private void winDateTime_Load(object sende

Devexpress WPF ChartControl 多Y轴

<Window x:Class="DXApplication4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/

【原】为DevExpress的ChartControl添加Y轴控制 和 GridControl中指定列添加超级链接

一.控制ChartControl的Y轴范围 使用Devexpress中的CharControl控件,需要控制AxisY轴的显示范围,需要使用该控件的BoundDataChanged事件,具体代码如下: 该代码实现的效果如下:   二.设置GridControl表格中的超级链接: 1.首先在表格的设计器中添加一个HyperLinkEdit 的 Repository: 2.将该Repository绑定到列表中的指定列中: 3.为第一步添加的rpLink控件添加Open_Link事件处理函数: 4.最

DevExpress之ChartControl基本用法

Series 作为cartControl的基本单位来现实图表数据 所以每一个Series代表一种需要显示的类型. 首先实例化一个Series Series _series = new Series("处理次数", ViewType.Bar); _series.ArgumentScaleType = ScaleType.Qualitative; _series.ArgumentDataMember = "dpName"; _series.ValueDataMember

devexpress中用ChartControl生成柱状图

在界面中拖入一个ChartControl控件,然后添加一个simplebutton控件.在simplebutton控件的click事件中加入如下代码: private void button1_Click(object sender, EventArgs e)        {            //数据源            chartControl1.DataSource = CreateChartData();            //数据成员            chartCo

DevExpress中ChartControl柱状图(Bar)用法

我的数据 代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 chartControl1.Series.Clear();   // 柱状图里的第一个柱 Series Series1 = new Series("当年数据", ViewType.Bar); Series1.DataSource = data; Series1.ArgumentScaleType = ScaleType.Qualitative;

[DevExpress]ChartControl之时间轴示例

关键代码: using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; namespace DevExpressChart { public partial class winDateTime : Form { public winDateTime() { InitializeComponent(); } private void winDateTime_Load(object

[DevExpress]ChartControl之柱状图演示

关键代码: using System; using System.Data; using System.Windows.Forms; using CSharpUtilHelpV2; using DevExpress.XtraCharts; namespace DevExpressChart { public partial class winProduct : Form { public winProduct() { InitializeComponent(); } static readonl