-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartLineOptionsExtension.js
89 lines (82 loc) · 3.52 KB
/
ChartLineOptionsExtension.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var ChartLineOptionsExtension = (function() {
var Model = DevExpress.Dashboard.Model;
// 1. Model
const dashStyleProperty = {
ownerType: Model.SimpleSeries,
propertyName: "DashStyleProperty",
defaultValue: "solid",
valueType: 'string'
};
Model.registerCustomProperty(dashStyleProperty);
// 2. Viewer
function onItemWidgetOptionsPrepared(args) {
if (args.dashboardItem instanceof Model.ChartItem) {
var seriesOptionArray = args.options['series'] || [];
seriesOptionArray.forEach(function(seriesOption) {
if (seriesOption.type === "line") {
var series = args.chartContext.getDashboardItemSeries(seriesOption);
if (series) {
var dashStyle = series.customProperties.getValue(dashStyleProperty.propertyName);
seriesOption.dashStyle = dashStyle;
}
}
});
}
};
// 3. Designer
function onCustomizeSections(args) {
var simpleSeries = args.dataItemContainer;
if (simpleSeries instanceof Model.SimpleSeries
&& ['Line', 'FullStackedLine', 'StackedLine', 'StepLine', 'Spline'].indexOf(simpleSeries.seriesType()) !== -1
) {
args.addSection({
title: "Line Options (Custom)",
items: [
{
dataField: dashStyleProperty.propertyName,
editorType: "dxSelectBox",
label: {
text: 'Dash style'
},
editorOptions: {
items: [
{ value: 'dash', displayValue: "Dashes" },
{ value: 'dot', displayValue: "Dots" },
{ value: 'longDash', displayValue: "Long Dashes" },
{ value: 'solid', displayValue: "Solid Line" },
{ value: 'dashdot', displayValue: "Dash-Dots" }
],
displayExpr: "displayValue",
valueExpr: "value"
}
}
]
});
}
};
// 4. Event Subscription
function ChartLineOptionsExtension(dashboardControl) {
this.name = 'ChartLineOptions',
this.start = function () {
let viewerApiExtension = dashboardControl.findExtension('viewer-api');
if (viewerApiExtension) {
viewerApiExtension.on('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared);
}
let bindingPanelExtension = dashboardControl.findExtension("item-binding-panel");
if (bindingPanelExtension) {
bindingPanelExtension.on('customizeDataItemContainerSections', onCustomizeSections);
}
},
this.stop = function () {
let viewerApiExtension = dashboardControl.findExtension('viewer-api');
if (viewerApiExtension) {
viewerApiExtension.off('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared);
}
let bindingPanelExtension = dashboardControl.findExtension("item-binding-panel");
if (bindingPanelExtension) {
bindingPanelExtension.off('customizeDataItemContainerSections', onCustomizeSections);
}
}
}
return ChartLineOptionsExtension
}());