1
-
2
- using DevExpress . DashboardCommon ;
3
- using DevExpress . DashboardCommon . ViewerData ;
4
- using DevExpress . DashboardWeb ;
5
- using DevExpress . XtraCharts ;
6
- using DevExpress . XtraReports . UI ;
7
- using Newtonsoft . Json ;
8
- using System . Collections . Generic ;
9
- using System . Drawing ;
10
- using System . Linq ;
11
-
12
- namespace AspNetCoreDashboardCustomPropertiesSample {
13
- public class CustomConstantLine {
14
- public int key { get ; set ; }
15
- public string name { get ; set ; }
16
- public bool isBound { get ; set ; }
17
- public string measureId { get ; set ; }
18
- public double value { get ; set ; }
19
- public string color { get ; set ; }
20
- public string labelText { get ; set ; }
21
- }
22
-
23
- public static class ChartConstantLinesExtension {
24
- public static void CustomExport ( CustomExportWebEventArgs e ) {
25
- Dictionary < string , XRControl > controls = e . GetPrintableControls ( ) ;
26
- foreach ( var control in controls ) {
27
- string componentName = control . Key ;
28
- XRChart chartControl = control . Value as XRChart ;
29
- ChartDashboardItem chartItem = e . GetDashboardItem ( componentName ) as ChartDashboardItem ;
30
- if ( chartControl != null && chartItem != null ) {
31
- string constantLinesJSON = chartItem . CustomProperties [ "ConstantLineSettings" ] ;
32
- if ( constantLinesJSON != null ) {
33
- XYDiagram diagram = chartControl . Diagram as XYDiagram ;
34
- if ( diagram != null ) {
35
- List < CustomConstantLine > customConstantLines = JsonConvert . DeserializeObject < List < CustomConstantLine > > ( constantLinesJSON ) ;
36
- customConstantLines . ForEach ( customConstantLine =>
37
- {
38
- ConstantLine line = new ConstantLine ( ) ;
39
- line . Visible = true ;
40
- line . ShowInLegend = false ;
41
- //line.Color = ColorTranslator.FromHtml(customConstantLine.color);
42
- line . Title . Text = customConstantLine . labelText ;
43
- line . LineStyle . DashStyle = DashStyle . Dash ;
44
- line . LineStyle . Thickness = 2 ;
45
- if ( customConstantLine . isBound ) {
46
- MultiDimensionalData data = e . GetItemData ( componentName ) ;
47
- MeasureDescriptor measure = data . GetMeasures ( ) . FirstOrDefault ( m => m . ID == customConstantLine . measureId ) ;
48
- if ( measure != null )
49
- line . AxisValue = data . GetValue ( measure ) . Value ;
50
- } else
51
- line . AxisValue = customConstantLine . value ;
52
-
53
-
54
- if ( diagram . SecondaryAxesY . Count > 0 )
55
- diagram . SecondaryAxesY [ 0 ] . ConstantLines . Add ( line ) ;
56
- } ) ;
57
- }
58
- }
59
- }
60
- }
61
- }
62
- }
63
- }
1
+
2
+ using DevExpress . DashboardCommon ;
3
+ using DevExpress . DashboardCommon . ViewerData ;
4
+ using DevExpress . DashboardWeb ;
5
+ using DevExpress . XtraCharts ;
6
+ using DevExpress . XtraReports . UI ;
7
+ using Newtonsoft . Json ;
8
+ using System . Collections . Generic ;
9
+ using System . Drawing ;
10
+ using System . Linq ;
11
+
12
+ namespace AspNetCoreDashboardCustomPropertiesSample {
13
+ public class CustomConstantLine {
14
+ public int key { get ; set ; }
15
+ public string name { get ; set ; }
16
+ public bool isBound { get ; set ; }
17
+ public string measureId { get ; set ; }
18
+ public double value { get ; set ; }
19
+ public string color { get ; set ; }
20
+ public string labelText { get ; set ; }
21
+ }
22
+
23
+ public static class ChartConstantLinesExtension {
24
+ public static void CustomExport ( CustomExportWebEventArgs e ) {
25
+ Dictionary < string , XRControl > controls = e . GetPrintableControls ( ) ;
26
+ foreach ( var control in controls ) {
27
+ string componentName = control . Key ;
28
+ XRChart chartControl = control . Value as XRChart ;
29
+ ChartDashboardItem chartItem = e . GetDashboardItem ( componentName ) as ChartDashboardItem ;
30
+ if ( chartControl != null && chartItem != null ) {
31
+ string constantLinesJSON = chartItem . CustomProperties [ "ConstantLineSettings" ] ;
32
+ if ( constantLinesJSON != null ) {
33
+ XYDiagram diagram = chartControl . Diagram as XYDiagram ;
34
+ if ( diagram != null ) {
35
+ List < CustomConstantLine > customConstantLines = JsonConvert . DeserializeObject < List < CustomConstantLine > > ( constantLinesJSON ) ;
36
+ customConstantLines . ForEach ( customConstantLine =>
37
+ {
38
+ ConstantLine line = new ConstantLine ( ) ;
39
+ line . Visible = true ;
40
+ line . ShowInLegend = false ;
41
+ //line.Color = ColorTranslator.FromHtml(customConstantLine.color);
42
+ line . Title . Text = customConstantLine . labelText ;
43
+ line . LineStyle . DashStyle = DashStyle . Dash ;
44
+ line . LineStyle . Thickness = 2 ;
45
+ if ( customConstantLine . isBound ) {
46
+ MultiDimensionalData data = e . GetItemData ( componentName ) ;
47
+ MeasureDescriptor measure = data . GetMeasures ( ) . FirstOrDefault ( m => m . ID == customConstantLine . measureId ) ;
48
+ if ( measure != null )
49
+ line . AxisValue = data . GetValue ( measure ) . Value ;
50
+ } else
51
+ line . AxisValue = customConstantLine . value ;
52
+
53
+
54
+ if ( diagram . SecondaryAxesY . Count > 0 )
55
+ diagram . SecondaryAxesY [ 0 ] . ConstantLines . Add ( line ) ;
56
+ } ) ;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
0 commit comments