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
/
MainForm.aspx.cs
55 lines (49 loc) · 2.17 KB
/
MainForm.aspx.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 System;
using System.Collections.Generic;
using System.Text;
using DevExpress.XtraCharts;
namespace RegisterSummaryFunctionExample {
public partial class WebForm1 : System.Web.UI.Page {
const string summaryFunctionName = "PRODUCT";
// Declare the Product summary function.
private static SeriesPoint[] CalculateProductValue(
Series series,
object argument,
string[] functionArguments,
DataSourceValues[] values,
object[] colors) {
// Create an array of the resulting series points.
List<SeriesPoint> points = new List<SeriesPoint>();
// Calculate the resulting series points as Price * Count.
for (int i = 0; i < values.Length; i++) {
double value = Convert.ToDouble(values[i][functionArguments[0]]) *
Convert.ToDouble(values[i][functionArguments[1]]);
if (value > 0)
points.Add(new SeriesPoint(argument, value));
}
// Return the result.
return points.ToArray();
}
String BuildSummaryFunction(String price, String count) {
return
new StringBuilder(summaryFunctionName)
.Append("([")
.Append(price)
.Append("],[")
.Append(count)
.Append("])")
.ToString();
}
protected void Page_Load(object sender, EventArgs e) {
// Register the summary function in a chart.
chartControl.RegisterSummaryFunction(summaryFunctionName, summaryFunctionName, 1,
new SummaryFunctionArgumentDescription[] {
new SummaryFunctionArgumentDescription("Price", ScaleType.Numerical),
new SummaryFunctionArgumentDescription("Count", ScaleType.Numerical)},
CalculateProductValue);
// Specify the summary function for the series.
Series series = chartControl.Series["Product"];
series.SummaryFunction = BuildSummaryFunction("UnitPrice", "UnitsOnOrder");
}
}
}