SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | - | using System.Collections.Generic; |
2 | + | |
3 | - | using System.ComponentModel; |
3 | + | |
4 | - | using System.Data; |
4 | + | |
5 | ||
6 | - | using System.Linq; |
6 | + | |
7 | - | using System.Text; |
7 | + | |
8 | public partial class Form1 : Form | |
9 | - | using System.Text.RegularExpressions; |
9 | + | |
10 | - | using System.IO; |
10 | + | |
11 | Random rand = new Random(); | |
12 | ||
13 | int cind = 0; | |
14 | char[] arr = new char[] { 'a', 'b', 'c' }; | |
15 | ||
16 | public Form1() | |
17 | { | |
18 | InitializeComponent(); | |
19 | ||
20 | } | |
21 | - | char[] arr = new char[] { 'a', 'b', 'c'}; |
21 | + | |
22 | private void button1_Click(object sender, EventArgs e) | |
23 | { | |
24 | chart1.Series.Clear(); | |
25 | chart1.Legends.Clear(); | |
26 | var leg = CreateLegend(); | |
27 | chart1.Legends.Add(leg); | |
28 | chart1.Series.Add(CreateSeries(leg, 'i')); | |
29 | } | |
30 | ||
31 | public Series CreateSeries(Legend legend, char c) | |
32 | { | |
33 | - | chart1.Series.Add(CreateSeries(leg)); |
33 | + | |
34 | seriesDetail.Name = "Result Chart" + arr[cind++]; | |
35 | seriesDetail.IsValueShownAsLabel = false; | |
36 | - | public Series CreateSeries(Legend legend) |
36 | + | |
37 | seriesDetail.BorderWidth = 2; | |
38 | ||
39 | for (int i = 0; i < 10; i++) | |
40 | { | |
41 | var p = seriesDetail.Points.Add(rand.NextDouble()); | |
42 | p.LegendText = new string(c, i + 1); | |
43 | ||
44 | } | |
45 | ||
46 | seriesDetail.ChartArea = "Result Chart"; | |
47 | - | p.LegendText = new string('x', i); |
47 | + | |
48 | - | |
48 | + | |
49 | } | |
50 | ||
51 | public Legend CreateLegend() | |
52 | { | |
53 | var legend = new Legend(); | |
54 | ||
55 | legend.Enabled = true; | |
56 | legend.Font = new Font("Arial", 11F); | |
57 | legend.ForeColor = Color.FromArgb(102, 102, 102); | |
58 | legend.InsideChartArea = "Result Chart"; | |
59 | ||
60 | legend.Position = new ElementPosition(65, 10, 30, 60); | |
61 | legend.Name = string.Format("Legend No. {0}", cind); | |
62 | ||
63 | legend.LegendStyle = LegendStyle.Column; | |
64 | ||
65 | legend.CellColumns.Add(new LegendCellColumn() { | |
66 | ColumnType = LegendCellColumnType.SeriesSymbol, | |
67 | MinimumWidth = 250, | |
68 | MaximumWidth = 250 | |
69 | }); | |
70 | - | legend.CellColumns.Add(new LegendCellColumn() { ColumnType = LegendCellColumnType.SeriesSymbol }); |
70 | + | |
71 | { | |
72 | ColumnType = LegendCellColumnType.Text, | |
73 | Alignment = ContentAlignment.MiddleLeft, | |
74 | - | Alignment = ContentAlignment.MiddleLeft |
74 | + | MinimumWidth = 1500, |
75 | MaximumWidth = 1500 | |
76 | }); | |
77 | ||
78 | return legend; | |
79 | } | |
80 | ||
81 | private void button2_Click(object sender, EventArgs e) | |
82 | { | |
83 | chart2.Series.Clear(); | |
84 | chart2.Legends.Clear(); | |
85 | var leg = CreateLegend(); | |
86 | chart2.Legends.Add(leg); | |
87 | chart2.Series.Add(CreateSeries(leg, 'M')); | |
88 | } | |
89 | } | |
90 | } |