This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
/
Form1.cs
51 lines (49 loc) · 2.52 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
using DevExpress.DashboardCommon;
using DevExpress.XtraEditors;
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;
namespace ChartFormatRulesSample {
public partial class Form1 : XtraForm {
public Form1() {
InitializeComponent();
dashboardDesigner1.CreateRibbon();
dashboardDesigner1.LoadDashboard("nwindDashboard.xml");
ChartDashboardItem chart1 = (ChartDashboardItem)dashboardDesigner1.Dashboard.Items["chartDashboardItem1"];
ChartDashboardItem chart2 = (ChartDashboardItem)dashboardDesigner1.Dashboard.Items["chartDashboardItem2"];
AddFormatRulesToBarSeries(chart1);
AddFormatRulesToLineSeries(chart2);
}
public void AddFormatRulesToBarSeries(ChartDashboardItem chart) {
SimpleSeries series = chart.Panes[0].Series[0] as SimpleSeries;
ChartItemFormatRule gradientRule = new ChartItemFormatRule(series.Value, series);
FormatConditionRangeGradient condition = new FormatConditionRangeGradient(FormatConditionRangeGradientPredefinedType.RedBlue);
gradientRule.Condition = condition;
gradientRule.ShowInLegend = false;
chart.FormatRules.Add(gradientRule);
}
public void AddFormatRulesToLineSeries(ChartDashboardItem chart) {
SimpleSeries series = chart.Panes[0].Series[0] as SimpleSeries;
ChartItemFormatRule valueRule1 = new ChartItemFormatRule(series.Value, series);
FormatConditionValue valueCondition1 = new FormatConditionValue(DashboardFormatCondition.Greater, 3000);
valueCondition1.StyleSettings = new ColorStyleSettings(Color.Green);
valueRule1.Condition = valueCondition1;
valueRule1.ShowInLegend = true;
valueRule1.DisplayName = "UnitPrice is greater than $3K";
chart.FormatRules.Add(valueRule1);
ChartItemFormatRule valueRule2 = new ChartItemFormatRule(series.Value, series);
FormatConditionValue valueCondition2 = new FormatConditionValue(DashboardFormatCondition.Less, 3000);
valueCondition2.StyleSettings = new ColorStyleSettings(Color.Red);
valueRule2.Condition = valueCondition2;
valueRule2.ShowInLegend = true;
valueRule2.DisplayName = "UnitPrice is less than $3K";
chart.FormatRules.Add(valueRule2);
}
}
}