zoukankan      html  css  js  c++  java
  • Chart的简单使用

    chart1.Titles.Add("Line Chart");
    
    chart1.ChartAreas[0].Axes[0].MajorGrid.Enabled = false;
    chart1.ChartAreas[0].Axes[1].MajorGrid.Enabled = false;
    this.dataGridView1.AllowUserToAddRows = false; List
    <string> brand = new List<string>(); List<int> price = new List<int>(); List<int> yrsava = new List<int>(); // Traverse the DataGridView to get the corresponding value for (int row = 0; row <= dataGridView1.Rows.Count - 1; row++) { brand.Add(dataGridView1.Rows[row].Cells[0].Value == null ? "" : dataGridView1.Rows[row].Cells[0].Value.ToString()); price.Add(dataGridView1.Rows[row].Cells[1].Value == null ? 0 : (int)dataGridView1.Rows[row].Cells[1].Value); yrsava.Add(dataGridView1.Rows[row].Cells[2].Value == null ? 0 : (int)dataGridView1.Rows[row].Cells[2].Value); } // Clear the exist Series and add new series chart1.Series.Clear(); chart1.Series.Add("Price"); chart1.Series.Add("Yrs ava"); // Add data to chart chart1.Series["Price"].Points.DataBindXY(brand, price); chart1.Series["Yrs ava"].Points.DataBindXY(brand, yrsava); // Set chart type, here set it to "Bar" chart1.Series[0].ChartType = SeriesChartType.Bar; chart1.Series[1].ChartType = SeriesChartType.Bar; // Draw StackedBar // Set Xaxis List<string> departments = new List<string>() { "A", "B", "C" }; // Add series List<string> months = new List<string>() { "Jan", "Feb", "Mar", "Apr" }; for (int i = 0; i < months.Count; i++) { Series series = new Series(); series.Name = months[i]; series.ChartType = SeriesChartType.StackedBar; this.chart1.Series.Add(series); } // Bind data int[][] scores = new int[3][] { new int[] { 1, 2, 3, 4 }, new int[] { 3, 3, 3, 4 }, new int[] { 5, 2, 3, 4 } }; for (int i = 0; i < months.Count; i++) { for (int j = 0; j < scores.Length; j++) this.chart1.Series[i].Points.AddXY(departments[j], scores[j][i]); } // Two AxisY chart1.Series.Add("Y1"); chart1.Series.Add("Y2"); // Show the Axis title chart1.ChartAreas[0].AxisX.Title = "X"; chart1.ChartAreas[0].AxisY.Title = "Y1"; chart1.ChartAreas[0].AxisY2.Title = "Y2"; chart1.Series["Y1"].Points.DataBindXY(X, Y1); chart1.Series["Y2"].Points.DataBindXY(X, Y2) chart1.Series[0].ChartType = SeriesChartType.StackedBar; chart1.Series[1].ChartType = SeriesChartType.StackedBar; chart1.Series[0].YAxisType = AxisType.Primary; chart1.Series[1].YAxisType = AxisType.Secondary; chart1.ChartAreas[0].AxisY2.LineColor = Color.Transparent; chart1.ChartAreas[0].AxisY2.MajorGrid.Enabled = false; chart1.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True; chart1.ChartAreas[0].AxisY2.IsStartedFromZero = chart1.ChartAreas[0].AxisY.IsStartedFromZero;
  • 相关阅读:
    CF-911E.Stack Sorting(栈)
    随机算法 && CodeForces
    CF-579D."Or" Game(或运算)
    CF-242E.XOR on Segment(异或线段树)
    莫队 && 洛谷 P1494 [国家集训队]小Z的袜子
    洛谷 P4168 [Violet]蒲公英(分块)
    分块 && 洛谷 P2801 教主的魔法
    启发式合并 && U41492 树上数颜色
    使用mysqlbinlog server远程备份binlog的脚本
    mysqldump备份过程中都干了些什么
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10898074.html
Copyright © 2011-2022 走看看