@dhis2/analytics 23.12.5 → 23.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/build/cjs/components/OpenFileDialog/OpenFileDialog.js +1 -1
- package/build/cjs/locales/nl/translations.json +3 -3
- package/build/cjs/modules/legends.js +20 -2
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/index.js +11 -6
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/legend.js +4 -97
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/series/index.js +42 -4
- package/build/cjs/visualizations/config/generators/highcharts/index.js +33 -0
- package/build/es/components/OpenFileDialog/OpenFileDialog.js +1 -1
- package/build/es/locales/nl/translations.json +3 -3
- package/build/es/modules/legends.js +15 -0
- package/build/es/visualizations/config/adapters/dhis_highcharts/index.js +11 -6
- package/build/es/visualizations/config/adapters/dhis_highcharts/legend.js +5 -93
- package/build/es/visualizations/config/adapters/dhis_highcharts/series/index.js +41 -4
- package/build/es/visualizations/config/generators/highcharts/index.js +33 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [23.13.3](https://github.com/dhis2/analytics/compare/v23.13.2...v23.13.3) (2022-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* avoid ES2022 functions ([#1300](https://github.com/dhis2/analytics/issues/1300)) ([93ab848](https://github.com/dhis2/analytics/commit/93ab848e89e4c22a2d9ca20625287af892ef8d89))
|
|
7
|
+
|
|
8
|
+
## [23.13.2](https://github.com/dhis2/analytics/compare/v23.13.1...v23.13.2) (2022-08-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* highcharts legend when exporting (DHIS2-12719) ([#1279](https://github.com/dhis2/analytics/issues/1279)) ([5f62e20](https://github.com/dhis2/analytics/commit/5f62e2050a1ff7411308a32f87f3e427cdbb4bb4))
|
|
14
|
+
|
|
15
|
+
## [23.13.1](https://github.com/dhis2/analytics/compare/v23.13.0...v23.13.1) (2022-07-28)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **translations:** sync translations from transifex (master) ([d3a1f4e](https://github.com/dhis2/analytics/commit/d3a1f4e861cf29e95f9615f3585e814d52aa837f))
|
|
21
|
+
|
|
22
|
+
# [23.13.0](https://github.com/dhis2/analytics/compare/v23.12.5...v23.13.0) (2022-07-25)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* search by tokens across identifiable properties (DHIS2-13475) ([c94c427](https://github.com/dhis2/analytics/commit/c94c4271492d390cd76cfb8c8d8104cbfab83e1d))
|
|
28
|
+
* search by tokens across identifiable properties [DHIS2-13475] ([87db2f9](https://github.com/dhis2/analytics/commit/87db2f91f7aa5b2665038324d5b779e2f8267812))
|
|
29
|
+
|
|
1
30
|
## [23.12.5](https://github.com/dhis2/analytics/compare/v23.12.4...v23.12.5) (2022-06-24)
|
|
2
31
|
|
|
3
32
|
|
|
@@ -130,7 +130,7 @@ const OpenFileDialog = _ref2 => {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
if (filters.searchTerm) {
|
|
133
|
-
queryFilters.push("
|
|
133
|
+
queryFilters.push("identifiable:token:".concat(filters.searchTerm));
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
return queryFilters;
|
|
@@ -200,9 +200,9 @@
|
|
|
200
200
|
"Bi-weekly": "Tweewekelijks",
|
|
201
201
|
"Monthly": "Maandelijks",
|
|
202
202
|
"Bi-monthly": "Tweemaandelijks",
|
|
203
|
-
"Quarterly": "",
|
|
204
|
-
"Six-monthly": "",
|
|
205
|
-
"Six-monthly April": "",
|
|
203
|
+
"Quarterly": "Driemaandelijks",
|
|
204
|
+
"Six-monthly": "Zesmaandelijks",
|
|
205
|
+
"Six-monthly April": "Zesmaandelijks april",
|
|
206
206
|
"Yearly": "Jaarlijks",
|
|
207
207
|
"Financial year (Start November)": "Financieel jaar (Start november)",
|
|
208
208
|
"Financial year (Start October)": "Financieel jaar (Start oktober)",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getLegendByValueFromLegendSet = exports.getColorByValueFromLegendSet = exports.LEGEND_DISPLAY_STYLE_TEXT = exports.LEGEND_DISPLAY_STYLE_FILL = exports.LEGEND_DISPLAY_STRATEGY_FIXED = exports.LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = void 0;
|
|
6
|
+
exports.getLegendSetByDisplayStrategy = exports.getLegendByValueFromLegendSet = exports.getColorByValueFromLegendSet = exports.LEGEND_DISPLAY_STYLE_TEXT = exports.LEGEND_DISPLAY_STYLE_FILL = exports.LEGEND_DISPLAY_STRATEGY_FIXED = exports.LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = void 0;
|
|
7
7
|
const LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = 'BY_DATA_ITEM';
|
|
8
8
|
exports.LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM;
|
|
9
9
|
const LEGEND_DISPLAY_STRATEGY_FIXED = 'FIXED';
|
|
@@ -27,4 +27,22 @@ const getColorByValueFromLegendSet = (legendSet, value) => {
|
|
|
27
27
|
return legend && legend.color;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
exports.getColorByValueFromLegendSet = getColorByValueFromLegendSet;
|
|
30
|
+
exports.getColorByValueFromLegendSet = getColorByValueFromLegendSet;
|
|
31
|
+
|
|
32
|
+
const getLegendSetByDisplayStrategy = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
displayStrategy,
|
|
35
|
+
legendSets,
|
|
36
|
+
legendSetId
|
|
37
|
+
} = _ref;
|
|
38
|
+
|
|
39
|
+
if (displayStrategy === LEGEND_DISPLAY_STRATEGY_FIXED && legendSets.length) {
|
|
40
|
+
return legendSets[0];
|
|
41
|
+
} else if (displayStrategy === LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM) {
|
|
42
|
+
return legendSets.find(legendSet => legendSet.id === legendSetId);
|
|
43
|
+
} else {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.getLegendSetByDisplayStrategy = getLegendSetByDisplayStrategy;
|
|
@@ -64,7 +64,7 @@ const getTransformedExtraOptions = extraOptions => ({ ...extraOptions,
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
function _default(_ref) {
|
|
67
|
-
var _layout$seriesKey, _layout$seriesKey2, _layout$seriesKey2$la,
|
|
67
|
+
var _layout$legend, _layout$seriesKey, _layout$seriesKey2, _layout$seriesKey2$la, _config$xAxis;
|
|
68
68
|
|
|
69
69
|
let {
|
|
70
70
|
store,
|
|
@@ -110,16 +110,21 @@ function _default(_ref) {
|
|
|
110
110
|
// y-axis
|
|
111
111
|
yAxis: (0, _index7.default)(_layout, series, _extraOptions),
|
|
112
112
|
// series
|
|
113
|
-
series: (0, _index3.default)(
|
|
113
|
+
series: (0, _index3.default)({
|
|
114
|
+
series: series.slice(),
|
|
115
|
+
metaData: store.data[0].metaData.items,
|
|
116
|
+
layout: _layout,
|
|
117
|
+
isStacked: stacked,
|
|
118
|
+
extraOptions: _extraOptions,
|
|
119
|
+
legendSets,
|
|
120
|
+
displayStrategy: (_layout$legend = _layout.legend) === null || _layout$legend === void 0 ? void 0 : _layout$legend.strategy
|
|
121
|
+
}),
|
|
114
122
|
// legend
|
|
115
123
|
legend: (0, _legend.default)({
|
|
116
124
|
isHidden: (_layout$seriesKey = _layout.seriesKey) === null || _layout$seriesKey === void 0 ? void 0 : _layout$seriesKey.hidden,
|
|
117
125
|
fontStyle: (_layout$seriesKey2 = _layout.seriesKey) === null || _layout$seriesKey2 === void 0 ? void 0 : (_layout$seriesKey2$la = _layout$seriesKey2.label) === null || _layout$seriesKey2$la === void 0 ? void 0 : _layout$seriesKey2$la.fontStyle,
|
|
118
126
|
visType: _layout.type,
|
|
119
|
-
dashboard: _extraOptions.dashboard
|
|
120
|
-
legendSets,
|
|
121
|
-
metaData: store.data[0].metaData.items,
|
|
122
|
-
displayStrategy: (_layout$legend = _layout.legend) === null || _layout$legend === void 0 ? void 0 : _layout$legend.strategy
|
|
127
|
+
dashboard: _extraOptions.dashboard
|
|
123
128
|
}),
|
|
124
129
|
// pane
|
|
125
130
|
pane: (0, _index2.default)(_layout.type),
|
|
@@ -7,18 +7,10 @@ exports.default = _default;
|
|
|
7
7
|
|
|
8
8
|
var _fontStyle = require("../../../../modules/fontStyle.js");
|
|
9
9
|
|
|
10
|
-
var _legends = require("../../../../modules/legends.js");
|
|
11
|
-
|
|
12
10
|
var _visTypes = require("../../../../modules/visTypes.js");
|
|
13
11
|
|
|
14
|
-
var _colorSets = require("../../../util/colors/colorSets.js");
|
|
15
|
-
|
|
16
12
|
var _getTextAlignOption = require("./getTextAlignOption.js");
|
|
17
13
|
|
|
18
|
-
var _type = _interopRequireDefault(require("./type.js"));
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
const DASHBOARD_ITEM_STYLE = {
|
|
23
15
|
fontSize: '11px',
|
|
24
16
|
fontWeight: 500
|
|
@@ -48,100 +40,15 @@ function getLegend(fontStyle, dashboard, visType) {
|
|
|
48
40
|
});
|
|
49
41
|
}
|
|
50
42
|
|
|
51
|
-
|
|
52
|
-
let {
|
|
53
|
-
displayStrategy,
|
|
54
|
-
legendSets,
|
|
55
|
-
legendSetId
|
|
56
|
-
} = _ref;
|
|
57
|
-
|
|
58
|
-
if (displayStrategy === _legends.LEGEND_DISPLAY_STRATEGY_FIXED && legendSets.length) {
|
|
59
|
-
return legendSets[0];
|
|
60
|
-
} else if (displayStrategy === _legends.LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM) {
|
|
61
|
-
return legendSets.find(legendSet => legendSet.id === legendSetId);
|
|
62
|
-
} else {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const formatLabel = _ref2 => {
|
|
68
|
-
var _metaData$seriesId, _legendSet$legends;
|
|
69
|
-
|
|
70
|
-
let {
|
|
71
|
-
seriesId,
|
|
72
|
-
seriesColor,
|
|
73
|
-
seriesName,
|
|
74
|
-
seriesType,
|
|
75
|
-
metaData,
|
|
76
|
-
displayStrategy,
|
|
77
|
-
legendSets,
|
|
78
|
-
fontStyle,
|
|
79
|
-
visType
|
|
80
|
-
} = _ref2;
|
|
81
|
-
const legendSet = getLegendSetByDisplayStrategy({
|
|
82
|
-
displayStrategy,
|
|
83
|
-
legendSets,
|
|
84
|
-
legendSetId: (_metaData$seriesId = metaData[seriesId]) === null || _metaData$seriesId === void 0 ? void 0 : _metaData$seriesId.legendSet
|
|
85
|
-
});
|
|
86
|
-
const result = []; // Note: Highcharts strips out 'data-test' and similar attributes, hence 'class="data-test-..." was used instead
|
|
87
|
-
|
|
88
|
-
result.push('<div style="display: flex; align-items: center; margin-bottom: 4px;" class="data-test-series-key-item">');
|
|
89
|
-
|
|
90
|
-
if ((!seriesId || seriesId.startsWith('trendline')) && seriesType === (0, _type.default)(_visTypes.VIS_TYPE_LINE).type) {
|
|
91
|
-
// trendline
|
|
92
|
-
result.push("<span style=\"height: ".concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 6.5, "px; width: ").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "px; background-color: ").concat(seriesColor, "; display: inline-block;\"></span>"));
|
|
93
|
-
result.push("<span style=\"margin-left: 8px\" class=\"data-test-series-key-item-name\">".concat(seriesName, "</span>"));
|
|
94
|
-
} else if (legendSet !== null && legendSet !== void 0 && (_legendSet$legends = legendSet.legends) !== null && _legendSet$legends !== void 0 && _legendSet$legends.length && (0, _visTypes.isLegendSetType)(visType) && seriesType !== (0, _type.default)(_visTypes.VIS_TYPE_LINE).type) {
|
|
95
|
-
// item with legend set
|
|
96
|
-
legendSet.legends.sort((a, b) => a.startValue - b.startValue).forEach((legend, index) => result.push("<svg width=\"".concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "\" height=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "\" style=\"margin-right:-5px; z-index: ").concat(legendSet.legends.length - index, "\" class=\"data-test-series-key-item-bullet\">\n <circle cx=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" cy=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" r=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" fill=\"").concat(legend.color, "\"></circle>\n </svg>")));
|
|
97
|
-
result.push("<span style=\"margin-left: 8px\" class=\"data-test-series-key-item-name\">".concat(seriesName, "</span>"));
|
|
98
|
-
} else {
|
|
99
|
-
// regular item (not a trendline, no applied legend set)
|
|
100
|
-
if ((seriesColor === null || seriesColor === void 0 ? void 0 : seriesColor.patternIndex) !== undefined) {
|
|
101
|
-
const pattern = _colorSets.colorSets[_colorSets.COLOR_SET_PATTERNS].patterns[seriesColor.patternIndex];
|
|
102
|
-
result.push("<svg style=\"height: ".concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "px; width: ").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "px; display: inline-block; margin-right:5px\" class=\"data-test-series-key-item-bullet\">\n <defs>\n <pattern id=\"pattern").concat(seriesColor.patternIndex, "\" patternUnits=\"userSpaceOnUse\" width=\"").concat(pattern.width, "\" height=\"").concat(pattern.height, "\">\n <path stroke=\"").concat(pattern.color, "\" d=\"").concat(pattern.path, "\"/>\n </pattern>\n </defs>\n <circle cx=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" cy=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" r=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" fill=\"url(#pattern").concat(seriesColor.patternIndex, ")\"/>\n </svg>"));
|
|
103
|
-
} else {
|
|
104
|
-
result.push("<svg width=\"".concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "\" height=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "\" style=\"margin-right:5px\" class=\"data-test-series-key-item-bullet\">\n <circle cx=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" cy=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" r=\"").concat(fontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" fill=\"").concat(seriesColor, "\"></circle>\n </svg>"));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
result.push("<span class=\"data-test-series-key-item-name\">".concat(seriesName, "</span>"));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
result.push('</div>');
|
|
111
|
-
return result.join('');
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
function _default(_ref3) {
|
|
43
|
+
function _default(_ref) {
|
|
115
44
|
let {
|
|
116
45
|
isHidden,
|
|
117
46
|
fontStyle,
|
|
118
47
|
visType,
|
|
119
|
-
dashboard
|
|
120
|
-
|
|
121
|
-
metaData,
|
|
122
|
-
displayStrategy
|
|
123
|
-
} = _ref3;
|
|
48
|
+
dashboard
|
|
49
|
+
} = _ref;
|
|
124
50
|
const mergedFontStyle = (0, _fontStyle.mergeFontStyleWithDefault)(fontStyle, _fontStyle.FONT_STYLE_LEGEND);
|
|
125
51
|
return isHidden || visType === _visTypes.VIS_TYPE_SCATTER ? {
|
|
126
52
|
enabled: false
|
|
127
|
-
} : Object.assign({}, getLegend(mergedFontStyle, dashboard, visType), getItemStyle(mergedFontStyle, dashboard)
|
|
128
|
-
useHTML: true,
|
|
129
|
-
symbolWidth: 0.001,
|
|
130
|
-
symbolHeight: 0.001,
|
|
131
|
-
labelFormatter: function () {
|
|
132
|
-
var _this$userOptions, _this$userOptions2;
|
|
133
|
-
|
|
134
|
-
return formatLabel({
|
|
135
|
-
seriesId: (_this$userOptions = this.userOptions) === null || _this$userOptions === void 0 ? void 0 : _this$userOptions.id,
|
|
136
|
-
seriesColor: this.color,
|
|
137
|
-
seriesName: this.name,
|
|
138
|
-
seriesType: (_this$userOptions2 = this.userOptions) === null || _this$userOptions2 === void 0 ? void 0 : _this$userOptions2.type,
|
|
139
|
-
metaData,
|
|
140
|
-
displayStrategy,
|
|
141
|
-
legendSets,
|
|
142
|
-
fontStyle: mergedFontStyle,
|
|
143
|
-
visType
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
53
|
+
} : Object.assign({}, getLegend(mergedFontStyle, dashboard, visType), getItemStyle(mergedFontStyle, dashboard));
|
|
147
54
|
}
|
|
@@ -11,6 +11,8 @@ var _axis = require("../../../../../modules/axis.js");
|
|
|
11
11
|
|
|
12
12
|
var _axisHasRelativeItems = require("../../../../../modules/layout/axisHasRelativeItems.js");
|
|
13
13
|
|
|
14
|
+
var _legends = require("../../../../../modules/legends.js");
|
|
15
|
+
|
|
14
16
|
var _visTypes = require("../../../../../modules/visTypes.js");
|
|
15
17
|
|
|
16
18
|
var _axisId = require("../../../../util/axisId.js");
|
|
@@ -95,12 +97,21 @@ function getIdColorMap(series, layout, extraOptions) {
|
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
function getDefault(
|
|
100
|
+
function getDefault(_ref) {
|
|
101
|
+
let {
|
|
102
|
+
series,
|
|
103
|
+
metaData,
|
|
104
|
+
layout,
|
|
105
|
+
isStacked,
|
|
106
|
+
extraOptions,
|
|
107
|
+
legendSets,
|
|
108
|
+
displayStrategy
|
|
109
|
+
} = _ref;
|
|
99
110
|
const fullIdAxisMap = (0, _customAxes.getFullIdAxisMap)(layout.series, series);
|
|
100
111
|
const idColorMap = getIdColorMap(series, layout, extraOptions);
|
|
101
112
|
const indexColorPatternMap = getIndexColorPatternMap(series, layout, extraOptions);
|
|
102
113
|
series.forEach((seriesObj, index) => {
|
|
103
|
-
var _seriesObj$custom, _layout$series2;
|
|
114
|
+
var _seriesObj$custom, _layout$series2, _metaData$seriesObj$i;
|
|
104
115
|
|
|
105
116
|
// show values
|
|
106
117
|
if (!seriesObj.dataLabels && (layout.showValues || layout.showData)) {
|
|
@@ -160,6 +171,15 @@ function getDefault(series, metaData, layout, isStacked, extraOptions) {
|
|
|
160
171
|
if (extraOptions.yearlySeries) {
|
|
161
172
|
seriesObj.name = extraOptions.yearlySeries[index];
|
|
162
173
|
}
|
|
174
|
+
|
|
175
|
+
seriesObj.legendSet = (0, _legends.getLegendSetByDisplayStrategy)({
|
|
176
|
+
displayStrategy,
|
|
177
|
+
legendSets,
|
|
178
|
+
legendSetId: (_metaData$seriesObj$i = metaData[seriesObj.id]) === null || _metaData$seriesObj$i === void 0 ? void 0 : _metaData$seriesObj$i.legendSet
|
|
179
|
+
});
|
|
180
|
+
seriesObj.marker = {
|
|
181
|
+
enabled: false
|
|
182
|
+
};
|
|
163
183
|
}); // DHIS2-701: use cumulative values
|
|
164
184
|
|
|
165
185
|
if (layout.cumulativeValues === true) {
|
|
@@ -169,7 +189,17 @@ function getDefault(series, metaData, layout, isStacked, extraOptions) {
|
|
|
169
189
|
return series;
|
|
170
190
|
}
|
|
171
191
|
|
|
172
|
-
function _default(
|
|
192
|
+
function _default(_ref2) {
|
|
193
|
+
let {
|
|
194
|
+
series,
|
|
195
|
+
metaData,
|
|
196
|
+
layout,
|
|
197
|
+
isStacked,
|
|
198
|
+
extraOptions,
|
|
199
|
+
legendSets,
|
|
200
|
+
displayStrategy
|
|
201
|
+
} = _ref2;
|
|
202
|
+
|
|
173
203
|
switch (layout.type) {
|
|
174
204
|
case _visTypes.VIS_TYPE_PIE:
|
|
175
205
|
series = (0, _pie.default)(series, Object.values(getIdColorMap(series, layout, extraOptions)));
|
|
@@ -184,7 +214,15 @@ function _default(series, metaData, layout, isStacked, extraOptions) {
|
|
|
184
214
|
break;
|
|
185
215
|
|
|
186
216
|
default:
|
|
187
|
-
series = getDefault(
|
|
217
|
+
series = getDefault({
|
|
218
|
+
series,
|
|
219
|
+
metaData,
|
|
220
|
+
layout,
|
|
221
|
+
isStacked,
|
|
222
|
+
extraOptions,
|
|
223
|
+
legendSets,
|
|
224
|
+
displayStrategy
|
|
225
|
+
});
|
|
188
226
|
}
|
|
189
227
|
|
|
190
228
|
series.forEach(seriesObj => {
|
|
@@ -29,6 +29,38 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
29
29
|
(0, _patternFill.default)(_highcharts.default);
|
|
30
30
|
(0, _boost.default)(_highcharts.default);
|
|
31
31
|
|
|
32
|
+
function drawLegendSymbolWrap() {
|
|
33
|
+
const pick = _highcharts.default.pick;
|
|
34
|
+
|
|
35
|
+
_highcharts.default.wrap(_highcharts.default.seriesTypes.column.prototype, 'drawLegendSymbol', function (proceed, legend, item) {
|
|
36
|
+
var _this$options$legendS, _this$options$legendS2;
|
|
37
|
+
|
|
38
|
+
if ((_this$options$legendS = this.options.legendSet) !== null && _this$options$legendS !== void 0 && (_this$options$legendS2 = _this$options$legendS.legends) !== null && _this$options$legendS2 !== void 0 && _this$options$legendS2.length) {
|
|
39
|
+
const ys = legend.baseline - legend.symbolHeight + 1,
|
|
40
|
+
// y start
|
|
41
|
+
x = legend.symbolWidth / 2 > 8 ? legend.symbolWidth / 2 : 8,
|
|
42
|
+
// x start
|
|
43
|
+
ye = legend.symbolHeight + ys; // y end
|
|
44
|
+
|
|
45
|
+
const legends = this.options.legendSet.legends.sort((a, b) => a.startValue - b.startValue);
|
|
46
|
+
this.chart.renderer.path(['M', x, ys, 'A', 1, 1, 0, 0, 0, x, ye, 'V', ys]).attr({
|
|
47
|
+
fill: legends[legends.length >= 5 ? 1 : 0].color
|
|
48
|
+
}).add(this.legendGroup);
|
|
49
|
+
this.chart.renderer.path(['M', x, ye, 'A', 1, 1, 0, 0, 0, x, ys, 'V', ye]).attr({
|
|
50
|
+
fill: legends[legends.length >= 5 ? legends.length - 2 : legends.length - 1].color
|
|
51
|
+
}).add(this.legendGroup);
|
|
52
|
+
} else {
|
|
53
|
+
var options = legend.options,
|
|
54
|
+
symbolHeight = legend.symbolHeight,
|
|
55
|
+
square = options.squareSymbol,
|
|
56
|
+
symbolWidth = square ? symbolHeight : legend.symbolWidth;
|
|
57
|
+
item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2)).addClass('highcharts-point').attr({
|
|
58
|
+
zIndex: 3
|
|
59
|
+
}).add(item.legendGroup);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
32
64
|
function _default(config, el) {
|
|
33
65
|
if (config) {
|
|
34
66
|
config.chart.renderTo = el || config.chart.renderTo; // silence warning about accessibility
|
|
@@ -43,6 +75,7 @@ function _default(config, el) {
|
|
|
43
75
|
});
|
|
44
76
|
}
|
|
45
77
|
|
|
78
|
+
drawLegendSymbolWrap();
|
|
46
79
|
return new _highcharts.default.Chart(config);
|
|
47
80
|
}
|
|
48
81
|
}
|
|
@@ -103,7 +103,7 @@ export const OpenFileDialog = _ref2 => {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (filters.searchTerm) {
|
|
106
|
-
queryFilters.push("
|
|
106
|
+
queryFilters.push("identifiable:token:".concat(filters.searchTerm));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
return queryFilters;
|
|
@@ -200,9 +200,9 @@
|
|
|
200
200
|
"Bi-weekly": "Tweewekelijks",
|
|
201
201
|
"Monthly": "Maandelijks",
|
|
202
202
|
"Bi-monthly": "Tweemaandelijks",
|
|
203
|
-
"Quarterly": "",
|
|
204
|
-
"Six-monthly": "",
|
|
205
|
-
"Six-monthly April": "",
|
|
203
|
+
"Quarterly": "Driemaandelijks",
|
|
204
|
+
"Six-monthly": "Zesmaandelijks",
|
|
205
|
+
"Six-monthly April": "Zesmaandelijks april",
|
|
206
206
|
"Yearly": "Jaarlijks",
|
|
207
207
|
"Financial year (Start November)": "Financieel jaar (Start november)",
|
|
208
208
|
"Financial year (Start October)": "Financieel jaar (Start oktober)",
|
|
@@ -11,4 +11,19 @@ export const getLegendByValueFromLegendSet = (legendSet, value) => {
|
|
|
11
11
|
export const getColorByValueFromLegendSet = (legendSet, value) => {
|
|
12
12
|
const legend = getLegendByValueFromLegendSet(legendSet, value);
|
|
13
13
|
return legend && legend.color;
|
|
14
|
+
};
|
|
15
|
+
export const getLegendSetByDisplayStrategy = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
displayStrategy,
|
|
18
|
+
legendSets,
|
|
19
|
+
legendSetId
|
|
20
|
+
} = _ref;
|
|
21
|
+
|
|
22
|
+
if (displayStrategy === LEGEND_DISPLAY_STRATEGY_FIXED && legendSets.length) {
|
|
23
|
+
return legendSets[0];
|
|
24
|
+
} else if (displayStrategy === LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM) {
|
|
25
|
+
return legendSets.find(legendSet => legendSet.id === legendSetId);
|
|
26
|
+
} else {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
14
29
|
};
|
|
@@ -31,7 +31,7 @@ const getTransformedExtraOptions = extraOptions => ({ ...extraOptions,
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
export default function (_ref) {
|
|
34
|
-
var _layout$seriesKey, _layout$seriesKey2, _layout$seriesKey2$la,
|
|
34
|
+
var _layout$legend, _layout$seriesKey, _layout$seriesKey2, _layout$seriesKey2$la, _config$xAxis;
|
|
35
35
|
|
|
36
36
|
let {
|
|
37
37
|
store,
|
|
@@ -77,16 +77,21 @@ export default function (_ref) {
|
|
|
77
77
|
// y-axis
|
|
78
78
|
yAxis: getYAxis(_layout, series, _extraOptions),
|
|
79
79
|
// series
|
|
80
|
-
series: getSeries(
|
|
80
|
+
series: getSeries({
|
|
81
|
+
series: series.slice(),
|
|
82
|
+
metaData: store.data[0].metaData.items,
|
|
83
|
+
layout: _layout,
|
|
84
|
+
isStacked: stacked,
|
|
85
|
+
extraOptions: _extraOptions,
|
|
86
|
+
legendSets,
|
|
87
|
+
displayStrategy: (_layout$legend = _layout.legend) === null || _layout$legend === void 0 ? void 0 : _layout$legend.strategy
|
|
88
|
+
}),
|
|
81
89
|
// legend
|
|
82
90
|
legend: getLegend({
|
|
83
91
|
isHidden: (_layout$seriesKey = _layout.seriesKey) === null || _layout$seriesKey === void 0 ? void 0 : _layout$seriesKey.hidden,
|
|
84
92
|
fontStyle: (_layout$seriesKey2 = _layout.seriesKey) === null || _layout$seriesKey2 === void 0 ? void 0 : (_layout$seriesKey2$la = _layout$seriesKey2.label) === null || _layout$seriesKey2$la === void 0 ? void 0 : _layout$seriesKey2$la.fontStyle,
|
|
85
93
|
visType: _layout.type,
|
|
86
|
-
dashboard: _extraOptions.dashboard
|
|
87
|
-
legendSets,
|
|
88
|
-
metaData: store.data[0].metaData.items,
|
|
89
|
-
displayStrategy: (_layout$legend = _layout.legend) === null || _layout$legend === void 0 ? void 0 : _layout$legend.strategy
|
|
94
|
+
dashboard: _extraOptions.dashboard
|
|
90
95
|
}),
|
|
91
96
|
// pane
|
|
92
97
|
pane: getPane(_layout.type),
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { FONT_STYLE_OPTION_FONT_SIZE, FONT_STYLE_OPTION_TEXT_COLOR, FONT_STYLE_OPTION_BOLD, FONT_STYLE_OPTION_ITALIC, FONT_STYLE_OPTION_TEXT_ALIGN, FONT_STYLE_LEGEND, mergeFontStyleWithDefault } from '../../../../modules/fontStyle.js';
|
|
2
|
-
import {
|
|
3
|
-
import { isLegendSetType, isVerticalType, VIS_TYPE_LINE, VIS_TYPE_SCATTER } from '../../../../modules/visTypes.js';
|
|
4
|
-
import { colorSets, COLOR_SET_PATTERNS } from '../../../util/colors/colorSets.js';
|
|
2
|
+
import { isVerticalType, VIS_TYPE_SCATTER } from '../../../../modules/visTypes.js';
|
|
5
3
|
import { getTextAlignOption } from './getTextAlignOption.js';
|
|
6
|
-
import getType from './type.js';
|
|
7
4
|
const DASHBOARD_ITEM_STYLE = {
|
|
8
5
|
fontSize: '11px',
|
|
9
6
|
fontWeight: 500
|
|
@@ -33,100 +30,15 @@ function getLegend(fontStyle, dashboard, visType) {
|
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
let {
|
|
38
|
-
displayStrategy,
|
|
39
|
-
legendSets,
|
|
40
|
-
legendSetId
|
|
41
|
-
} = _ref;
|
|
42
|
-
|
|
43
|
-
if (displayStrategy === LEGEND_DISPLAY_STRATEGY_FIXED && legendSets.length) {
|
|
44
|
-
return legendSets[0];
|
|
45
|
-
} else if (displayStrategy === LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM) {
|
|
46
|
-
return legendSets.find(legendSet => legendSet.id === legendSetId);
|
|
47
|
-
} else {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const formatLabel = _ref2 => {
|
|
53
|
-
var _metaData$seriesId, _legendSet$legends;
|
|
54
|
-
|
|
55
|
-
let {
|
|
56
|
-
seriesId,
|
|
57
|
-
seriesColor,
|
|
58
|
-
seriesName,
|
|
59
|
-
seriesType,
|
|
60
|
-
metaData,
|
|
61
|
-
displayStrategy,
|
|
62
|
-
legendSets,
|
|
63
|
-
fontStyle,
|
|
64
|
-
visType
|
|
65
|
-
} = _ref2;
|
|
66
|
-
const legendSet = getLegendSetByDisplayStrategy({
|
|
67
|
-
displayStrategy,
|
|
68
|
-
legendSets,
|
|
69
|
-
legendSetId: (_metaData$seriesId = metaData[seriesId]) === null || _metaData$seriesId === void 0 ? void 0 : _metaData$seriesId.legendSet
|
|
70
|
-
});
|
|
71
|
-
const result = []; // Note: Highcharts strips out 'data-test' and similar attributes, hence 'class="data-test-..." was used instead
|
|
72
|
-
|
|
73
|
-
result.push('<div style="display: flex; align-items: center; margin-bottom: 4px;" class="data-test-series-key-item">');
|
|
74
|
-
|
|
75
|
-
if ((!seriesId || seriesId.startsWith('trendline')) && seriesType === getType(VIS_TYPE_LINE).type) {
|
|
76
|
-
// trendline
|
|
77
|
-
result.push("<span style=\"height: ".concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 6.5, "px; width: ").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE], "px; background-color: ").concat(seriesColor, "; display: inline-block;\"></span>"));
|
|
78
|
-
result.push("<span style=\"margin-left: 8px\" class=\"data-test-series-key-item-name\">".concat(seriesName, "</span>"));
|
|
79
|
-
} else if (legendSet !== null && legendSet !== void 0 && (_legendSet$legends = legendSet.legends) !== null && _legendSet$legends !== void 0 && _legendSet$legends.length && isLegendSetType(visType) && seriesType !== getType(VIS_TYPE_LINE).type) {
|
|
80
|
-
// item with legend set
|
|
81
|
-
legendSet.legends.sort((a, b) => a.startValue - b.startValue).forEach((legend, index) => result.push("<svg width=\"".concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE], "\" height=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE], "\" style=\"margin-right:-5px; z-index: ").concat(legendSet.legends.length - index, "\" class=\"data-test-series-key-item-bullet\">\n <circle cx=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" cy=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" r=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" fill=\"").concat(legend.color, "\"></circle>\n </svg>")));
|
|
82
|
-
result.push("<span style=\"margin-left: 8px\" class=\"data-test-series-key-item-name\">".concat(seriesName, "</span>"));
|
|
83
|
-
} else {
|
|
84
|
-
// regular item (not a trendline, no applied legend set)
|
|
85
|
-
if ((seriesColor === null || seriesColor === void 0 ? void 0 : seriesColor.patternIndex) !== undefined) {
|
|
86
|
-
const pattern = colorSets[COLOR_SET_PATTERNS].patterns[seriesColor.patternIndex];
|
|
87
|
-
result.push("<svg style=\"height: ".concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE], "px; width: ").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE], "px; display: inline-block; margin-right:5px\" class=\"data-test-series-key-item-bullet\">\n <defs>\n <pattern id=\"pattern").concat(seriesColor.patternIndex, "\" patternUnits=\"userSpaceOnUse\" width=\"").concat(pattern.width, "\" height=\"").concat(pattern.height, "\">\n <path stroke=\"").concat(pattern.color, "\" d=\"").concat(pattern.path, "\"/>\n </pattern>\n </defs>\n <circle cx=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" cy=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" r=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" fill=\"url(#pattern").concat(seriesColor.patternIndex, ")\"/>\n </svg>"));
|
|
88
|
-
} else {
|
|
89
|
-
result.push("<svg width=\"".concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE], "\" height=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE], "\" style=\"margin-right:5px\" class=\"data-test-series-key-item-bullet\">\n <circle cx=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" cy=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" r=\"").concat(fontStyle[FONT_STYLE_OPTION_FONT_SIZE] / 2, "\" fill=\"").concat(seriesColor, "\"></circle>\n </svg>"));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
result.push("<span class=\"data-test-series-key-item-name\">".concat(seriesName, "</span>"));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
result.push('</div>');
|
|
96
|
-
return result.join('');
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export default function (_ref3) {
|
|
33
|
+
export default function (_ref) {
|
|
100
34
|
let {
|
|
101
35
|
isHidden,
|
|
102
36
|
fontStyle,
|
|
103
37
|
visType,
|
|
104
|
-
dashboard
|
|
105
|
-
|
|
106
|
-
metaData,
|
|
107
|
-
displayStrategy
|
|
108
|
-
} = _ref3;
|
|
38
|
+
dashboard
|
|
39
|
+
} = _ref;
|
|
109
40
|
const mergedFontStyle = mergeFontStyleWithDefault(fontStyle, FONT_STYLE_LEGEND);
|
|
110
41
|
return isHidden || visType === VIS_TYPE_SCATTER ? {
|
|
111
42
|
enabled: false
|
|
112
|
-
} : Object.assign({}, getLegend(mergedFontStyle, dashboard, visType), getItemStyle(mergedFontStyle, dashboard)
|
|
113
|
-
useHTML: true,
|
|
114
|
-
symbolWidth: 0.001,
|
|
115
|
-
symbolHeight: 0.001,
|
|
116
|
-
labelFormatter: function () {
|
|
117
|
-
var _this$userOptions, _this$userOptions2;
|
|
118
|
-
|
|
119
|
-
return formatLabel({
|
|
120
|
-
seriesId: (_this$userOptions = this.userOptions) === null || _this$userOptions === void 0 ? void 0 : _this$userOptions.id,
|
|
121
|
-
seriesColor: this.color,
|
|
122
|
-
seriesName: this.name,
|
|
123
|
-
seriesType: (_this$userOptions2 = this.userOptions) === null || _this$userOptions2 === void 0 ? void 0 : _this$userOptions2.type,
|
|
124
|
-
metaData,
|
|
125
|
-
displayStrategy,
|
|
126
|
-
legendSets,
|
|
127
|
-
fontStyle: mergedFontStyle,
|
|
128
|
-
visType
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
43
|
+
} : Object.assign({}, getLegend(mergedFontStyle, dashboard, visType), getItemStyle(mergedFontStyle, dashboard));
|
|
132
44
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { colors } from '@dhis2/ui';
|
|
2
2
|
import { hasCustomAxes } from '../../../../../modules/axis.js';
|
|
3
3
|
import { axisHasRelativeItems } from '../../../../../modules/layout/axisHasRelativeItems.js';
|
|
4
|
+
import { getLegendSetByDisplayStrategy } from '../../../../../modules/legends.js';
|
|
4
5
|
import { VIS_TYPE_PIE, VIS_TYPE_GAUGE, isDualAxisType, isYearOverYear, VIS_TYPE_LINE, VIS_TYPE_SCATTER } from '../../../../../modules/visTypes.js';
|
|
5
6
|
import { getAxisStringFromId } from '../../../../util/axisId.js';
|
|
6
7
|
import { colorSets, COLOR_SET_PATTERNS } from '../../../../util/colors/colorSets.js';
|
|
@@ -73,12 +74,21 @@ function getIdColorMap(series, layout, extraOptions) {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
function getDefault(
|
|
77
|
+
function getDefault(_ref) {
|
|
78
|
+
let {
|
|
79
|
+
series,
|
|
80
|
+
metaData,
|
|
81
|
+
layout,
|
|
82
|
+
isStacked,
|
|
83
|
+
extraOptions,
|
|
84
|
+
legendSets,
|
|
85
|
+
displayStrategy
|
|
86
|
+
} = _ref;
|
|
77
87
|
const fullIdAxisMap = getFullIdAxisMap(layout.series, series);
|
|
78
88
|
const idColorMap = getIdColorMap(series, layout, extraOptions);
|
|
79
89
|
const indexColorPatternMap = getIndexColorPatternMap(series, layout, extraOptions);
|
|
80
90
|
series.forEach((seriesObj, index) => {
|
|
81
|
-
var _seriesObj$custom, _layout$series2;
|
|
91
|
+
var _seriesObj$custom, _layout$series2, _metaData$seriesObj$i;
|
|
82
92
|
|
|
83
93
|
// show values
|
|
84
94
|
if (!seriesObj.dataLabels && (layout.showValues || layout.showData)) {
|
|
@@ -138,6 +148,15 @@ function getDefault(series, metaData, layout, isStacked, extraOptions) {
|
|
|
138
148
|
if (extraOptions.yearlySeries) {
|
|
139
149
|
seriesObj.name = extraOptions.yearlySeries[index];
|
|
140
150
|
}
|
|
151
|
+
|
|
152
|
+
seriesObj.legendSet = getLegendSetByDisplayStrategy({
|
|
153
|
+
displayStrategy,
|
|
154
|
+
legendSets,
|
|
155
|
+
legendSetId: (_metaData$seriesObj$i = metaData[seriesObj.id]) === null || _metaData$seriesObj$i === void 0 ? void 0 : _metaData$seriesObj$i.legendSet
|
|
156
|
+
});
|
|
157
|
+
seriesObj.marker = {
|
|
158
|
+
enabled: false
|
|
159
|
+
};
|
|
141
160
|
}); // DHIS2-701: use cumulative values
|
|
142
161
|
|
|
143
162
|
if (layout.cumulativeValues === true) {
|
|
@@ -147,7 +166,17 @@ function getDefault(series, metaData, layout, isStacked, extraOptions) {
|
|
|
147
166
|
return series;
|
|
148
167
|
}
|
|
149
168
|
|
|
150
|
-
export default function (
|
|
169
|
+
export default function (_ref2) {
|
|
170
|
+
let {
|
|
171
|
+
series,
|
|
172
|
+
metaData,
|
|
173
|
+
layout,
|
|
174
|
+
isStacked,
|
|
175
|
+
extraOptions,
|
|
176
|
+
legendSets,
|
|
177
|
+
displayStrategy
|
|
178
|
+
} = _ref2;
|
|
179
|
+
|
|
151
180
|
switch (layout.type) {
|
|
152
181
|
case VIS_TYPE_PIE:
|
|
153
182
|
series = getPie(series, Object.values(getIdColorMap(series, layout, extraOptions)));
|
|
@@ -162,7 +191,15 @@ export default function (series, metaData, layout, isStacked, extraOptions) {
|
|
|
162
191
|
break;
|
|
163
192
|
|
|
164
193
|
default:
|
|
165
|
-
series = getDefault(
|
|
194
|
+
series = getDefault({
|
|
195
|
+
series,
|
|
196
|
+
metaData,
|
|
197
|
+
layout,
|
|
198
|
+
isStacked,
|
|
199
|
+
extraOptions,
|
|
200
|
+
legendSets,
|
|
201
|
+
displayStrategy
|
|
202
|
+
});
|
|
166
203
|
}
|
|
167
204
|
|
|
168
205
|
series.forEach(seriesObj => {
|
|
@@ -12,6 +12,38 @@ HNDTD(H);
|
|
|
12
12
|
HE(H);
|
|
13
13
|
HPF(H);
|
|
14
14
|
HB(H);
|
|
15
|
+
|
|
16
|
+
function drawLegendSymbolWrap() {
|
|
17
|
+
const pick = H.pick;
|
|
18
|
+
H.wrap(H.seriesTypes.column.prototype, 'drawLegendSymbol', function (proceed, legend, item) {
|
|
19
|
+
var _this$options$legendS, _this$options$legendS2;
|
|
20
|
+
|
|
21
|
+
if ((_this$options$legendS = this.options.legendSet) !== null && _this$options$legendS !== void 0 && (_this$options$legendS2 = _this$options$legendS.legends) !== null && _this$options$legendS2 !== void 0 && _this$options$legendS2.length) {
|
|
22
|
+
const ys = legend.baseline - legend.symbolHeight + 1,
|
|
23
|
+
// y start
|
|
24
|
+
x = legend.symbolWidth / 2 > 8 ? legend.symbolWidth / 2 : 8,
|
|
25
|
+
// x start
|
|
26
|
+
ye = legend.symbolHeight + ys; // y end
|
|
27
|
+
|
|
28
|
+
const legends = this.options.legendSet.legends.sort((a, b) => a.startValue - b.startValue);
|
|
29
|
+
this.chart.renderer.path(['M', x, ys, 'A', 1, 1, 0, 0, 0, x, ye, 'V', ys]).attr({
|
|
30
|
+
fill: legends[legends.length >= 5 ? 1 : 0].color
|
|
31
|
+
}).add(this.legendGroup);
|
|
32
|
+
this.chart.renderer.path(['M', x, ye, 'A', 1, 1, 0, 0, 0, x, ys, 'V', ye]).attr({
|
|
33
|
+
fill: legends[legends.length >= 5 ? legends.length - 2 : legends.length - 1].color
|
|
34
|
+
}).add(this.legendGroup);
|
|
35
|
+
} else {
|
|
36
|
+
var options = legend.options,
|
|
37
|
+
symbolHeight = legend.symbolHeight,
|
|
38
|
+
square = options.squareSymbol,
|
|
39
|
+
symbolWidth = square ? symbolHeight : legend.symbolWidth;
|
|
40
|
+
item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2)).addClass('highcharts-point').attr({
|
|
41
|
+
zIndex: 3
|
|
42
|
+
}).add(item.legendGroup);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
15
47
|
export default function (config, el) {
|
|
16
48
|
if (config) {
|
|
17
49
|
config.chart.renderTo = el || config.chart.renderTo; // silence warning about accessibility
|
|
@@ -26,6 +58,7 @@ export default function (config, el) {
|
|
|
26
58
|
});
|
|
27
59
|
}
|
|
28
60
|
|
|
61
|
+
drawLegendSymbolWrap();
|
|
29
62
|
return new H.Chart(config);
|
|
30
63
|
}
|
|
31
64
|
}
|