protected void Page_Load(object sender, EventArgs e) { WebChartControl chart = new WebChartControl(); chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = string.Format(Utilities.GetResourceString("Common", "ChartHeader"), "Jmeno", "Start 10.12.2010","Finish 17.12.2010"); title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; Dictionary<int, Series> series = new Dictionary<int, Series>(); Series s0 = new Series("Recommended price", ViewType.StackedBar); s0.ValueScaleType = ScaleType.Numerical; s0.ArgumentScaleType = ScaleType.DateTime; series.Add(0, s0); SetGraphPoint(series[0], "rnd"); Series s1 = new Series("Actual price", ViewType.Line); s1.ValueScaleType = ScaleType.Numerical; s1.ArgumentScaleType = ScaleType.DateTime; series.Add(1, s1); SetGraphPoint(series[1], "fib"); //Series s2 = new Series("Predicted price", ViewType.Bubble); //s2.ValueScaleType = ScaleType.Numerical; //s2.ArgumentScaleType = ScaleType.DateTime; //series.Add(2, s2); //SetGraphPoint(series[2], "byte"); foreach (KeyValuePair<int, Series> serie in series) chart.Series.Add(serie.Value); //chart.SeriesTemplate.ShowInLegend = false; chart.Legend.Direction = LegendDirection.LeftToRight; chart.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center; chart.Legend.AlignmentVertical = LegendAlignmentVertical.Bottom; DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Title.Text = "CZK"; xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; chart.Diagram = xyDiagram; chart.Width = 700; chart.Height = 500; //chart.DataBind(); phMain.Controls.Add(chart); }
private void CreateChart(DataTable dt) { #region Series List <Series> list = new List <Series>(); int iCount = 0; list.Clear(); chartControl1.Series.Clear(); chartControl1.Titles.Clear(); int selectIndex = 0; if (dt != null) { DataRow drItem = dt.Rows[selectIndex]; Series series1 = CreateOldSeries(drItem[0].ToString(), ViewType.Pie, dt, iCount); iCount = iCount + 1; list.Add(series1); } #endregion chartControl1.Series.AddRange(list.ToArray()); chartControl1.Legend.Visible = true; chartControl1.Legend.MarkerVisible = true; chartControl1.SeriesTemplate.LabelsVisibility = DefaultBoolean.True; ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "出院结算费用报销分布分析"; chartControl1.Titles.Add(chartTitle); CreateChartTwo(dt); }
private void ShowTotalRFQs() { string result = _metrics.GetTotalRFQs(); if (result != "") { MessageBox.Show(result); return; } _chartControl.DataSource = _metrics.quotesPerYear; Series series1 = new Series(); series1.ArgumentDataMember = "QuoteYear"; series1.ValueDataMembers[0] = "NumberOfQuotes"; series1.Name = "Total Quotes"; series1.ChangeView(DevExpress.XtraCharts.ViewType.Bar); // Add series to chart _chartControl.Series.Add(series1); ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "RFQ's Received"; _chartControl.Titles.Add(chartTitle); }
private ChartTitle GetChartTitle(string seriesName) { _chartTitle = new ChartTitle(); switch (seriesName) { case "区域面积": case "建筑面积": case "占地面积": case "绿化面积": _chartTitle.Text = seriesName + "统计图 单位:平方米"; break; case "建筑物数": case "构筑物数": case "绿化地块数": _chartTitle.Text = seriesName + "统计图 单位:个"; break; case "道路长度": case "铁路长度": _chartTitle.Text = seriesName + "统计图 单位:米"; break; } _chartTitle.Font = new System.Drawing.Font("宋体", 15f); return(_chartTitle); }
public void ChartTitle() { //ExStart //ExFor:Charts.Chart //ExFor:Charts.Chart.Title //ExFor:Charts.ChartTitle //ExFor:Charts.ChartTitle.Overlay //ExFor:Charts.ChartTitle.Show //ExFor:Charts.ChartTitle.Text //ExSummary:Shows how to insert a chart and change its title. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to insert a bar chart Shape chartShape = builder.InsertChart(ChartType.Bar, 400, 300); Assert.AreEqual(ShapeType.NonPrimitive, chartShape.ShapeType); Assert.True(chartShape.HasChart); // Get the chart object from the containing shape Chart chart = chartShape.Chart; // Set the title text, which appears at the top center of the chart and modify its appearance ChartTitle title = chart.Title; title.Text = "MyChart"; title.Overlay = true; title.Show = true; doc.Save(ArtifactsDir + "Charts.ChartTitle.docx"); //ExEnd }
private void CreateChartTwo(DataTable dt) { dt = finBiz.GetInMainFeeData2("ALL", this.dtBeginDate.Value.ToString("yyyy-MM-dd"), this.dtEnd.Value.ToString("yyyy-MM-dd")); #region Series List <Series> list = new List <Series>(); int iCount = 0; list.Clear(); if (dt == null) { return; } foreach (DataRow drItem in dt.Rows) { Series series1 = CreateSeries(drItem[0].ToString(), ViewType.Bar, dt, iCount); iCount = iCount + 1; list.Add(series1); } #endregion chartControl2.Series.Clear(); chartControl2.Titles.Clear(); chartControl2.Series.AddRange(list.ToArray()); chartControl2.Legend.Visible = true; chartControl2.SeriesTemplate.LabelsVisibility = DefaultBoolean.True; ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "出院结算各医保费用报销比例(%)"; chartControl2.Titles.Add(chartTitle); }
private void loadDanhMuc() { //WebChartControl WebChartControl = new WebChartControl(); // Add the chart to the form. // Note that a chart isn't initialized until it's added to the form's collection of controls. //this.Controls.Add(WebChartControl); // Create a new bar series. Series series = new Series("Công ty điện lực", ViewType.Bar); // Add the series to the chart. WebChartControl1.Series.Add(series); // Specify the series data source. DataTable seriesData = GetData(); series.DataSource = seriesData; ChartTitle ct = new ChartTitle(); ct.Text = "THỐNG KÊ TÌNH HÌNH NHẬP LIỆU CÁC ĐIỆN LỰC ( Tính theo tỷ lệ %)"; WebChartControl1.Titles.Add(ct); // Specify an argument data member. series.ArgumentDataMember = "Region"; // Specify a value data member. series.ValueDataMembers.AddRange(new string[] { "Sales" }); // Rotate the diagram (if necessary). ((XYDiagram)WebChartControl1.Diagram).Rotated = false; ((XYDiagram)WebChartControl1.Diagram).AxisY.Range.SetMinMaxValues(0, 100); ((XYDiagram)WebChartControl1.Diagram).AxisY.Label.EndText = "%"; }
/// <summary> /// Initializes a new instance of the <see cref="ChartPane" /> class. /// </summary> public ChartPane() { Title = new ChartTitle(); Margin = new ChartSpacing(); Padding = new ChartSpacing(); Border = new ChartElementBorder(); }
private void ShowQuotesByMonthForCurrentYear() { string result = _metrics.GetRFQsByMonth(); if (result != "") { MessageBox.Show(result); return; } _chartControl.DataSource = _metrics.quotesPerMonth; Series series1 = new Series(); series1.ArgumentDataMember = "QuoteMonth"; series1.ValueDataMembers[0] = "NumberOfQuotes"; series1.ChangeView(DevExpress.XtraCharts.ViewType.Bar); series1.DataFilters.Add(new DataFilter("QuoteYear", "System.Int32", DataFilterCondition.Equal, DateTime.Now.Year)); // Add series to chart _chartControl.Series.Add(series1); // Add title to chart ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = DateTime.Now.Year.ToString() + " Quotes by Month"; _chartControl.Titles.Add(chartTitle); _chartControl.Legend.Visible = false; }
private void InitDataSource( ) { CommonUtils.ConexionBD.AbrirConexion( ); ChartTitle chartTitle = new ChartTitle( ); chartTitle.Text = "Productos por tipo"; chartControl.Titles.Add( chartTitle ); //chartControl.SeriesTemplate.ValueDataMembersSerializable = "Tipo"; string sql = "SELECT Categoria.Tipo, COUNT(Categoria.Tipo) AS Amount FROM Categoria INNER JOIN Producto ON Categoria.CategoriaId = Producto.CategoriaId " + "GROUP BY Categoria.Tipo HAVING (Categoria.Tipo = Categoria.Tipo)"; //DataTable table = CommonUtils.ConexionBD.EjecutarConsulta( sql ); SqlCommand cmdProduct = new SqlCommand( sql , CommonUtils.ConexionBD.Conexion ); DataSet dataSet = new DataSet( ); dataSet.Load( cmdProduct.ExecuteReader( ) , LoadOption.OverwriteChanges , "Producto" ); BindingSource bs = new BindingSource( ); bs.DataSource = dataSet.Tables[ 0 ]; chartControl.DataSource = bs; chartControl.SeriesDataMember = "Tipo"; chartControl.SeriesTemplate.ArgumentDataMember = "Amount"; //chartControl.SeriesTemplate.ValueDataMembersSerializable = "Amount"; chartControl.SeriesTemplate.ValueDataMembers.AddRange( new string[ ] { "Amount" } ); CommonUtils.ConexionBD.CerrarConexion( ); }
private void ShowOnTimeDelivery() { string result = _metrics.GetOnTimeDelivery(); if (result != "") { MessageBox.Show(result); return; } // Create a pie series. Series series1 = new Series("Pie Series", ViewType.Pie); // Populate the series with points. series1.Points.Add(new SeriesPoint("On Time", _metrics.onTimeDelivery[0].OnTime)); series1.Points.Add(new SeriesPoint("Late", _metrics.onTimeDelivery[0].Late)); // Adjust the point options of the series. series1.Label.PointOptions.PointView = PointView.ArgumentAndValues; series1.Label.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; series1.Label.PointOptions.ValueNumericOptions.Precision = 0; // Add series to chart _chartControl.Series.Add(series1); // Add title to chart ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "On Time Delivery " + DateTime.Now.Year.ToString(); _chartControl.Titles.Add(chartTitle); _chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True; }
private void ShowQuoteRequestsPerMonth() { string result = _metrics.GetQuoteRequestsPerMonth(); if (result != "") { MessageBox.Show(result); return; } _chartControl.DataSource = _metrics.quoteRequestsPerMonth; // Create a chart series for each active quote engineer _metrics.GetQuoteEngineerNames(); foreach (var name in _metrics.quoteEngineerNames) { // Create a series for each quote engineer Series series = new Series(); series.Name = name.FirstName; series.ArgumentDataMember = "QuoteMonth"; series.ValueDataMembers[0] = "NumberOfQuotes"; series.ChangeView(DevExpress.XtraCharts.ViewType.Line); series.DataFilters.Add(new DataFilter("QuoteEngineer", "String", DataFilterCondition.Equal, name.FirstName)); // Add series to chart _chartControl.Series.Add(series); } ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "Quote Requests Received by Month " + DateTime.Now.Year.ToString(); _chartControl.Titles.Add(chartTitle); }
private void CreateChartTwo(DataTable dt) { #region Series List <Series> list = new List <Series>(); int iCount = 0; list.Clear(); if (dt == null) { return; } foreach (DataRow drItem in dt.Rows) { Series series1 = CreateSeries(drItem[0].ToString(), ViewType.Bar, dt, iCount); iCount = iCount + 1; list.Add(series1); } #endregion chartControl2.Series.Clear(); chartControl2.Titles.Clear(); chartControl2.Series.AddRange(list.ToArray()); chartControl2.Legend.Visible = true; chartControl2.SeriesTemplate.LabelsVisibility = DefaultBoolean.True; ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "出院人次结算类型分析(单位:人次)"; chartControl2.Titles.Add(chartTitle); }
/// <summary> /// Initializes a new instance of the <see cref="ChartPane" /> class. /// </summary> public ChartPane() { Title = new ChartTitle(); Margin = new ChartSpacing(); Padding = new ChartSpacing(); Border = new ChartElementBorder(); }
private void InitDataSource( ) { CommonUtils.ConexionBD.AbrirConexion( ); ChartTitle chartTitle = new ChartTitle( ); chartTitle.Text = "Productos por tipo"; chartControl.Titles.Add(chartTitle); //chartControl.SeriesTemplate.ValueDataMembersSerializable = "Tipo"; string sql = "SELECT Categoria.Tipo, COUNT(Categoria.Tipo) AS Amount FROM Categoria INNER JOIN Producto ON Categoria.CategoriaId = Producto.CategoriaId " + "GROUP BY Categoria.Tipo HAVING (Categoria.Tipo = Categoria.Tipo)"; //DataTable table = CommonUtils.ConexionBD.EjecutarConsulta( sql ); SqlCommand cmdProduct = new SqlCommand(sql, CommonUtils.ConexionBD.Conexion); DataSet dataSet = new DataSet( ); dataSet.Load(cmdProduct.ExecuteReader( ), LoadOption.OverwriteChanges, "Producto"); BindingSource bs = new BindingSource( ); bs.DataSource = dataSet.Tables[0]; chartControl.DataSource = bs; chartControl.SeriesDataMember = "Tipo"; chartControl.SeriesTemplate.ArgumentDataMember = "Amount"; //chartControl.SeriesTemplate.ValueDataMembersSerializable = "Amount"; chartControl.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Amount" }); CommonUtils.ConexionBD.CerrarConexion( ); }
/// <summary> /// 设置图表标题 /// </summary> /// <param name="control">图表控件</param> /// /// <param name="isVisible">标题是否可见</param> /// <param name="text">标题文本</param> /// <param name="isWordWrop">是否换行</param> /// <param name="maxLineCount">最大允许行数</param> /// <param name="alignment">对齐方式</param> /// <param name="dock">位置</param> /// <param name="isAntialiasing">是否允许设置外观</param> /// <param name="font">字体</param> /// <param name="textColor">文本颜色</param> /// <param name="indent">字体缩进值</param> public static void SetChartTitle(DevExpress.XtraCharts.ChartControl control, bool isVisible, String text, bool isWordWrop, int maxLineCount, StringAlignment alignment, ChartTitleDockStyle dock, bool isAntialiasing, Font font, Color textColor, int indent) { //设置标题 ChartTitle title = new ChartTitle(); title.Visible = isVisible; //显示文本 title.Text = text; //是否允许换行 title.WordWrap = isWordWrop; //最大允许行数 title.MaxLineCount = maxLineCount; //对齐方式 title.Alignment = alignment; //位置 title.Dock = dock; //是否允许设置外观 title.Antialiasing = isAntialiasing; //字体 title.Font = font; //字体颜色 title.TextColor = textColor; //缩进值 title.Indent = indent; control.Titles.Add(title); }
public DataTable SetGraphForStrongPasswordCount() { strongpasswordWebChart.Series.Clear(); DataTable dt = VSWebBL.DashboardBL.Office365BL.Ins.PasswordsChart(); Series series = new Series("DeviceCount", ViewType.Pie); for (int i = 0; i < dt.Rows.Count; i++) { series.Points.Add(new SeriesPoint("Strong Password Required: " + dt.Rows[i]["StrongPasswordRequired"], dt.Rows[i]["NumberOfPasswords"])); } strongpasswordWebChart.Series.Add(series); series.Label.PointOptions.PointView = PointView.Argument; series.ToolTipEnabled = DevExpress.Utils.DefaultBoolean.True; //series.Label.PointOptions.ValueNumericOptions.Format = NumericFormat.General; // series.Label.PointOptions.ValueNumericOptions.Precision = 0; strongpasswordWebChart.Legend.Visible = false; ChartTitle title = new ChartTitle(); title.Text = "Strong Password Required"; strongpasswordWebChart.Titles.Clear(); strongpasswordWebChart.Titles.Add(title); strongpasswordWebChart.DataSource = dt; strongpasswordWebChart.DataBind(); return(dt); }
private void Form1_Load(object sender, EventArgs e) { // Create a new chart. ChartControl polarLineChart = new ChartControl(); // Add a polar series to it. Series series1 = new Series("Series 1", ViewType.PolarLine); // Populate the series with points. series1.Points.Add(new SeriesPoint(0, 90)); series1.Points.Add(new SeriesPoint(90, 70)); series1.Points.Add(new SeriesPoint(180, 50)); series1.Points.Add(new SeriesPoint(270, 100)); // Add the series to the chart. polarLineChart.Series.Add(series1); // Flip the diagram (if necessary). ((PolarDiagram)polarLineChart.Diagram).StartAngleInDegrees = 180; ((PolarDiagram)polarLineChart.Diagram).RotationDirection = RadarDiagramRotationDirection.Counterclockwise; // Add a title to the chart and hide the legend. ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "Polar Line Chart"; polarLineChart.Titles.Add(chartTitle1); polarLineChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; // Add the chart to the form. polarLineChart.Dock = DockStyle.Fill; this.Controls.Add(polarLineChart); }
/// <summary> /// 绑定到按服务细分的数据 /// </summary> /// <returns></returns> private void BindingDataByService() { chart.DataSource = aas.GetCallNumAnalyseDataByService(); //((XYDiagram)chart.Diagram).Rotated = false; ChartTitle ct = new ChartTitle(); ct.Text = "按服务细分的调用次数统计"; chart.Titles.Clear(); chart.Titles.Add(ct); chart.Series.Clear(); chart.SeriesDataMember = "ServiceName"; chart.SeriesTemplate.View = new StackedBarSeriesView(); chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "NUM" }); chart.SeriesTemplate.ArgumentDataMember = "BusinessName"; chart.SeriesTemplate.PointOptions.PointView = PointView.Values; chart.SeriesTemplate.PointOptions.ValueNumericOptions.Format = NumericFormat.General; chart.SeriesNameTemplate.BeginText = "服务:"; chart.DataBind(); }
/// <summary> /// /// </summary> /// <param name="dt"></param> /// <param name="webChartContro"></param> /// <param name="title"></param> private void CreateCustomerChart(DataTable dt, DevExpress.XtraCharts.Web.WebChartControl webChartContro, string title) { webChartContro.Series.Clear(); if (dt.Rows.Count > 0) { Series series = new Series("客户分布", ViewType.Pie);//首先new一个对象 //for (int i = 0; i < dt.Rows.Count; i++) //{ foreach (DataRow row in dt.Rows)//将传入的表dt中每行数据都加入进去 { SeriesPoint point = new SeriesPoint(row["C_X"].ToString(), row["C_Y"].ToString()); series.Points.Add(point); } //} webChartContro.Series.Add(series); //样式设置 series.ArgumentScaleType = ScaleType.Qualitative; series.ValueScaleType = ScaleType.Numerical; ((PieSeriesView)series.View).Rotation = 90; //从90度方向开始 series.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; //显示为百分比形式 series.LegendPointOptions.PointView = PointView.Argument; //右边的图例 series.PointOptions.PointView = PointView.ArgumentAndValues; //左边饼上的图例 ((PiePointOptions)(series.PointOptions)).PercentOptions.PercentageAccuracy = 3; //保留三位小数 ChartTitle CTitl = new ChartTitle(); //加标题 CTitl.Text = title; webChartContro.Titles.Clear(); webChartContro.Titles.Add(CTitl); webChartContro.Visible = true; } }
/// <summary> /// 获取到所有的数据 /// </summary> /// <returns></returns> private void BindingAllData() { ChartTitle ct = new ChartTitle(); ct.Text = "所有调用次数统计"; chart.Titles.Clear(); chart.Titles.Add(ct); chart.SeriesTemplate.View = new PieSeriesView(); Series series1 = new Series("Line Series 1", ViewType.Pie); DataTable dt = aas.GetCallNumAnalyseData(); for (int i = 0; i < dt.Rows.Count; i++) { string title = dt.Rows[i]["BusinessFullName"].ToString(); double num = double.Parse(dt.Rows[i]["NUM"].ToString()); series1.Points.Add(new SeriesPoint(title, new double[] { num })); } ((PieSeriesLabel)series1.Label).Position = PieSeriesLabelPosition.Outside; ((PiePointOptions)series1.PointOptions).PointView = PointView.Values; ((PiePointOptions)series1.PointOptions).PercentOptions.ValueAsPercent = true; ((PiePointOptions)series1.PointOptions).ValueNumericOptions.Format = NumericFormat.Percent; ((PiePointOptions)series1.PointOptions).ValueNumericOptions.Precision = 0; series1.LegendPointOptions.PointView = PointView.ArgumentAndValues; series1.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.FixedPoint; series1.LegendPointOptions.ValueNumericOptions.Precision = 0; ((PiePointOptions)series1.LegendPointOptions).PercentOptions.ValueAsPercent = false; chart.Series.Add(series1); }
//根据文章数,按文章发布时间产生折线图 public string CreateLine(string key, DataTable dt) { ChartTitle title = new ChartTitle() { text = key, subtext = "最近30天" }; ChartOption option = null; option = new BarChartOption(title, "", "line"); string[] days = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31".Split(','); int[] data_int = new int[days.Length]; for (int i = 0; i < days.Length; i++) { data_int[i] = dt.Select("Day=" + (i + 1)).Length; } List <ChartSeries> seriesList = new List <ChartSeries>()//这里的统计算法不对,需要统计出文章数 { new ChartSeries() { name = "文章数", type = "line", data_int = data_int } }; ((BarChartOption)option).AddData(days, seriesList, ""); option.tooltip.formatter = null;//使用默认格式 return(option.ToString()); }
private void ChartPreview() { string chartField1 = _data.DrTable["ChartField1"].ToString().ToUpper(); string chartField2 = _data.DrTable["ChartField2"].ToString().ToUpper(); string chartField3 = _data.DrTable["ChartField3"].ToString().ToUpper(); if (chartField1 == string.Empty && chartField2 == string.Empty) { return; } DevExpress.XtraCharts.ChartControl chartMain = new ChartControl(); chartMain.DataSource = gridViewReport.DataSource; chartMain.Series.Clear(); chartMain.SeriesDataMember = chartField1; if (chartField3 == string.Empty) { chartMain.SeriesTemplate.ArgumentDataMember = chartField1; } else { chartMain.SeriesTemplate.ArgumentDataMember = chartField3; } chartMain.SeriesTemplate.ValueDataMembers.AddRange(new string[] { chartField2 }); chartMain.SeriesTemplate.View = new StackedBarSeriesView(); ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = this.Text; chartMain.Titles.Add(chartTitle); chartMain.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Stretch; chartMain.ShowPrintPreview(); }
/// <summary> /// 获取到所有的数据 /// </summary> /// <returns></returns> private void BindingAllData() { chart.DataSource = aas.GetResTimeAnalyseData(); ChartTitle ct = new ChartTitle(); ct.Text = "按服务细分的响应时间分析"; chart.Titles.Clear(); chart.Titles.Add(ct); chart.Legend.Direction = LegendDirection.LeftToRight; chart.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center; chart.Legend.AlignmentVertical = LegendAlignmentVertical.BottomOutside; chart.Series.Clear(); chart.SeriesDataMember = "MethodName"; chart.SeriesTemplate.View = new SideBySideBarSeriesView(); chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "ResTimeAvg" }); chart.SeriesTemplate.ArgumentDataMember = "ServiceName"; chart.SeriesTemplate.PointOptions.PointView = PointView.Values; chart.SeriesTemplate.PointOptions.ValueNumericOptions.Format = NumericFormat.General; ((SideBySideBarSeriesLabel)chart.SeriesTemplate.Label).Position = BarSeriesLabelPosition.Top; ((XYDiagram)chart.Diagram).Rotated = true; ((XYDiagram)chart.Diagram).AxisY.Label.Font = new System.Drawing.Font("Tahoma", 8, System.Drawing.FontStyle.Bold); ((XYDiagram)chart.Diagram).AxisY.Label.Antialiasing = true; ((XYDiagram)chart.Diagram).AxisY.Label.Angle = 30; //((XYDiagram)chart.Diagram).AxisY.Label.Font = new System.Drawing.Font("宋体", 10, System.Drawing.FontStyle.Bold); chart.DataBind(); }
public DataTable SetGraphForUsersDaily() { //string fromdate = ""; //string todate = ""; //fromdate = dtPick.FromDate; //todate = dtPick.ToDate; UsersDailyWebChart.Series.Clear(); DataTable dt = VSWebBL.DashboardBL.ConnectionsBL.Ins.GetUsersDailyCount("%created_last_day%", Request.QueryString["Name"]); UsersDailyWebChart.SeriesDataMember = "StatName"; UsersDailyWebChart.SeriesTemplate.ArgumentDataMember = "Date"; UsersDailyWebChart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "StatValue" }); ((LineSeriesView)UsersDailyWebChart.SeriesTemplate.View).LineMarkerOptions.Size = 7; ChartTitle title = new ChartTitle(); title.Text = "Daily Activities"; System.Drawing.Font font = new System.Drawing.Font(title.Font.FontFamily.Name, 12); title.Font = font; UsersDailyWebChart.Titles.Clear(); UsersDailyWebChart.Titles.Add(title); UI uiobj = new UI(); uiobj.RecalibrateChartAxes(UsersDailyWebChart.Diagram, "Y", "int", "int"); UsersDailyWebChart.DataSource = dt; UsersDailyWebChart.DataBind(); return(dt); }
//生成文章来源饼图 public string CreateSumPie(string key, DataTable dt) { ChartTitle title = new ChartTitle() { text = key, subtext = "平台对比" }; ChartOption option = new PieChartOption(title, ""); ChartLegend legend = new ChartLegend(); legend.data = "新闻,微博,微信".Split(','); ChartData[] data_mod = new ChartData[legend.data.Length]; for (int i = 0; i < legend.data.Length; i++) { data_mod[i] = new ChartData() { name = legend.data[i], value = dt.Select("Source='" + legend.data[i] + "'").Length }; } List <ChartSeries> seriesList = new List <ChartSeries>() { new ChartSeries() { name = "平台对比", data_mod = data_mod } }; ((PieChartOption)option).AddData(legend, seriesList, ""); return(option.ToString()); }
private static void DecorateSlideThree(PPT.Slide slide) { var columnsList = new string[] { "C#", "VB.Net", "Perl", "Python", "Java" }; var series1 = new ChartSeries() { name = "Blog Statistics", seriesData = new string[] { "8200", "3900", "890", "300", "3278" }, seriesType = XlChartType.xl3DColumn }; var chartData = new List <ChartSeries>() { series1 }; var chart = PptChartManager.CreateChart(XlChartType.xlColumnStacked, slide, columnsList, chartData); var chartTitle = new ChartTitle() { bold = true, italic = false, fontSize = 40, titleText = "Users by Software Language", underline = false }; PptChartManager.AddChartTitle(chart, chartTitle); SetSlideFooter(slide, 3); }
private void ShowCompletedQuotesByEstimator() { string result = _metrics.GetCompletedQuotesByEstimator(); if (result != "") { MessageBox.Show(result); return; } _chartControl.DataSource = _metrics.compQuotesByEstimator; Series series1 = new Series(); series1.LegendText = "On Time"; series1.ArgumentDataMember = "QuoteEngineer"; series1.ValueDataMembers[0] = "OnTime"; series1.ChangeView(DevExpress.XtraCharts.ViewType.Bar); Series series2 = new Series(); series2.LegendText = "Late"; series2.ArgumentDataMember = "QuoteEngineer"; series2.ValueDataMembers[0] = "Late"; series2.ChangeView(DevExpress.XtraCharts.ViewType.Bar); // Add series to chart _chartControl.Series.Add(series1); _chartControl.Series.Add(series2); // Add title to chart ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "Completed Quotes by Estimator " + DateTime.Now.Year.ToString(); _chartControl.Titles.Add(chartTitle); }
void LoadChartTop(ChartControl chart, ChartTitle t, List <BieuDoTop> data) { chart.Series[0].DataSource = data; chart.Series[0].ArgumentDataMember = "Name"; chart.Series[0].ValueDataMembers.AddRange("Value"); chart.Titles.Add(t); }
private void ShowDaysLate() { string result = _metrics.GetDaysLate(); if (result != "") { MessageBox.Show(result); return; } _chartControl.DataSource = _metrics.onTimeDaysLateBreakdown; Series series1 = new Series(); series1.ArgumentDataMember = "Category"; series1.ValueDataMembers[0] = "NumberOfDaysLate"; //series1.Name = "Category1"; series1.ChangeView(DevExpress.XtraCharts.ViewType.Bar); // Add series to chart _chartControl.Series.Add(series1); ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "Number of Days Late " + DateTime.Now.Year.ToString(); _chartControl.Titles.Add(chartTitle); }
private void setChartTitle(string argTitle) { chartControl1.Titles.Clear(); // Create chart titles. ChartTitle chartTitle1 = new ChartTitle(); // Define the text for the titles. // chartTitle1.Text = "<i>Basic</i> <b>HTML</b> <u>is</u> <color=blue>supported</color>."; chartTitle1.Text = argTitle; // Define the alignment of the titles. chartTitle1.Alignment = StringAlignment.Center; // Place the titles where it's required. chartTitle1.Dock = ChartTitleDockStyle.Top; // Customize a title's appearance. chartTitle1.Antialiasing = true; chartTitle1.Font = new Font("Tahoma", 14, FontStyle.Bold); // chartTitle1.TextColor = Color.Red; chartTitle1.Indent = 10; // Add the titles to the chart. chartControl1.Titles.AddRange(new ChartTitle[] { chartTitle1 }); }
private void ShowTypeOfRequestsPerCustomer() { string result = _metrics.GetTypeOfRequestsPerCustomer(); if (result != "") { MessageBox.Show(result); return; } _chartControl.DataSource = _metrics.typeOfRequestsPerCustomer; Series series1 = new Series(); series1.LegendText = "New Quotes"; series1.ArgumentDataMember = "Customer"; series1.ValueDataMembers[0] = "NewQuotes"; series1.ChangeView(DevExpress.XtraCharts.ViewType.Bar); Series series2 = new Series(); series2.LegendText = "Re-Quotes"; series2.ArgumentDataMember = "Customer"; series2.ValueDataMembers[0] = "ReQuotes"; series2.ChangeView(DevExpress.XtraCharts.ViewType.Bar); // Add series to chart _chartControl.Series.Add(series1); _chartControl.Series.Add(series2); // Add title to chart ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "Type of Requests by Customers"; _chartControl.Titles.Add(chartTitle); }
private void loadDanhMuc() { //WebChartControl WebChartControl = new WebChartControl(); // Add the chart to the form. // Note that a chart isn't initialized until it's added to the form's collection of controls. //this.Controls.Add(WebChartControl); // Create a new bar series. Series series = new Series("Sản lượng khách hàng", ViewType.Bar); // Add the series to the chart. WebChartControl1.Series.Add(series); // Specify the series data source. DataTable seriesData = GetData(); int max = Convert.ToInt32(seriesData.AsEnumerable().Max(row => row["Sales"])); if (max == 0) { max = 500; } series.DataSource = seriesData; ChartTitle ct = new ChartTitle(); ct.Text = "THỐNG KÊ SẢN LƯỢNG KHÁCH HÀNG"; WebChartControl1.Titles.Add(ct); // Specify an argument data member. series.ArgumentDataMember = "Region"; // Specify a value data member. series.ValueDataMembers.AddRange(new string[] { "Sales" }); // Rotate the diagram (if necessary). ((XYDiagram)WebChartControl1.Diagram).Rotated = false; ((XYDiagram)WebChartControl1.Diagram).AxisY.Range.SetMinMaxValues(0, max * 1.25); ((XYDiagram)WebChartControl1.Diagram).AxisY.Label.EndText = "kWh"; }
/// <summary> /// 获取到所有的数据 /// </summary> /// <returns></returns> private void BindingAllData() { ChartTitle ct = new ChartTitle(); ct.Text = "所有调用次数统计"; chart.Titles.Clear(); chart.Titles.Add(ct); chart.SeriesTemplate.View = new PieSeriesView(); Series series1 = new Series("Line Series 1", ViewType.Pie); DataTable dt = aas.GetCallNumAnalyseData(); for (int i = 0; i < dt.Rows.Count; i++) { string title = dt.Rows[i]["BusinessFullName"].ToString(); double num = double.Parse(dt.Rows[i]["NUM"].ToString()); series1.Points.Add(new SeriesPoint(title, new double[] { num })); } ((PieSeriesLabel)series1.Label).Position = PieSeriesLabelPosition.Outside; ((PiePointOptions)series1.PointOptions).PointView = PointView.Values; ((PiePointOptions)series1.PointOptions).PercentOptions.ValueAsPercent = true; ((PiePointOptions)series1.PointOptions).ValueNumericOptions.Format = NumericFormat.Percent; ((PiePointOptions)series1.PointOptions).ValueNumericOptions.Precision = 0; series1.LegendPointOptions.PointView = PointView.ArgumentAndValues; series1.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.FixedPoint; series1.LegendPointOptions.ValueNumericOptions.Precision = 0; ((PiePointOptions)series1.LegendPointOptions).PercentOptions.ValueAsPercent = false; chart.Series.Add(series1); }
private void btnSearch_Click(object sender, EventArgs e) { try { string query = "select Name as 'المندوب',sum(Busy_Duration)/60 as 'المدة' from attendance where Delegate_ID is not null and attendance.Absence_Date is NULL and Error=0 and DATE_FORMAT(Attendance_Date,'%Y-%m-%d') between '" + this.dateTimePicker1.Value.ToString("yyyy-MM-dd") + "' and '" + this.dateTimePicker2.Value.ToString("yyyy-MM-dd") + "' group by Delegate_ID"; MySqlDataAdapter da = new MySqlDataAdapter(query, dbconnection); DataTable dt = new DataTable(); da.Fill(dt); series.DataSource = dt; chartControl1.Series.Clear(); chartControl1.Series.Add(series); if (!loaded) { ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "تقرير الاشغال"; chartTitle1.TextColor = Color.DarkBlue; chartTitle1.Alignment = StringAlignment.Center; chartControl1.Titles.Add(chartTitle1); loaded = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frmViewChart_Load(object sender, EventArgs e) { // Create an empty chart ChartControl barChart = new ChartControl(); // Create the first side-by-side bar series and add points to it. Series series1 = new Series("Gross Amount Series ", ViewType.Bar); for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++) { series1.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["GrossAmount"], ds_takeQryData.Tables[0].Rows[i]["GrossAmount"])); } //series1.Points.Add(new SeriesPoint("A", new double[] { 10 })); //series1.Points.Add(new SeriesPoint("B", new double[] { 12 })); //series1.Points.Add(new SeriesPoint("C", new double[] { 14 })); //series1.Points.Add(new SeriesPoint("D", new double[] { 17 })); // Create the second side-by-side bar series and add points to it. Series series2 = new Series("Unit Price Series ", ViewType.Bar); for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++) { series2.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["UnitPrice"], ds_takeQryData.Tables[0].Rows[i]["UnitPrice"])); } //series2.Points.Add(new SeriesPoint("A", new double[] { 15 })); //series2.Points.Add(new SeriesPoint("B", new double[] { 18 })); //series2.Points.Add(new SeriesPoint("C", new double[] { 25 })); //series2.Points.Add(new SeriesPoint("D", new double[] { 33 })); // Create the second side-by-side bar series and add points to it. Series series3 = new Series("Net Amount Series ", ViewType.Bar); for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++) { series3.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["NetAmount"], ds_takeQryData.Tables[0].Rows[i]["NetAmount"])); } // Add the series to the chart barChart.Series.Add(series1); barChart.Series.Add(series2); barChart.Series.Add(series3); // Hide the legend (if necessary). //sideBySideBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; // Rotate the diagram (if necessary). //((XYDiagram)sideBySideBarChart.Diagram).Rotated = true; // Add a title to the chart (if necessary). ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "Babar Medicine Company Bar Chart"; barChart.Titles.Add(chartTitle1); // Add the chart to the form. barChart.Dock = DockStyle.Fill; this.Controls.Add(barChart); barChart.BringToFront(); }
public override Control Generete() { var grafico = new ChartControl(); var pathbaseControlXml = string.Format( @"panel de control/basecontrol/{0}", XmlDocument.SelectSingleNode("control").Attributes["baseControl"].Value); grafico.LoadFromFile(Path.Combine(Application.StartupPath, pathbaseControlXml)); grafico.Location = Location; grafico.Size = Size; //grafico.BackColor = Color.Transparent; grafico.Text = DatasourceDetail; var title = new ChartTitle { Text = this.Title }; grafico.Titles.Add(title); title = new ChartTitle { Text = this.DatasourceDetail, Visible = false }; grafico.Titles.Add(title); Control = grafico; return grafico; }
/// <summary> /// 绑定到按服务细分的数据 /// </summary> /// <returns></returns> private void BindingDataByService() { chart.DataSource = aas.GetCallNumAnalyseDataByService(); ChartTitle ct = new ChartTitle(); ct.Text = "服务调用总体情况"; chart.Titles.Clear(); chart.Titles.Add(ct); chart.Series.Clear(); chart.SeriesDataMember = "ServiceName"; chart.SeriesTemplate.View = new StackedBarSeriesView(); chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "NUM" }); chart.SeriesTemplate.ArgumentDataMember = "BusinessName"; chart.SeriesTemplate.PointOptions.PointView = PointView.Values; chart.SeriesTemplate.PointOptions.ValueNumericOptions.Format = NumericFormat.General; chart.SeriesNameTemplate.BeginText = "服务:"; chart.DataBind(); }
/// <summary> /// 绑定到按服务细分的数据 /// </summary> /// <returns></returns> private void BindingDataByService() { chart.DataSource = aas.GetResTimeAnalyseData(); ChartTitle ct = new ChartTitle(); ct.Text = "按服务细分的调用次数统计"; chart.Titles.Clear(); chart.Titles.Add(ct); chart.Series.Clear(); chart.SeriesDataMember = "MethodName"; chart.SeriesTemplate.View = new StackedBarSeriesView(); chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "ResTimeAvg" }); chart.SeriesTemplate.ArgumentDataMember = "ServiceName"; chart.SeriesTemplate.PointOptions.PointView = PointView.Values; chart.SeriesTemplate.PointOptions.ValueNumericOptions.Format = NumericFormat.General; chart.SeriesNameTemplate.BeginText = "服务方法:"; ((XYDiagram)chart.Diagram).AxisX.Label.Angle = 30; ((XYDiagram)chart.Diagram).Rotated = true; chart.DataBind(); }
private void show_graphic_fc_ms() { ClearChart(); int[] a = this.gridView1.GetSelectedRows(); //传递实体类过去 获取选中的行 string fd = this.gridView1.GetRowCellValue(a[0], "first_delay").ToString();//获取选中行的内容 string lr = this.gridView1.GetRowCellValue(a[0], "leak_rate").ToString();//获取选中行的内容 string bs = this.gridView1.GetRowCellValue(a[0], "bucket_size").ToString();//获取选中行的内容 string len = this.gridView1.GetRowCellValue(a[0], "down_total_len").ToString();//获取选中行的内容 string pr = this.gridView1.GetRowCellValue(a[0], "down_packet_rate").ToString();//获取选中行的内容 string times = this.gridView1.GetRowCellValue(a[0], "fcm_time").ToString();//获取选中行的内容 string callid = this.gridView1.GetRowCellValue(a[0], "BeginFrameNum").ToString();//获取选中行的内容 var arrfd = fd.Split(','); var arrlr = lr.Split(','); var arrbs = bs.Split(','); var arrlen = len.Split(','); var arrpr = pr.Split(','); var arrts = times.Split(','); textBox7.Text = "Callid=" + callid; textBox1.Text = "first_delay(flow-control-ms发送时间序列second):平均值=" + arrfd.Where(e => e != "").Average(e => double.Parse(e)).ToString("f1") + "," + "最大值=" + arrfd.Where(e => e != "").Max(e => double.Parse(e)).ToString("f1") + "," + "最小值" + arrfd.Where(e => e != "").Min(e => double.Parse(e)).ToString("f1") + "," + "时间序列=" + fd; textBox2.Text = "leak_rate(flow-control-ms参数值kbps):平均值=" + arrlr.Where(e => e != "").Average(e => double.Parse(e)).ToString("f1") + "," + "最大值=" + arrlr.Where(e => e != "").Max(e => double.Parse(e)).ToString("f1") + "," + "最小值" + arrlr.Where(e => e != "").Min(e => double.Parse(e)).ToString("f1") + "," + "时间序列=" + lr; textBox3.Text = "bucket_size(flow-control-ms参数值Kbyte):平均值=" + arrbs.Where(e => e != "").Average(e => double.Parse(e)).ToString("f1") + "," + "最大值=" + arrbs.Where(e => e != "").Max(e => double.Parse(e)).ToString("f1") + "," + "最小值" + arrbs.Where(e => e != "").Min(e => double.Parse(e)).ToString("f1") + "," + "时间序列=" + bs; textBox4.Text = "down_total_len(flow-control-ms之间MS下行包总长度Kbyte):平均值=" + arrlen.Where(e => e != "").Average(e => double.Parse(e)).ToString("f1") + "," + "最大值=" + arrlen.Where(e => e != "").Max(e => double.Parse(e)).ToString("f1") + "," + "最小值" + arrlen.Where(e => e != "").Min(e => double.Parse(e)).ToString("f1") + "," + "时间序列=" + len; textBox5.Text = "fcm_time(flow-control-ms发送时间间隔second):平均值=" + arrts.Where(e => e != "").Average(e => double.Parse(e)).ToString("f1") + "," + "最大值=" + arrts.Where(e => e != "").Max(e => double.Parse(e)).ToString("f1") + "," + "最小值" + arrts.Where(e => e != "").Min(e => double.Parse(e)).ToString("f1") + "," + "时间序列=" + times; textBox6.Text = "down_packet_rate(flow-control-ms之间MS下行速率kbps):平均值=" + arrpr.Where(e => e != "").Average(e => double.Parse(e)).ToString("f1") + "," + "最大值=" + arrpr.Where(e => e != "").Max(e => double.Parse(e)).ToString("f1") + "," + "最小值" + arrpr.Where(e => e != "").Min(e => double.Parse(e)).ToString("f1") + "," + "时间序列=" + pr; Series series1 = new Series("leak_rate(kbps)", ViewType.Line); Series series4 = new Series("down_packet_rate(kbps)", ViewType.Line); Series series2 = new Series("bucket_size(KByte)", ViewType.Line); Series series3 = new Series("down_total_len(KByte)", ViewType.Line); Series series5 = new Series("fcm_time(seconds)", ViewType.Line); double x, y, z, m, n, k; for (int i = 0; i < arrfd.Count(); i++) { x = double.Parse(arrfd[i]); y = double.Parse(arrlr[i]); z = double.Parse(arrbs[i]); m = double.Parse(arrlen[i]); n = double.Parse(arrpr[i]); k = double.Parse(arrts[i]); series1.Points.Add(new SeriesPoint(x, y)); series2.Points.Add(new SeriesPoint(x, z)); series3.Points.Add(new SeriesPoint(x, m)); series4.Points.Add(new SeriesPoint(x, n)); series5.Points.Add(new SeriesPoint(x, k)); } chartControl1.Series.Add(series1); chartControl1.Series.Add(series4); chartControl1.Series.Add(series3); chartControl1.Series.Add(series2); chartControl1.Series.Add(series5); ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Antialiasing = true; chartTitle1.Font = new Font("Tahoma", 12, FontStyle.Bold); chartTitle1.Text = string.Format("Callid={0} down_packet_rate和FLOW-CONTROL-MS的Bucket_Size、Leak_Rate时间走势", callid); chartControl1.Titles.Add(chartTitle1); series1.Label.Visible = true; series2.Label.Visible = true; series3.Label.Visible = true; series4.Label.Visible = true; series5.Label.Visible = true; //chartControl1.Legend.TextColor = series1.Label.LineColor; chartControl1.Legend.Antialiasing = true; chartControl1.Legend.Font = new Font("Tahoma", 10, FontStyle.Bold); XYDiagram diagram = (XYDiagram)chartControl1.Diagram; // Customize the appearance of the Y-axis title. diagram.AxisY.Title.Visible = true; diagram.AxisY.Title.Alignment = StringAlignment.Center; diagram.AxisY.Title.Text = "kbps"; diagram.AxisY.Title.TextColor = Color.Blue; diagram.AxisY.Title.Antialiasing = true; diagram.AxisY.Title.Font = new Font("Tahoma", 10, FontStyle.Bold); diagram.AxisX.Visible = false; // Add secondary axes to the diagram, and adjust their options. diagram.SecondaryAxesX.Add(new SecondaryAxisX("My Axis X")); diagram.SecondaryAxesY.Add(new SecondaryAxisY("My Axis Y")); diagram.SecondaryAxesX[0].Alignment = AxisAlignment.Near; diagram.SecondaryAxesY[0].Alignment = AxisAlignment.Near; // Add a new additional pane to the diagram. diagram.Panes.Add(new XYDiagramPane("My Pane")); // Assign both the additional pane and, if required, // the secondary axes to the second series. LineSeriesView myView = (LineSeriesView)series2.View; myView.AxisX = diagram.SecondaryAxesX[0]; myView.AxisY = diagram.SecondaryAxesY[0]; // Note that the created pane has the zero index in the collection, // because the existing Default pane is a separate entity. myView.Pane = diagram.Panes[0]; // Assign both the additional pane and, if required, // the secondary axes to the second series. myView = (LineSeriesView)series3.View; myView.AxisX = diagram.SecondaryAxesX[0]; myView.AxisY = diagram.SecondaryAxesY[0]; // Note that the created pane has the zero index in the collection, // because the existing Default pane is a separate entity. myView.Pane = diagram.Panes[0]; // Customize the appearance of the Y-axis title. myView.AxisY.Title.Visible = true; myView.AxisY.Title.Alignment = StringAlignment.Center; myView.AxisY.Title.Text = "KByte"; myView.AxisY.Title.TextColor = Color.Blue; myView.AxisY.Title.Antialiasing = true; myView.AxisY.Title.Font = new Font("Tahoma", 10, FontStyle.Bold); myView.AxisX.Visible = false; // Add secondary axes to the diagram, and adjust their options. diagram.SecondaryAxesX.Add(new SecondaryAxisX("My Axis X1")); diagram.SecondaryAxesY.Add(new SecondaryAxisY("My Axis Y1")); diagram.SecondaryAxesX[1].Alignment = AxisAlignment.Near; diagram.SecondaryAxesY[1].Alignment = AxisAlignment.Near; // Add a new additional pane to the diagram. diagram.Panes.Add(new XYDiagramPane("My Pane1")); // Assign both the additional pane and, if required, // the secondary axes to the second series. LineSeriesView myView1 = (LineSeriesView)series5.View; myView1.AxisX = diagram.SecondaryAxesX[1]; myView1.AxisY = diagram.SecondaryAxesY[1]; // Note that the created pane has the zero index in the collection, // because the existing Default pane is a separate entity. myView1.Pane = diagram.Panes[1]; // Customize the appearance of the Y-axis title. myView1.AxisY.Title.Visible = true; myView1.AxisY.Title.Alignment = StringAlignment.Center; myView1.AxisY.Title.Text = "second"; myView1.AxisY.Title.TextColor = Color.Blue; myView1.AxisY.Title.Antialiasing = true; myView1.AxisY.Title.Font = new Font("Tahoma", 10, FontStyle.Bold); // Customize the appearance of the X-axis title. myView1.AxisX.Title.Visible = true; myView1.AxisX.Title.Alignment = StringAlignment.Center; myView1.AxisX.Title.Text = "FLOW-CONTROL-MS delay(seconds)"; myView1.AxisX.Title.TextColor = Color.Red; myView1.AxisX.Title.Antialiasing = true; myView1.AxisX.Title.Font = new Font("Tahoma", 10, FontStyle.Bold); myView1.AxisX.Label.Staggered = true; // Customize the layout of the diagram's panes. diagram.PaneDistance = 10; diagram.PaneLayoutDirection = PaneLayoutDirection.Vertical; diagram.DefaultPane.SizeMode = PaneSizeMode.UseWeight; diagram.DefaultPane.Weight = 1.2; diagram.SecondaryAxesY[0].LogarithmicBase = 2; diagram.SecondaryAxesY[0].Logarithmic = true; diagram.AxisY.LogarithmicBase = 2; diagram.AxisY.Logarithmic = true; //SecondaryAxisY myAxisY = new SecondaryAxisY("my Y-Axis"); //myAxisY.Title.Text="KByte"; //diagram.SecondaryAxesY.Add(myAxisY); //((LineSeriesView)series2.View).AxisY = myAxisY; //diagram.SecondaryAxesY.Add(myAxisY); //((PointSeriesView)series5.View).AxisY = myAxisY; //this.xtraTabPage3.Controls.Add(chartControl1); //this.Controls.Add(chartControl1); //series1.Points.Clear(); //series2.Points.Clear(); }
void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation, bool ajax) { List<Interval> _intervals = new List<Interval>(); if (interval == IntervalType.Day || interval == IntervalType.Week) { // Day by day or week by week for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++) { _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1))); } } if (interval == IntervalType.Month) { for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++) { _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1))); } } if (interval == IntervalType.Year) { for (int i = 0; i < to.Year - from.Year + 1; i++) { _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddYears(i), new DateTime(from.Year, from.Month, 1).AddYears(i + 1).AddDays(-1))); } } //foreach (Interval ii in _intervals) //{ // Response.Write(ii.Start); // Response.Write(" - "); // Response.Write(ii.End); // Response.Write("<br>"); //} // Draw chart here item by item in _intervals WebChartControl chart = new WebChartControl(); if (!ajax) { chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = "Graf dle " + ddlYGroupBy.SelectedItem.Text.ToLower() + ":"; title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; } Dictionary<int, Series> series = new Dictionary<int, Series>(); List<bool> seriesVisibilities = new List<bool>(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString)) { conn.Open(); List<string> seriesNames = new List<string>(); List<string> seriesCriteria = new List<string>(); int k = 0; Culture = "cs-CZ"; // Create series using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; StringBuilder text = new StringBuilder(""); #warning extract to function if (ddlYFilterType.SelectedIndex > 0) { if (_filerYValues.Count > 0) { text.Append(" AND ("); // Y Filter int i = 0; foreach (string s in _filerYValues) { text.Append(ddlYFilterType.SelectedValue); text.Append(" = '"); text.Append(s); text.Append("' "); if (i < _filerYValues.Count - 1) { text.Append("OR "); } i++; } text.Append(") "); } } string top = ""; if (chbTop.Checked) { int tp = Convert.ToInt32(txtTop.Text); if (!ajax) { tp += 1; } top = "TOP " + tp; } cmd.CommandText = string.Format("SELECT {2} {0}, {0} AS Value FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End {1} GROUP BY {0} ORDER BY Sum(CAST(replace(TurnoverEUR, ',', '.') as Decimal)) DESC", ddlYGroupBy.SelectedValue, text, top); cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (ddlYGroupBy.SelectedValue == "ReselerGroupJoined") { seriesNames.Add(reader[1].ToString().Trim() == "" ? "NO-NAME" : reader[1].ToString()); } else { seriesNames.Add(reader[1].ToString().Trim() == "" ? "(neuvedeno)" : reader[1].ToString()); } if (!ajax) { Series s; if (rblValueDisplayMode.SelectedValue == "2" || ddlXValueType.SelectedValue == "Data") { s = new Series(reader[1].ToString(), ViewType.StackedBar); } else { s = new Series(reader[1].ToString(), ViewType.Line); } s.ValueScaleType = ScaleType.Numerical; if (ddlXValueType.SelectedValue == "Time") { s.ArgumentScaleType = ScaleType.DateTime; } if (ddlXValueType.SelectedValue == "Data") { s.ArgumentScaleType = ScaleType.Qualitative; } if (ddlYValueType.SelectedValue == "4") { if (rblValueDisplayMode.SelectedValue != "2") { s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; } if (rblValueDisplayMode.SelectedValue == "2") { s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; } } //s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; seriesCriteria.Add(reader[0].ToString()); seriesVisibilities.Add(false); series.Add(k, s); k++; } } reader.Close(); } // Draw series // By Time // Enumerate series here and send them via ajax if (ajax) { lbYHaving.Items.Clear(); lbYHaving.Items.Add(allValues); foreach (string s in seriesNames) { lbYHaving.Items.Add(s); } DataBind(lbYHaving); return; } if (ddlXValueType.SelectedValue == "Time") { foreach (Interval i in _intervals) { for (int j = 0; j < seriesNames.Count; j++) { using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesCriteria[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) })); seriesVisibilities[j] = true; } } dr.Close(); } } } } if (ddlXValueType.SelectedValue == "Data") { using (SqlCommand command_data = new SqlCommand()) { command_data.Connection = conn; command_data.CommandText = "SELECT DISTINCT " + ddlXGroupByData.SelectedValue + " FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End"; command_data.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); command_data.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = command_data.ExecuteReader(); List<string> xData = new List<string>(); while (reader.Read()) { xData.Add(reader[0].ToString()); } reader.Close(); foreach(string xd in xData) { for (int j = 0; j < seriesNames.Count; j++) { using (SqlCommand command = GenerateReportCommandByData(xd, seriesCriteria[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(xd, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(xd, new double[] { Convert.ToDouble(dr[0]) })); seriesVisibilities[j] = true; } } dr.Close(); } } } } } } int l = 0; object yHaving = Request[lbYHaving.ClientID.Replace('_', '$')]; if (yHaving == null) { yHaving = allValues; } lbYHaving.Items.Clear(); if (yHaving.ToString() != allValues) { { for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i]) { lbYHaving.Items.Add(series[i].Name); foreach (string s in yHaving.ToString().Split(',')) { if (s == series[i].Name) { lbYHaving.Items[l].Selected = true; seriesVisibilities[i] = true; break; } else { seriesVisibilities[i] = false; } } l++; } } } } else { for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i] && yHaving.ToString() != allValues) { lbYHaving.Items.Add(series[i].Name); } } } lbYHaving.Items.Insert(0, allValues); if (yHaving.ToString() == allValues) { lbYHaving.Items[0].Selected = true; } // Other for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i]) { if (seriesVisibilities[i] && yHaving.ToString() == allValues) { lbYHaving.Items.Add(series[i].Name); } chart.Series.Add(series[i]); } } #region Compute sum Series suma = new Series("Suma", ViewType.Line); suma.ValueScaleType = ScaleType.Numerical; suma.ArgumentScaleType = ScaleType.DateTime; if (ddlYValueType.SelectedValue == "4") { if (rblValueDisplayMode.SelectedValue != "2") { suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; } if (rblValueDisplayMode.SelectedValue == "2") { suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; } } DataTable grid = new DataTable(); string xArgumentName = ddlXValueType.SelectedItem.Text + " - dle "; if (ddlXValueType.SelectedValue == "Time") { xArgumentName += ddlXGroupByTime.SelectedItem.Text.ToLower(); } else { xArgumentName += ddlXGroupByData.SelectedItem.Text.ToLower(); } grid.Columns.Add(new DataColumn(xArgumentName)); for (int i = 0; i < chart.Series.Count; i++) { grid.Columns.Add(new DataColumn(chart.Series[i].Name)); } double sum; for (int j = 0; j < chart.Series[0].Points.Count; j++) { sum = 0; DataRow dr = grid.NewRow(); if (ddlXValueType.SelectedValue == "Time") { dr[0] = Convert.ToDateTime(chart.Series[0].Points[j].Argument).ToString("dd.MM.yyyy"); } else { dr[0] = chart.Series[0].Points[j].Argument; } for (int i = 0; i < chart.Series.Count; i++) { dr[i+1] = chart.Series[i].Points[j].Values[0]; sum += chart.Series[i].Points[j].Values[0]; } grid.Rows.Add(dr); suma.Points.Add(new SeriesPoint(chart.Series[0].Points[j].Argument, new double[] { sum })); // Percent if (rblValueDisplayMode.SelectedValue == "2") { for (int i = 0; i < chart.Series.Count; i++) { if (sum == 0) { chart.Series[i].Points[j].Values[0] = 0; } else { chart.Series[i].Points[j].Values[0] = Math.Round(((chart.Series[i].Points[j].Values[0] / sum) * 1), 2); } } } if (rblValueDisplayMode.SelectedValue == "3") { if (j > 0) { for (int i = 0; i < chart.Series.Count; i++) { chart.Series[i].Points[j].Values[0] = chart.Series[i].Points[j].Values[0] - chart.Series[i].Points[j - 1].Values[0]; } } else { for (int i = 0; i < chart.Series.Count; i++) { chart.Series[i].Points[j].Values[0] = 0; } } } } suma.View.Color = System.Drawing.Color.Black; series.Add(series.Count, suma); if (rblValueDisplayMode.SelectedValue == "1") { chart.Series.Add(series[series.Count - 1]); } if (chbShowSum.Checked && rblValueDisplayMode.SelectedValue == "1" && ddlXValueType.SelectedValue == "Time") { int toBeRemoved = chart.Series.Count - 1; for (int j = 0; j < toBeRemoved; j++) { chart.Series.RemoveAt(0); } } // Show grid DataRow drSum = grid.NewRow(); for(int i = 1; i < grid.Columns.Count; i++) { double dSum = 0; for (int j = 0; j < grid.Rows.Count; j++) { dSum += Convert.ToDouble(grid.Rows[j][i]); } drSum[i] = dSum; } grid.Columns.Add(new DataColumn("Součet za svislou osu")); for (int i = 0; i < grid.Rows.Count; i++) { double dSum = 0; for (int j = 1; j < grid.Columns.Count - 1; j++) { dSum += Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]); } if (rblValueDisplayMode.SelectedValue == "2") { for (int j = 1; j < grid.Columns.Count - 1; j++) { if (dSum == 0) { grid.Rows[i][j] = "0"; } else { grid.Rows[i][j] = (Math.Round(Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]) / dSum, 4) * 100).ToString() + " %"; } } } grid.Rows[i][grid.Columns[grid.Columns.Count-1]] = dSum; } grid.Rows.Add(drSum); grid.Rows[grid.Rows.Count - 1][0] = "Součet za vodorovnou osu"; gvGrid.DataSource = grid; gvGrid.DataBind(); #endregion #region Customize chart DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); if (ddlYValueType.SelectedIndex == 0) { xyDiagram.AxisY.Title.Text = "EUR"; } if (ddlYValueType.SelectedIndex == 1) { xyDiagram.AxisY.Title.Text = "Kusů"; } xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; xyDiagram.AxisX.Range.MinValue = from; xyDiagram.AxisX.Range.MaxValue = to; switch (interval) { case IntervalType.Day: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; break; case IntervalType.Week: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; xyDiagram.AxisX.GridSpacingAuto = false; xyDiagram.AxisX.GridSpacing = 7; break; case IntervalType.Month: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; break; case IntervalType.Year: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Year; break; } xyDiagram.EnableZooming = true; chart.Diagram = xyDiagram; chart.Width = Convert.ToInt32(txtScreenWidth.Text) - 50; chart.Height = 602; //chart.Height = Convert.ToInt32(txtScreenHeight.Text) - 230; #endregion chart.DataBind(); pnlGraph.Controls.Add(chart); }
void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation) { List<Interval> _intervals = new List<Interval>(); if (interval == IntervalType.Day || interval == IntervalType.Week) { // Day by day or week by week for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++) { //Response.Write(i + 1); //Response.Write(": "); //Response.Write((i * (int)interval) + 1); //Response.Write(" - "); //Response.Write((i * (int)interval) + 1 + 7); //Response.Write(" | "); //Response.Write(from.AddDays((i * (int)interval) + 1 - 1)); //Response.Write(" - "); //Response.Write(from.AddDays((i * (int)interval) + 1 - 1)); //Response.Write("<br>"); _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1))); } } if (interval == IntervalType.Month) { for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++) { //Response.Write(i + 1); //Response.Write(": "); //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i)); //Response.Write(" - "); //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i+1).AddDays(-1)); //Response.Write("<br>"); _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1))); } } //List<> // Draw chart here item by item in _intervals WebChartControl chart = new WebChartControl(); chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = "pokus"; title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; Dictionary<int, Series> series = new Dictionary<int, Series>(); //foreach (int channelId in channels) //{ // Channel channel = db.Channels.Where(c => c.ChannelId == channelId).FirstOrDefault(); // if (channel == null) continue; // Series s = new Series(channel.ChannelName, ViewType.Line); // s.ValueScaleType = ScaleType.Numerical; // s.ArgumentScaleType = ScaleType.DateTime; // series.Add(channelId, s); //} using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString)) { conn.Open(); List<string> seriesNames = new List<string>(); int k = 0; // Create series using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandText = string.Format("SELECT DISTINCT {0} FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End", ddlYGroupBy.SelectedValue); cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Series s = new Series(reader[0].ToString(), ViewType.Line); s.ValueScaleType = ScaleType.Numerical; s.ArgumentScaleType = ScaleType.DateTime; seriesNames.Add(reader[0].ToString()); series.Add(k, s); k++; } reader.Close(); } // Draw series foreach (Interval i in _intervals) { for (int j = 0; j < seriesNames.Count; j++ ) { using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesNames[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes //Response.Write(dr[0]); //Response.Write(" - "); //Response.Write(dr[1]); //Response.Write("<br>"); if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) })); } } dr.Close(); } } } } foreach (KeyValuePair<int, Series> serie in series) chart.Series.Add(serie.Value); //diagram DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Title.Text = "CZK"; xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; xyDiagram.AxisX.Range.MinValue = from; xyDiagram.AxisX.Range.MaxValue = to; switch (interval) { case IntervalType.Day: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; break; case IntervalType.Week: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; xyDiagram.AxisX.GridSpacingAuto = false; xyDiagram.AxisX.GridSpacing = 7; break; case IntervalType.Month: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; break; } //xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; xyDiagram.EnableZooming = true; chart.Diagram = xyDiagram; chart.Width = 800; chart.Height = 500; chart.DataBind(); pnlGraph.Controls.Add(chart); }
private void _initChart() { this.that.checkShowPointLabels.Checked = true; this.that.chartControlMaster.SeriesTemplate.Label.Visible = true; if (this.that.pivotGridMaster.Cells.Selection.X == 0 && this.that.pivotGridMaster.Cells.Selection.Y == 0 && this.that.pivotGridMaster.Cells.Selection.Width == 0 && this.that.pivotGridMaster.Cells.Selection.Height == 0) { this.that.pivotGridMaster.OptionsChartDataSource.SelectionOnly = false; } else { this.that.pivotGridMaster.OptionsChartDataSource.SelectionOnly = true; } this.that.ceChartDataVertical.Checked = true; this.that.pivotGridMaster.OptionsChartDataSource.ChartDataVertical = this.that.ceChartDataVertical.Checked; if (this.that.chartControlMaster.Titles.Count == 0) { ChartTitle title = new ChartTitle(); title.Text = this.GetTenBaoCao(); this.that.chartControlMaster.Titles.Add(title); } this.that.chartControlMaster.SeriesDataMember = "Series"; this.that.chartControlMaster.SeriesTemplate.ArgumentDataMember = "Arguments"; this.that.chartControlMaster.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Values" }); this.that.chartControlMaster.SeriesTemplate.LegendPointOptions.PointView = PointView.ArgumentAndValues; this.that.chartControlMaster.DataSource = this.that.pivotGridMaster; this.that.chartControlMaster.SeriesTemplate.ChangeView((ViewType)this.that.comboChartType.SelectedItem); PopupChartOption._setScrollAndZoom(this.that.chartControlMaster); }
private void CreateStatisticTheme(string LayerName) { //创建组 string GroupName = "统计专题_" + LayerName; int GroupID = Program.sgworld.ProjectTree.CreateGroup(GroupName); //根据获取的位置及表中的值建立 if (StaThemePos != null) { this.progressBarControl1.Properties.Minimum = 0; this.progressBarControl1.Properties.Maximum = StaThemePos.Count; this.progressBarControl1.Properties.Step = 1; this.progressBarControl1.Position = 0; for (int i = 0; i < StaThemePos.Count; i++) { //根据图表类型获取字段值根据设置生成图像 #region ChartControl Chart3D = new ChartControl(); ChartTitle chartTitle1 = new ChartTitle(); Chart3D.Titles.Add(chartTitle1); string AValue = ""; switch (this.comboBoxChartType.Text) { case "柱状图": //每个字段对应一个Series,字段名以及该要素该字段的值构成一个Point foreach (DataGridViewRow ARow in this.dataGridView3.Rows) { Series Aseries = new Series("Aseries", ViewType.Bar3D); AValue = this.dataGridView4.Rows[i].Cells[ARow.Cells[1].Value.ToString()].Value.ToString(); Aseries.Points.Add(new SeriesPoint(ARow.Cells[1].Value.ToString(), Convert.ToDouble(AValue))); Chart3D.Series.Add(Aseries); ((BarSeriesLabel)Aseries.Label).Visible = true; Font myFont = new Font(new FontFamily("宋体"),20); ((BarSeriesLabel)Aseries.Label).Font = myFont; ((BarSeriesLabel)Aseries.Label).BackColor = Color.FromArgb(0, 0, 0, 0); ((BarSeriesLabel)Aseries.Label).Border.Visible = false; ((BarSeriesLabel)Aseries.Label).TextColor = Color.Black; ((BarSeriesLabel)Aseries.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default; Aseries.PointOptions.PointView = PointView.ArgumentAndValues; //是否勾选百分比 //if (this.checkPercent.Checked) // Aseries.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; ((Bar3DSeriesView)Aseries.View).Model = Bar3DModel.Cylinder; //修改柱状体颜色 ((Bar3DSeriesView)Aseries.View).Color = ARow.Cells[0].Style.BackColor; ((XYDiagram3D)Chart3D.Diagram).AxisX.GridLines.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisX.Label.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisY.GridLines.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisY.Label.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisY.Interlaced = false; ((XYDiagram3D)Chart3D.Diagram).BackColor = Color.FromArgb(0, 0, 0, 0); } break; case "堆叠柱状图": //每个字段对应一个Series,每个Series一个Point,Argument值相同,Value值对应各字段值,起码2个Series才有堆叠效果 foreach (DataGridViewRow ARow in this.dataGridView3.Rows) { Series Aseries = new Series("Aseries", ViewType.StackedBar3D); AValue = this.dataGridView4.Rows[i].Cells[ARow.Cells[1].Value.ToString()].Value.ToString(); Aseries.Points.Add(new SeriesPoint(this.dataGridView4.Rows[i].Cells[0].Value.ToString(), Convert.ToDouble(AValue))); Chart3D.Series.Add(Aseries); ((BarSeriesLabel)Aseries.Label).Visible = true; Font myFont = new Font(new FontFamily("宋体"), 20); ((BarSeriesLabel)Aseries.Label).Font = myFont; ((BarSeriesLabel)Aseries.Label).BackColor = Color.FromArgb(0, 0, 0, 0); ((BarSeriesLabel)Aseries.Label).Border.Visible = false; ((BarSeriesLabel)Aseries.Label).TextColor = Color.Black; ((BarSeriesLabel)Aseries.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default; Aseries.PointOptions.PointView = PointView.ArgumentAndValues; //是否勾选百分比 //if (this.checkPercent.Checked) // Aseries.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; ((Bar3DSeriesView)Aseries.View).Model = Bar3DModel.Cylinder; //修改柱状体颜色 ((Bar3DSeriesView)Aseries.View).Color = ARow.Cells[0].Style.BackColor; ((XYDiagram3D)Chart3D.Diagram).AxisX.GridLines.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisX.Label.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisY.GridLines.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisY.Label.Visible = false; ((XYDiagram3D)Chart3D.Diagram).AxisY.Interlaced = false; ((XYDiagram3D)Chart3D.Diagram).BackColor = Color.FromArgb(0, 0, 0, 0); } break; case "饼图": //每个要素仅含一个Series,每个字段对应一个Point,分别由字段名和字段值组成 Series Aseries1 = new Series("Aseries1", ViewType.Pie3D); Palette Colorlist = new Palette("Colorlist"); foreach (DataGridViewRow ARow in this.dataGridView3.Rows) { AValue = this.dataGridView4.Rows[i].Cells[ARow.Cells[1].Value.ToString()].Value.ToString(); Aseries1.Points.Add(new SeriesPoint(ARow.Cells[1].Value.ToString(), Convert.ToDouble(AValue))); //Aseries1.Points.Add(new SeriesPoint(ARow.Cells[1].Value.ToString(), 50)); Colorlist.Add(ARow.Cells[0].Style.BackColor); } Chart3D.Series.Add(Aseries1); //修改饼颜色 Chart3D.PaletteRepository.Add("Colorlist", Colorlist); Chart3D.PaletteName = "Colorlist"; Chart3D.PaletteBaseColorNumber = 0; ((Pie3DSeriesLabel)Aseries1.Label).Visible = true; Font myFont1 = new Font(new FontFamily("宋体"),10); ((Pie3DSeriesLabel)Aseries1.Label).Font = myFont1; ((Pie3DSeriesLabel)Aseries1.Label).BackColor = Color.FromArgb(0, 0, 0, 0); ((Pie3DSeriesLabel)Aseries1.Label).Border.Visible = false; ((Pie3DSeriesLabel)Aseries1.Label).TextColor = Color.Black; ((Pie3DSeriesLabel)Aseries1.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default; Aseries1.PointOptions.PointView = PointView.ArgumentAndValues; //是否勾选百分比 if (this.checkPercent.Checked) { Aseries1.PointOptions.ValueNumericOptions.Format = DevExpress.XtraCharts.NumericFormat.Percent; Aseries1.PointOptions.ValueNumericOptions.Precision = 1; } break; default: break; } chartTitle1.Text = this.dataGridView4.Rows[i].Cells[0].Value.ToString(); chartTitle1.TextColor = Color.White; chartTitle1.WordWrap = true; Chart3D.BackColor = Color.FromArgb(0, 0, 0, 0); Chart3D.BorderOptions.Visible = false; Chart3D.Size =new Size(400,400); Chart3D.Legend.Visible = false; Chart3D.ExportToImage(Application.StartupPath + "temp_" + i + ".png", System.Drawing.Imaging.ImageFormat.Png); //使图片透明 Bitmap oldbmp = new Bitmap(Application.StartupPath + "temp_" + i + ".png"); Bitmap newbmp = new Bitmap(oldbmp.Width, oldbmp.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); newbmp.MakeTransparent(); for (int x = 0; x != oldbmp.Width; x++) { for (int y = 0; y != oldbmp.Height; y++) { Color AColor = oldbmp.GetPixel(x, y); if (!(AColor.A == 255 & AColor.R == 238 & AColor.G == 238 & AColor.B == 238)) { newbmp.SetPixel(x, y, Color.FromArgb(AColor.A, AColor.R, AColor.G, AColor.B)); } } } newbmp.Save(Application.StartupPath + "temp2_" + i + ".png", System.Drawing.Imaging.ImageFormat.Png); oldbmp.Dispose(); #endregion //创建Label,后删除图片 ILabelStyle61 cLabelStyle = null; ITerrainImageLabel61 cImageLabel = null; //根据设置创建标签风格 SGLabelStyle eLabelStyle = SGLabelStyle.LS_DEFAULT; cLabelStyle = Program.sgworld.Creator.CreateLabelStyle(eLabelStyle); //随图缩放 cLabelStyle.LimitScreenSize = true; //最大可视高度 cLabelStyle.MaxViewingHeight = 50000; //最小可视高度 //cLabelStyle.MinViewingHeight = 10; cLabelStyle.PivotAlignment = "Bottom,Left"; cImageLabel = Program.sgworld.Creator.CreateImageLabel(StaThemePos[i], Application.StartupPath + "temp2_" + i + ".png", cLabelStyle, GroupID, this.dataGridView4.Rows[i].Cells[0].Value.ToString()); File.Delete(Application.StartupPath + "temp_" + i + ".png"); File.Delete(Application.StartupPath + "temp2_" + i + ".png"); System.Windows.Forms.Application.DoEvents(); this.progressBarControl1.PerformStep(); } } }
public void LoadGraph() { int t1 = System.Environment.TickCount; if (_report.State != Report.StateEnum.Executed) return; _chCtrl.BeginInit(); bool rotateGraph = false; bool pivotAxes = ((_report.GraphOptions & OlapReport.GraphOptionsEnum.Pivot) > 0); int seriesPosCount = (pivotAxes ? _report.Cellset.Axis1PosCount : _report.Cellset.Axis0PosCount); int seriesMemCount = (pivotAxes ? _report.Cellset.Axis1TupleMemCount : _report.Cellset.Axis0TupleMemCount); int catPosCount = (pivotAxes ? _report.Cellset.Axis0PosCount : _report.Cellset.Axis1PosCount); int catMemCount = (pivotAxes ? _report.Cellset.Axis0TupleMemCount : _report.Cellset.Axis1TupleMemCount); if (seriesPosCount == 0 || catPosCount == 0) return; Size size = new Size(_report.GraphWidth, _report.GraphHeight); size = this.AdjustGraphWidth(size, _report.GraphType); // limit number of series if (seriesPosCount > __MaxSeriesCount) seriesPosCount = __MaxSeriesCount; if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart) if (seriesPosCount > __MaxPieCount) seriesPosCount = __MaxPieCount; // limit number of categories if (catPosCount > __MaxCategoriesCount) catPosCount = __MaxCategoriesCount; bool showValues = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowValues) > 0; bool showSeries = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowSeries) > 0; bool showCats = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowCategories) > 0; bool setScaling = _report.GraphType != OlapReport.GraphTypeEnum.Pie && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.ScalingBySeries) > 0); bool setPerc = !setScaling && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.PercentByCategories) > 0); byte graphPieColumns = (_report.GraphPieColumns == 0 ? Convert.ToByte(Math.Sqrt(seriesPosCount)) : _report.GraphPieColumns); byte graphMixedLinePos = _report.GraphMixedLinePosition; graphMixedLinePos = (graphMixedLinePos <= 0 || graphMixedLinePos > seriesPosCount ? (byte)1 : graphMixedLinePos); // theme if (_report.GraphTheme != null && _report.GraphTheme != "") _chCtrl.AppearanceName = _report.GraphTheme; // create series for (int i = 0; i < seriesPosCount; i++) { string name = ""; for (int j = 0; j < seriesMemCount; j++) name += (j == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(1, j, i).Name : _report.Cellset.GetCellsetMember(0, j, i).Name); Series series = new Series(); series.Name = name; // type if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart) { // if pie, each of series is displayed as individual graph if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart) _chCtrl.Series.Clear(); _chCtrl.Series.Add(series); series.ChangeView(ViewType.Pie); PiePointOptions ppo = (PiePointOptions)series.PointOptions; PieSeriesView psw = (PieSeriesView)series.View; PieSeriesLabel psl = (PieSeriesLabel)series.Label; psl.Position = PieSeriesLabelPosition.TwoColumns; series.PointOptions.PointView = PointView.Undefined; if (_report.GraphType == OlapReport.GraphTypeEnum.Pie) { SimpleDiagram sd = new SimpleDiagram(); sd.LayoutDirection = LayoutDirection.Horizontal; sd.Dimension = graphPieColumns; _chCtrl.Diagram = sd; } // legend if (showCats) _chCtrl.Legend.Visible = false; series.Label.OverlappingOptions.ResolveOverlapping = true; series.LegendPointOptions.PointView = PointView.Argument; _chCtrl.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center; _chCtrl.Legend.AlignmentVertical = LegendAlignmentVertical.BottomOutside; _chCtrl.Legend.Direction = LegendDirection.LeftToRight; // series title SeriesTitle sTitle = new SeriesTitle(); sTitle.Text = name; sTitle.Alignment = StringAlignment.Center; sTitle.Dock = ChartTitleDockStyle.Bottom; psw.Titles.Add(sTitle); } else { // diagram if (_chCtrl.Diagram == null) _chCtrl.Diagram = new XYDiagram(); XYDiagram diag = (XYDiagram)_chCtrl.Diagram; //// panes //if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars && graphMixedLinePos <= seriesPosCount && diag.Panes.Count == 0) //{ // // add new pane // XYDiagramPane pane = new XYDiagramPane(); // pane.Visible = true; // pane.SizeMode = PaneSizeMode.UseWeight; // pane.Weight = 0.66; // diag.PaneLayoutDirection = PaneLayoutDirection.Vertical; // diag.Panes.Add(pane); // // set default pane weight // diag.DefaultPane.SizeMode = PaneSizeMode.UseWeight; // diag.DefaultPane.Weight = 0.33; //} // add series _chCtrl.Series.Add(series); // add series to secondary pane if needed (in case of LineWithBars) if (diag.Panes.Count > 0 && i != graphMixedLinePos - 1) ((XYDiagramSeriesViewBase)series.View).Pane = diag.Panes[0]; if (_report.GraphType == OlapReport.GraphTypeEnum.BarVertical) { series.ChangeView(ViewType.Bar); } else if (_report.GraphType == OlapReport.GraphTypeEnum.BarHorizontal) { series.ChangeView(ViewType.Bar); rotateGraph = true; } else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarVertical) series.ChangeView(ViewType.StackedBar); else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarHorizontal) { series.ChangeView(ViewType.StackedBar); rotateGraph = true; } else if (_report.GraphType == OlapReport.GraphTypeEnum.LineHorizontal) series.ChangeView(ViewType.Line); else if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars) { if (i == graphMixedLinePos - 1) { //if (!setScaling) //{ // // create secondary axis // SecondaryAxisY axisY = new SecondaryAxisY(series.Name); // axisY.Visible = true; // axisY.Title.Text = series.Name; // axisY.Title.Visible = true; // axisY.Alignment = AxisAlignment.Near; // ((XYDiagram)_chCtrl.Diagram).SecondaryAxesY.Add(axisY); // ((XYDiagramSeriesViewBase)series.View).AxisY = axisY; // // set default axis title // ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Text = "Bar axis"; // ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Visible = true; //} // change view series.ChangeView(ViewType.Line); } else series.ChangeView(ViewType.Bar); } // 20 pixels per label (250 pixels for legend), othervise overlapping resolution will never finish if ((size.Width - 250) / catPosCount > 20) { series.Label.OverlappingOptions.ResolveOverlapping = true; PointOverlappingOptions poo = series.Label.OverlappingOptions as PointOverlappingOptions; if (poo != null) poo.AttractToMarker = true; } series.LegendText = name; series.ShowInLegend = true; series.ValueScaleType = ScaleType.Numerical; series.PointOptions.PointView = PointView.Undefined; series.LegendPointOptions.PointView = PointView.SeriesName; series.Visible = true; // labels orientation diag.Rotated = rotateGraph; if (rotateGraph) { diag.AxisY.Label.Antialiasing = true; diag.AxisY.Label.Angle = 315; } else { diag.AxisX.Label.Antialiasing = true; diag.AxisX.Label.Angle = 315; } // if scaling if (setScaling) diag.AxisY.Visible = false; } // prepare scaling ranges double scalingMin = double.MaxValue; double scalingMax = double.MinValue; if (setScaling) { for (int l = 0; l < catPosCount; l++) { string val = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value); double dVal = 0; double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal); if (dVal < scalingMin) scalingMin = dVal; if (dVal > scalingMax) scalingMax = dVal; } } scalingMin = scalingMin - (scalingMax - scalingMin) * 0.1; // set data double percSum = 0; for (int l = 0; l < catPosCount; l++) { string argument = ""; for (int m = 0; m < catMemCount; m++) argument += (m == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(0, m, l).Name : _report.Cellset.GetCellsetMember(1, m, l).Name); string val = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value); double dVal = 0; double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal); if (setPerc) percSum += dVal; else if (setScaling) dVal = (scalingMax - scalingMin == 0 ? 0 : (dVal - scalingMin) / (scalingMax - scalingMin)); string fVal = (pivotAxes ? _report.Cellset.GetCell(l, i).FormattedValue : _report.Cellset.GetCell(i, l).FormattedValue); SeriesPoint sp = new SeriesPoint(argument, new double[] { dVal }); sp.Tag = fVal; series.Points.Add(sp); } // set custom labels and value as percentage for (int l = 0; l < catPosCount; l++) { SeriesPoint sp = series.Points[l]; if (setPerc) { sp.Values[0] = sp.Values[0] / percSum; sp.Tag = sp.Values[0].ToString("P"); } // custom point label string customLabel = string.Empty; if (!showValues && !showSeries && !showCats) series.Label.Visible = false; else { string fVal = (string)sp.Tag; if (fVal == null || fVal == "") fVal = "0"; customLabel = (showSeries ? series.Name : string.Empty); customLabel += (showCats ? (customLabel != string.Empty ? " | " : string.Empty) + sp.Argument : string.Empty); customLabel += (showValues ? (customLabel != string.Empty ? ": " : string.Empty) + fVal : string.Empty); } series.Points[l].Tag = customLabel; } // for pie, layout each of series individually if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart) { _chCtrl.Titles.Clear(); _chCtrl.EndInit(); LayoutGraph(_report.ID.ToString() + "." + i.ToString(), size, graphPieColumns); // init next chart if (i < seriesPosCount - 1) { _chCtrl = new DevExpress.XtraCharts.Web.WebChartControl(); _chCtrl.BeginInit(); } } } int t2 = System.Environment.TickCount; if (_report.GraphType != OlapReport.GraphTypeEnum.PieBrokenApart) { ChartTitle title = new ChartTitle(); title.Alignment = StringAlignment.Center; title.Lines = new string[] { _report.Name, _report.Description }; _chCtrl.Titles.Add(title); LayoutGraph(_report.ID.ToString(), size, 0); } // if LineWithBars if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars) { // fill combo for (int i = 0; i < _chCtrl.Series.Count; i++) this.selMixedLinePos.Items.Add(new ListItem(_chCtrl.Series[i].Name, (i + 1).ToString())); this.selMixedLinePos.SelectedIndex = graphMixedLinePos - 1; // set line as last if (!(_chCtrl.Series[_chCtrl.Series.Count - 1].View is LineSeriesView)) { // roll down through series for (int i = graphMixedLinePos - 1; i < _chCtrl.Series.Count - 1; i++) _chCtrl.Series.Swap(i, i + 1); } } int t3 = System.Environment.TickCount; double time1 = (t3 - t2) / 1000.0; double time2 = (t2 - t1) / 1000.0; t1 = 0; }
public static void DefineTitleChart(ChartControl chartControl, string title) { ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = title; chartControl.Titles.Add(chartTitle); }
public ChartTitleSerializerTests() { title = new ChartTitle(); }
/// <summary> /// 刷新图表显示 /// </summary> public virtual void Reflush() { this.Titles.Clear(); this.Series.Clear();//清除数据 this.RuntimeSeriesSelectionMode = this.SerSelectionMode; this.RuntimeSelection = EnalbeRuntimeSelection; if (null == (this.SeriesDataSource as DataTable) || (this.SeriesDataSource as DataTable).Rows.Count < 1) { //定义chart标题 ChartTitle cht = new ChartTitle(); cht.Text = ExportName ?? string.Empty; this.Titles.Add(cht); ChartTitle ct2 = new ChartTitle(); ct2.Text = NoDataTipText; ct2.Dock = ChartTitleDockStyle.Bottom; this.Titles.Add(ct2); return; } ////创建相应类型的图表类型 //Series S1 = new Series(ExportName ?? string.Empty, this.ChartViewType); //S1.DataSource = this.SeriesDataSource; ////S1的X轴数据源字段 //S1.ArgumentDataMember = this.ArgumentDataMember; ////S1的Y轴数据源字段 //S1.ValueDataMembers[0] = this.ValueDataMembers; Series[] sers = CreateSeriesByFieldName(FieldOfSeriesName, this.SeriesDataSource as DataTable); if (null == sers || sers.Length < 1) return; foreach (Series S1 in sers) { PointOptions ptopt = S1.PointOptions; ptopt.PointView = PointView.Values; ptopt.Pattern = PointParttern;//图表点数据显示样式 ptopt.ValueNumericOptions.Format = AxisY; ptopt.ValueNumericOptions.Precision = AxisYPrecision; if (null != S1.Label as PointSeriesLabel) (S1.Label as PointSeriesLabel).LineVisible = true; this.Series.Add(S1); //((BarSeriesView)series1.View).BarWidth = 0.07; //保证在显示柱状图的时候当数据项少的时候 不会柱子太宽 BarSeriesView bsv = S1.View as BarSeriesView; if (null != bsv) bsv.BarWidth = MinBarWidth; AdjustPie3D(S1); } //定义chart标题 ChartTitle ct1 = new ChartTitle(); ct1.Text = ExportName ?? string.Empty; this.Titles.Add(ct1); if (null != ChartDiagram) { ChartDiagram.AxisY.Title.Text = AxisYTitle;//设置Y轴说明文字 ChartDiagram.AxisX.Title.Text = AxisXTitle;//设置X轴说明文字 ChartDiagram.AxisY.Title.Visible = !string.IsNullOrEmpty(AxisYTitle); ChartDiagram.AxisX.Title.Visible = !string.IsNullOrEmpty(AxisXTitle); ChartDiagram.AxisX.Label.Visible = AxisXVisiable; ChartDiagram.EnableScrolling = EnableScrolling; ChartDiagram.EnableZooming = EnableZooming; ChartDiagram.AxisX.Label.Angle = AntialiasingValue;//设置X轴斜率 ChartDiagram.AxisX.Label.Antialiasing = Antialiasing;//开启X轴斜率 //ChartDiagram.AxisY.MinorCount = 10; //设置Y轴的间隔 //ChartDiagram.AxisY.Range.Auto = false; //不允许自动设定间隔值 if (null != ChartDiagram.AxisX && null != ChartDiagram.AxisX.Label) ChartDiagram.AxisX.Label.Antialiasing = true; } Adjust3DRoation(); AdjustAxisY(); }
public void DataBinding(IBaseModel datalist) { if (datalist == null) return; if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate() { this.DataBinding(datalist); }); } else { AMR_MST04Model model = new AMR_MST04Model(); model = (AMR_MST04Model)datalist; //gridControl1.DataSource = null; //gridControl1.DataSource = model.DataTable; this.chartControl1.Series[0].Points.BeginUpdate(); this.chartControl1.Series[0].Points.Clear(); foreach (DataRow row in model.DataTable.Rows) { string time = row["TOT00DAT"].ToString(); // 그래프 Y값 추출 DateTime datetime = DateTime.ParseExact(time, "yyyy-MM-dd HH", null); // 센서 값 넣기 //double value = Convert.ToDouble(row.ItemArray[1]); double value = Convert.ToDouble(row["TOT00VALUE"]); //double[] value = new double[] { Convert.ToDouble(row.ItemArray[1]), Convert.ToDouble(row.ItemArray[2]), // Convert.ToDouble(row.ItemArray[3]), Convert.ToDouble(row.ItemArray[4]), Convert.ToDouble(row.ItemArray[5]) }; // 센서별 데이터 넣기 ChartVariable2 chartValue = new ChartVariable2(); chartValue.data = new SeriesPoint(datetime, value); this.chartControl1.Series[0].Points.Add(chartValue.data); } this.chartControl1.Series[0].Points.EndUpdate(); this.chartControl1.Titles.RemoveAt(0); ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = string.Format("{0}동 {1}호 - {2}", model.MST04DON, model.MST04HNO, this.radioGroup1.Text); chartTitle1.Alignment = System.Drawing.StringAlignment.Center; chartTitle1.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Top; this.chartControl1.Titles.Add(chartTitle1); // ChartTitle chartTitle1 = new ChartTitle(); // ChartTitle chartTitle2 = new ChartTitle(); // chartTitle1.Text = "Great Lakes Gross State Product"; // chartTitle2.Alignment = System.Drawing.StringAlignment.Far; // chartTitle2.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Bottom; // chartTitle2.Font = new System.Drawing.Font("Tahoma", 8F); // chartTitle2.Text = "From www.bea.gov"; // chartTitle2.TextColor = System.Drawing.Color.Gray; // this.chartControl1.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] { //chartTitle1, //chartTitle2}); } }
public void Bind() { List<int> channels = this.Channels; List<int> products = this.Products; CanonDataContext db = Cdb.Instance; List<MainMonitor> list = CanonMainMonitor.GetValuesForChart(deStartDate.Date, deFinishDate.Date, channels, products); foreach (int productId in products) { Product product = db.Products.Where(p => p.ProductId == productId).FirstOrDefault(); if (product == null) continue; WebChartControl chart = new WebChartControl(); chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = string.Format(Utilities.GetResourceString("Common", "ChartHeader"), product.ProductName, deStartDate.Date.ToString("dd.MM.yyyy"), deFinishDate.Date.ToString("dd.MM.yyyy")); title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; Dictionary<int, Series> series = new Dictionary<int, Series>(); Series s0 = new Series("Recommended price", ViewType.Line); s0.ValueScaleType = ScaleType.Numerical; s0.ArgumentScaleType = ScaleType.DateTime; series.Add(0, s0); foreach (int channelId in channels) { Channel channel = db.Channels.Where(c=> c.ChannelId==channelId).FirstOrDefault(); if (channel == null) continue; Series s = new Series(channel.ChannelName, ViewType.Line); s.ValueScaleType = ScaleType.Numerical; s.ArgumentScaleType = ScaleType.DateTime; series.Add(channelId, s); } foreach (MainMonitor mm in list) { if (mm.ProductId != productId) continue; series[mm.ChannelId].Points.Add(new SeriesPoint(mm.CalcDate, new double[] { (double)mm.ChannelPrice })); series[0].Points.Add(new SeriesPoint(mm.CalcDate, new double[] { (double)mm.RecommendedPrice })); } foreach (KeyValuePair<int, Series> serie in series) chart.Series.Add(serie.Value); //diagram DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Title.Text = "CZK"; xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; chart.Diagram = xyDiagram; chart.Width = 700; chart.Height = 500; chart.DataBind(); panelPics.Controls.Add(chart); this.FilesToSave.Add(this.SaveChartIntoFile(product.ProductName, chart)); } }
public void LoadGraph() { if(_report.State!=Report.StateEnum.Executed) return; bool rotateGraph=false; bool rotateAxes=((_report.GraphOptions & OlapReport.GraphOptionsEnum.RotateAxes)>0); int seriesPosCount=(rotateAxes ? _report.Cellset.Axis1PosCount: _report.Cellset.Axis0PosCount); int seriesMemCount=(rotateAxes ? _report.Cellset.Axis1TupleMemCount: _report.Cellset.Axis0TupleMemCount); int catPosCount=(rotateAxes ? _report.Cellset.Axis0PosCount: _report.Cellset.Axis1PosCount); int catMemCount=(rotateAxes ? _report.Cellset.Axis0TupleMemCount: _report.Cellset.Axis1TupleMemCount); if(seriesPosCount>256) seriesPosCount=256; if(catPosCount>1024) catPosCount=1024; bool showValues=(_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowValues)>0; bool showSeries=(_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowSeries)>0; bool showCats=(_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowCategories)>0; bool setScaling=(_report.GraphOptions & OlapReport.GraphOptionsEnum.SetScaling)>0; // create series for(int i=0;i<seriesPosCount;i++) { string name=""; for(int j=0; j<seriesMemCount;j++) name+=(j==0 ? "" : " | ")+ (rotateAxes ? _report.Cellset.GetCellsetMember(1, j, i).Name : _report.Cellset.GetCellsetMember(0, j, i).Name); Series series=new Series(); series.Name=name; _chCtrl.Series.Add(series); // type if(_report.GraphType==OlapReport.GraphTypeEnum.Pie) { // limit number of series if(seriesPosCount>6) seriesPosCount=6; // disable scaling for pie setScaling=false; series.ChangeView(ViewType.Pie); PiePointOptions ppo=(PiePointOptions)series.PointOptions; PieSeriesView psw=(PieSeriesView)series.View; PieSeriesLabel psl=(PieSeriesLabel)series.Label; psl.Position=PieSeriesLabelPosition.TwoColumns; series.ShowInLegend=false; // cause it's shown in pie anyway showValues=true; showCats=true; this.chkCat.Checked=true; this.chkCat.Disabled=true; this.chkValues.Checked=true; this.chkValues.Disabled=true; } else { if(_report.GraphType==OlapReport.GraphTypeEnum.BarVertical) { series.ChangeView(ViewType.Bar); } else if(_report.GraphType==OlapReport.GraphTypeEnum.BarHorizontal) { series.ChangeView(ViewType.Bar); rotateGraph=true; } else if(_report.GraphType==OlapReport.GraphTypeEnum.StackedBarVertical) series.ChangeView(ViewType.StackedBar); else if(_report.GraphType==OlapReport.GraphTypeEnum.StackedBarHorizontal) { series.ChangeView(ViewType.StackedBar); rotateGraph=true; } else if(_report.GraphType==OlapReport.GraphTypeEnum.LineHorizontal) series.ChangeView(ViewType.Line); series.LegendText=name; series.ShowInLegend=true; series.ValueScaleType=ScaleType.Numerical; series.Visible=true; // labels orientation XYDiagram diag=(XYDiagram)_chCtrl.Diagram; diag.Rotated=rotateGraph; if(rotateGraph) { diag.AxisY.Label.Antialiasing=true; diag.AxisY.Label.Angle=315; } else { diag.AxisX.Label.Antialiasing=true; diag.AxisX.Label.Angle=315; } // if scaling if(setScaling) diag.AxisY.Visible=false; // if(setScaling) // { // // hide axis, cause it won't display real values // if(seriesPosCount<10) // diag.AxisY.Visible=false; // if(i<10) // { // SecondaryAxisY axisY=new SecondaryAxisY(name); // // axisY.Alignment=AxisAlignment.Near; // axisY.Title.Text = name; // axisY.Title.Visible = true; // axisY.Title.Font=new Font(axisY.Title.Font.Name, 10); // axisY.Label.Antialiasing=true; // axisY.Label.Angle=315; // // diag.SecondaryAxesY.Add(axisY); // ((XYDiagramSeriesViewBase)series.View).AxisY = axisY; // } // } } // prepare scaling ranges double scalingMin=double.MaxValue; double scalingMax=double.MinValue; if(setScaling) { for(int l=0;l<catPosCount;l++) { string val=(rotateAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value); double dVal=0; double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal); if(dVal<scalingMin) scalingMin=dVal; if(dVal>scalingMax) scalingMax=dVal; } } scalingMin=scalingMin-(scalingMax-scalingMin)*0.1; // set data for(int l=0; l<catPosCount;l++) { string argument=""; for(int m=0;m<catMemCount;m++) argument+=(m==0 ? "" : " | ")+ (rotateAxes ? _report.Cellset.GetCellsetMember(0, m, l).Name : _report.Cellset.GetCellsetMember(1, m, l).Name); string val=(rotateAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value); string fVal=(rotateAxes ? _report.Cellset.GetCell(l, i).FormattedValue : _report.Cellset.GetCell(i, l).FormattedValue); double dVal=0; double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal); if(setScaling) dVal=(scalingMax-scalingMin==0 ? 0 : (scalingMin+dVal)/(scalingMax-scalingMin)); // custom point label string customLabel=string.Empty; if(!showValues && !showSeries&& !showCats) series.Label.Visible=false; else { customLabel=(showSeries ? series.Name : string.Empty); customLabel+=(showCats ? (customLabel!=string.Empty ? " | " : string.Empty) + argument : string.Empty); customLabel+=(showValues ? (customLabel!=string.Empty ? ": " : string.Empty) + fVal : string.Empty); } CustomChartSeriesPoint sp=new CustomChartSeriesPoint(argument, dVal, customLabel); series.Points.Add(sp); } } ChartTitle title=new ChartTitle(); title.Alignment=StringAlignment.Center; title.Lines=new string[]{ _report.Name, _report.Description }; _chCtrl.Titles.Add(title); if(_report.GraphTheme!=null && _report.GraphTheme!="") _chCtrl.AppearanceName=_report.GraphTheme; _chCtrl.Width=AdjustGraphSize(_report.GraphWidth); _chCtrl.Height=AdjustGraphSize(_report.GraphHeight); string imgNamePrefix=_report.GetType().Name + _report.ID.ToString(); //delete older images of same report string[] filePaths=System.IO.Directory.GetFiles(FI.Common.AppConfig.TempDir , imgNamePrefix + "*.PNG"); if(filePaths!=null && filePaths.Length>0) for(int j=0;j<filePaths.Length;j++) { try { System.IO.File.Delete(filePaths[j]); } catch(Exception exc) { //do nothing exc=null; } } //write to file and display, it will overwite itself if needed string imgName=imgNamePrefix + "." + DateTime.Now.ToString("yyyyMMddHHssfff") + ".PNG"; string imgVirtPath=Request.ApplicationPath + "/" + FI.Common.AppConfig.TempVirtualDir + "/" + imgName; string imgPhysPath=FI.Common.AppConfig.TempDir + @"\" + imgName; _chCtrl.ExportToImage(imgPhysPath, System.Drawing.Imaging.ImageFormat.Png); System.Web.UI.WebControls.Image img=new System.Web.UI.WebControls.Image(); img.ImageUrl=imgVirtPath; this.cellGraph.Controls.Add(img); }
protected void Button1_Click(object sender, EventArgs e) { string connStr = "Server=127.0.0.1;Database=edit;Trusted_Connection=True;"; string col1 = ""; string col2 = ""; List<double> col1Values = new List<double>(); List<double> col2Values = new List<double>(); WebChartControl1.Titles.Clear(); WebChartControl1.Series.Clear(); if (DropDownList1.SelectedValue.Equals(DropDownList2.SelectedValue)) { Literal1.Text = "The same columns cannot be compared because the correlation is always 100%"; return; } using (SqlConnection conn = new SqlConnection(connStr)) { conn.Open(); // lookup friendlytext, get the real DB column name... using (SqlCommand cmd = new SqlCommand(String.Format("SELECT [DBColumn] FROM [edit].[dbo].[datawarehouseColumnMapping] WHERE FriendlyText = '{0}' OR FriendlyText = '{1}'",DropDownList1.SelectedValue, DropDownList2.SelectedValue),conn)) { using (SqlDataReader r = cmd.ExecuteReader()) { try { r.Read(); // move to first row col1 = r.GetString(0); r.Read(); col2 = r.GetString(0); } catch (Exception ex) { } } } using (SqlCommand cmd = new SqlCommand(String.Format("SELECT [{0}],[{1}] FROM [edit].[dbo].[datawarehouse]", col1, col2), conn)) { using (SqlDataReader r = cmd.ExecuteReader()) { DataTable dt = new DataTable(); dt.Load(r); if (dt.Columns[0].DataType != typeof(System.Double) || dt.Columns[1].DataType != typeof(System.Double)) { Literal1.Text = "These two columns cannot be compared!"; return; } double a = 0; double b = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i].ItemArray.GetValue(0) != DBNull.Value && dt.Rows[i].ItemArray.GetValue(1) != DBNull.Value) { a = (double)dt.Rows[i].ItemArray.GetValue(0); b = (double)dt.Rows[i].ItemArray.GetValue(1); col1Values.Add(a); col2Values.Add(b); } } } } } double correlation = Math.Round(Correlation.Pearson(col1Values, col2Values), 5, MidpointRounding.ToEven); double percentageCorrelation = Math.Round(correlation * 100, 0); Literal1.Text = String.Format("The correlation is: {0}% ({1})<br/><p><strong>Please understand that high correlations do not necessarily imply causation -- only association!</strong></p><br/>", percentageCorrelation, correlation); SeriesPoint[] sp = new SeriesPoint[col1Values.Count]; Series s = new Series("Comparison", ViewType.Point); for (int i = 0; i < col1Values.Count; i++) { sp[i] = new SeriesPoint(col1Values[i], col2Values[i]); s.Points.Add(sp[i]); } RegressionLine rl = new RegressionLine("regression line"); rl.LineStyle.DashStyle = DashStyle.Dot; rl.LineStyle.Thickness = 2; rl.Color = System.Drawing.Color.Aqua; s.ArgumentScaleType = ScaleType.Numerical; s.ValueScaleType = ScaleType.Numerical; ChartTitle ct = new ChartTitle(); ct.Text = DropDownList1.SelectedValue + " compared to " + DropDownList2.SelectedValue; WebChartControl1.Titles.Add(ct); WebChartControl1.Series.Add(s); ((PointSeriesView)WebChartControl1.Series[0].View).Indicators.Clear(); ((PointSeriesView)WebChartControl1.Series[0].View).Indicators.Add(rl); ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisX.Title.Visible = true; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisX.Title.Alignment = System.Drawing.StringAlignment.Center; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisX.Title.Text = DropDownList1.SelectedValue; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisX.Title.TextColor = System.Drawing.Color.Red; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisX.Title.Antialiasing = true; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisY.Title.Visible = true; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisY.Title.Alignment = System.Drawing.StringAlignment.Center; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisY.Title.Text = DropDownList2.SelectedValue; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisY.Title.TextColor = System.Drawing.Color.Red; ((XYDiagramSeriesViewBase)WebChartControl1.Series[0].View).AxisY.Title.Antialiasing = true; }
/// <summary> /// Initializes a new instance of the <see cref="ChartTitleBuilder" /> class. /// </summary> /// <param name="chartTitle">The chart title.</param> public ChartTitleBuilder(ChartTitle chartTitle) { title = chartTitle; }
private void _initChart() { checkShowPointLabels.Checked = true; chartControlMaster.SeriesTemplate.Label.Visible = true; if (pivotGridMaster.Cells.Selection.X == 0 && pivotGridMaster.Cells.Selection.Y == 0 && pivotGridMaster.Cells.Selection.Width == 0 && pivotGridMaster.Cells.Selection.Height == 0) { ceSelectionOnly.Checked = false; ceSelectionFull.Checked = true; pivotGridMaster.OptionsChartDataSource.SelectionOnly = false; } else { ceSelectionOnly.Checked = true; ceSelectionFull.Checked = false; pivotGridMaster.OptionsChartDataSource.SelectionOnly = true; } ceChartDataVertical.Checked = true; pivotGridMaster.OptionsChartDataSource.ChartDataVertical = ceChartDataVertical.Checked; ChartTitle title = new ChartTitle(); title.Text = chartTitle; chartControlMaster.Titles.Add(title); chartControlMaster.DataSource = pivotGridMaster; chartControlMaster.SeriesDataMember = "Series"; chartControlMaster.SeriesTemplate.ArgumentDataMember = "Arguments"; chartControlMaster.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Values" }); chartControlMaster.SeriesTemplate.LegendPointOptions.PointView = PointView.ArgumentAndValues; _setScrollAndZoom(chartControlMaster); }