-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhighcharts.ts
132 lines (128 loc) · 4.89 KB
/
highcharts.ts
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import Highcharts from 'highcharts';
import HighchartsMore from 'highcharts/highcharts-more';
HighchartsMore(Highcharts);
import HighchartsGantt from 'highcharts/modules/gantt';
HighchartsGantt(Highcharts);
import NetworkGraph from 'highcharts/modules/networkgraph';
NetworkGraph(Highcharts);
import WordCloudGraph from 'highcharts/modules/wordcloud';
WordCloudGraph(Highcharts);
import VariablePieGraph from 'highcharts/modules/variable-pie';
VariablePieGraph(Highcharts);
import SankeyGraph from 'highcharts/modules/sankey';
SankeyGraph(Highcharts);
import SolidGaugeGraph from 'highcharts/modules/solid-gauge';
SolidGaugeGraph(Highcharts);
// import DependencyWheelGraph from 'highcharts/modules/dependency-wheel';
// DependencyWheelGraph(Highcharts);
// import MarkerCluster from 'highcharts/modules/marker-clusters';
// MarkerCluster(Highcharts);
import HighchartsColorAxis from 'highcharts/modules/coloraxis';
HighchartsColorAxis(Highcharts);
import HighchartsExporting from 'highcharts/modules/exporting';
HighchartsExporting(Highcharts);
import HighchartsExportData from 'highcharts/modules/export-data';
HighchartsExportData(Highcharts);
import NoDataToDisplay from 'highcharts/modules/no-data-to-display';
NoDataToDisplay(Highcharts);
import HighchartsDrilldown from 'highcharts/modules/drilldown';
HighchartsDrilldown(Highcharts);
// import MouseWheelZoom from 'highcharts/modules/mouse-wheel-zoom';
// MouseWheelZoom(Highcharts);
import Dashboards from '@highcharts/dashboards';
import DataGrid from '@highcharts/dashboards/datagrid';
import LayoutModule from '@highcharts/dashboards/modules/layout';
LayoutModule(Dashboards);
Dashboards.HighchartsPlugin.custom.connectHighcharts(Highcharts);
Dashboards.DataGridPlugin.custom.connectDataGrid(DataGrid);
Dashboards.PluginHandler.addPlugin(Dashboards.HighchartsPlugin);
Dashboards.PluginHandler.addPlugin(Dashboards.DataGridPlugin);
import { copySVG2JPG, saveSVG } from '../../bootstrap/modules/utils';
import { viewItemsInLib } from './utils';
import * as zh_CN from './zh_CN.json';
import { MessagePlugin } from 'tdesign-vue-next';
let infoFlag = false;
if (['zh-CN', 'zh-TW', 'ja-JP'].includes(navigator.language))
Highcharts.setOptions(zh_CN as Highcharts.Options);
Highcharts.setOptions({
accessibility: { enabled: false },
time: {
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
useUTC: false,
},
title: { text: undefined },
// tooltip: { outside: true },
chart: {
displayErrors: true,
borderRadius: 6,
animation: {
duration: 1200,
easing: (pos: number) => {
if (pos < 1 / 2.75) return 7.5625 * pos * pos;
if (pos < 2 / 2.75) return 7.5625 * (pos -= 1.5 / 2.75) * pos + 0.75;
if (pos < 2.5 / 2.75) return 7.5625 * (pos -= 2.25 / 2.75) * pos + 0.9375;
return 7.5625 * (pos -= 2.625 / 2.75) * pos + 0.984375;
},
},
style: { fontFamily: '' },
panKey: 'shift',
panning: { type: 'x', enabled: true },
zooming: {
type: 'x',
// key: 'ctrl',
// mouseWheel: { enabled: true },
},
events: {
selection: () => {
if (!infoFlag) {
MessagePlugin.info(addon.locale.zoomingTip);
infoFlag = true;
}
},
},
},
plotOptions: {
series: {
allowPointSelect: true,
cursor: 'pointer',
shadow: true,
point: { events: { select: _ => addon.log(_) } },
},
},
exporting: {
menuItemDefinitions: {
downloadSVG: {
onclick() {
saveSVG((this as any).getSVGForExport());
},
},
downloadJPEG: {
onclick() {
copySVG2JPG((this as any).getSVGForExport());
MessagePlugin.success(addon.locale.imageCopied);
},
text: addon.locale.copyPNG,
},
showInLibrary: {
onclick() {
const points = this.getSelectedPoints(),
ids = points
.flatMap((p: any) => p.custom?.itemIDs ?? parseInt(p.custom?.itemID ?? p.id))
.filter(id => id >= 0);
if (ids.length) viewItemsInLib(ids);
else MessagePlugin.warning(addon.locale.noItemToView);
},
text: addon.locale.showSelectedInLibrary,
},
help: { text: addon.locale.help },
},
buttons: {
contextButton: {
menuItems: ['viewFullscreen', 'downloadSVG', 'downloadJPEG', 'showInLibrary', 'help'],
},
},
},
credits: { enabled: false },
} as Highcharts.Options);
export default Highcharts;
export { Dashboards };