This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
55 lines (48 loc) · 1.86 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using DevExpress.XtraCharts;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace AggregationSample {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
#region #ConfigureChart
private void Form1_Load(object sender, EventArgs e) {
chart.Series.Add(GenerateSeries(10000));
XYDiagram diagram = chart.Diagram as XYDiagram;
if (diagram == null) return;
diagram.AxisX.NumericScaleOptions.AggregateFunction = AggregateFunction.Average;
diagram.AxisX.NumericScaleOptions.ScaleMode = ScaleMode.Automatic;
diagram.AxisX.NumericScaleOptions.AutomaticMeasureUnitsCalculator = new CustomNumericMeasureUnitCalculator();
diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false;
}
#endregion #ConfigureChart
Series GenerateSeries(int pointCount) {
Series series = new Series {
Name = "Random data",
View = new SideBySideBarSeriesView()
};
Random generator = new Random();
for (int i = 0; i < pointCount; ++i) {
series.Points.Add(new SeriesPoint((double)i, generator.NextDouble()));
}
return series;
}
}
#region #InterfaceImpl
class CustomNumericMeasureUnitCalculator : INumericMeasureUnitsCalculator {
public double CalculateMeasureUnit(
IEnumerable<Series> series,
double axisLength,
int pixelsPerUnit,
double visualMin,
double visualMax,
double wholeMin,
double wholeMax) {
double visualRange = visualMax - visualMin;
return Math.Ceiling(visualRange / 20);
}
}
#endregion #InterfaceImpl
}