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;
  • 相关阅读:
    自调用匿名函数和js的Module模式
    设置一天中不同时段的倒计时,计算时针和分针的夹角
    移动端web开发中对点透的处理,以及理解fastclick如何做到去除300ms延迟
    使用Fiddler改变线上js文件的引用路径
    Linux下常用设置文件和文件夹读写权限操作
    RESTful API
    mysql之load语句
    Django学习之点赞功能
    Django学习之网站图标
    python学习之pyenv
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10898074.html
Copyright © 2011-2022 走看看