0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

cscの作法 その63 3Dチャート

Last updated at Posted at 2022-03-26

概要

cscの作法、調べてみた。
3Dチャートやってみた。

参考にしたページ

写真

image.png

コンパイル手順


>set PATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;%PATH%

>csc chart.cs /r:System.Windows.Forms.DataVisualization.dll


サンプルコード

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace ChartingApp
{
	public partial class Form1 : Form {
		Chart chart;
		public Form1() {
			this.Width = 600;
			this.Height = 500;
			TrackBar track = new TrackBar();
			track.Dock = DockStyle.Bottom;
			track.Minimum = -44;
			track.Maximum = 44;
			track.LargeChange = 50;
			track.SmallChange = 50;
			track.Value = 30;
			this.Controls.Add(track);
			TrackBar track2 = new TrackBar();
			track2.Dock = DockStyle.Top;
			track2.Minimum = -90;
			track2.Maximum = 90;
			track2.LargeChange = 1;
			track2.SmallChange = 1;
			track2.Value = 15;
			this.Controls.Add(track2);
			TrackBar track3 = new TrackBar();
			track3.Dock = DockStyle.Bottom;
			track3.Minimum = 0;
			track3.Maximum = 100;
			track3.LargeChange = 1;
			track3.SmallChange = 1;
			track3.Value = 30;
			this.Controls.Add(track3);
			ChartArea area = new ChartArea();
			area.AxisX.Title = "X";
			area.AxisX.Minimum = -10;
			area.AxisX.Maximum = 100 + 10;
			area.AxisX.Interval = 20;
			area.AxisY.Title = "Y";
			area.AxisY.Minimum = -10;
			area.AxisY.Maximum = 255 + 50;
			area.AxisY.Interval = 20;
			var style = area.Area3DStyle;
			style.Enable3D = true;
			style.IsRightAngleAxes = true;
			style.Perspective = 20;
			style.Rotation = track.Value;
			style.Inclination = track2.Value;
			style.Perspective = track3.Value;
			chart = new Chart();
			chart.ChartAreas.Add(area);
			Random rnd = new Random();
			for (int i = 0; i < 100; i++)
			{
				var series = new Series();
				series.ChartType = SeriesChartType.Point;
				series.MarkerSize = 5;
				series.MarkerStyle = MarkerStyle.Circle;
				series.BorderColor = Color.Tomato;
				chart.Series.Add(series);
				for (int x = 0; x <= 100; x++)
				{
					var value = Math.Sin(x * Math.PI / 18.0) * 100 + 100;
					series.Points.AddXY(x, value);
				}
			}
			area.Position = new ElementPosition(0f, 0f, 100f, 90f);
			chart.Dock = DockStyle.Fill;
			this.Controls.Add(chart);
			track.ValueChanged += (s, e) => {
				this.chart.ChartAreas[0].Area3DStyle.Rotation = ((TrackBar)s).Value;
			};
			track2.ValueChanged += (s, e) => {
				this.chart.ChartAreas[0].Area3DStyle.Inclination = ((TrackBar)s).Value;
			};
			track3.ValueChanged += (s, e) => {
				this.chart.ChartAreas[0].Area3DStyle.Perspective = ((TrackBar)s).Value;
			};
		}
		[STAThread]
		static void Main() {
			Application.Run(new Form1());
		}
	}
}





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?