-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartScaleBreaksExtension.js
68 lines (64 loc) · 2.44 KB
/
ChartScaleBreaksExtension.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
var ChartScaleBreaksExtension = (function() {
var Model = DevExpress.Dashboard.Model;
// 1. Model
var autoScaleBreaksProperty = {
ownerType: Model.ChartItem,
propertyName: 'ScaleBreaks',
defaultValue: false,
valueType: 'boolean'
};
Model.registerCustomProperty(autoScaleBreaksProperty);
// 2. Viewer
function onItemWidgetOptionsPrepared(args) {
var scaleBreaks = args.dashboardItem.customProperties.getValue(autoScaleBreaksProperty.propertyName);
if (scaleBreaks) {
var valueAxisOptions = args.options["valueAxis"];
if (valueAxisOptions && valueAxisOptions[0]) {
valueAxisOptions[0].autoBreaksEnabled = true;
}
}
};
// 3. Designer
function onCustomizeSections(args) {
args.addSection({
title: "Scale breaks (Custom)",
items: [
{
dataField: autoScaleBreaksProperty.propertyName,
editorType: "dxCheckBox",
label: {
visible: false
},
editorOptions: {
text: "Enable Auto Scale breaks"
}
}
]
});
};
// 4. Event Subscription
function ChartScaleBreaksExtension(dashboardControl) {
this.name = "ScaleBreaks",
this.start = function () {
var viewerApiExtension = dashboardControl.findExtension('viewer-api');
if (viewerApiExtension) {
viewerApiExtension.on('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared);
}
var optionsPanelExtension = dashboardControl.findExtension("item-options-panel");
if (optionsPanelExtension) {
optionsPanelExtension.on('customizeSections', onCustomizeSections);
}
},
this.stop = function () {
var viewerApiExtension = dashboardControl.findExtension('viewer-api');
if (viewerApiExtension) {
viewerApiExtension.off('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared);
}
var optionsPanelExtension = dashboardControl.findExtension("item-options-panel");
if (optionsPanelExtension) {
optionsPanelExtension.off('customizeSections', onCustomizeSections);
}
}
}
return ChartScaleBreaksExtension;
}());