cscの作法 その64
概要
cscの作法、調べてみた。
円グラフやってみた。
写真
コンパイル手順
>set PATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;%PATH%
>csc ch1.cs /r:System.Windows.Forms.DataVisualization.dll
サンプルコード
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form {
public Form1() {
var chart1 = new Chart {
Dock = DockStyle.Fill,
};
this.Controls.Add(chart1);
Series mySeries = new Series("series");
double[] data = new double[] { 65.62, 75.54, 60.45, 55.73, 70.42 };
string[] country = new string[] { "France", "Canada", "UK", "USA", "Italy" };
mySeries.Points.DataBindXY(country, data);
mySeries.ChartType = SeriesChartType.Pie;
mySeries["PieLabelStyle"] = "Inside";
mySeries["PieDrawingStyle"] = "Default";
ChartArea myArea = new ChartArea("area");
chart1.ChartAreas.Add("area");
chart1.Series.Add(mySeries);
mySeries.ChartArea = "area";
chart1.Legends.Add(new Legend("Default"));
LegendCellColumn firstColumn = new LegendCellColumn();
firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
firstColumn.HeaderText = "";
chart1.Legends["Default"].CellColumns.Add(firstColumn);
LegendCellColumn percentColumn = new LegendCellColumn();
percentColumn.Text = "#PERCENT";
percentColumn.HeaderText = "Percentage";
percentColumn.Name = "nameColumn";
chart1.Legends["Default"].CellColumns.Add(percentColumn);
chart1.Legends["Default"].LegendStyle = LegendStyle.Table;
chart1.Legends["Default"].TableStyle = LegendTableStyle.Tall;
chart1.Legends["Default"].DockedToChartArea = "area";
chart1.Legends["Default"].IsDockedInsideChartArea = false;
chart1.Legends["Default"].Docking = Docking.Bottom;
}
[STAThread]
static void Main() {
Application.Run(new Form1());
}
}
}
>set PATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;%PATH%
>csc ch1.cs /r:System.Windows.Forms.DataVisualization.dll
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form {
public Form1() {
var chart1 = new Chart {
Dock = DockStyle.Fill,
};
this.Controls.Add(chart1);
Series mySeries = new Series("series");
double[] data = new double[] { 65.62, 75.54, 60.45, 55.73, 70.42 };
string[] country = new string[] { "France", "Canada", "UK", "USA", "Italy" };
mySeries.Points.DataBindXY(country, data);
mySeries.ChartType = SeriesChartType.Pie;
mySeries["PieLabelStyle"] = "Inside";
mySeries["PieDrawingStyle"] = "Default";
ChartArea myArea = new ChartArea("area");
chart1.ChartAreas.Add("area");
chart1.Series.Add(mySeries);
mySeries.ChartArea = "area";
chart1.Legends.Add(new Legend("Default"));
LegendCellColumn firstColumn = new LegendCellColumn();
firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
firstColumn.HeaderText = "";
chart1.Legends["Default"].CellColumns.Add(firstColumn);
LegendCellColumn percentColumn = new LegendCellColumn();
percentColumn.Text = "#PERCENT";
percentColumn.HeaderText = "Percentage";
percentColumn.Name = "nameColumn";
chart1.Legends["Default"].CellColumns.Add(percentColumn);
chart1.Legends["Default"].LegendStyle = LegendStyle.Table;
chart1.Legends["Default"].TableStyle = LegendTableStyle.Tall;
chart1.Legends["Default"].DockedToChartArea = "area";
chart1.Legends["Default"].IsDockedInsideChartArea = false;
chart1.Legends["Default"].Docking = Docking.Bottom;
}
[STAThread]
static void Main() {
Application.Run(new Form1());
}
}
}
以上。
Author And Source
この問題について(cscの作法 その64), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/0c653ab7a3426166c85e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .