evui 3.3.51 → 3.3.53
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/dist/evui.common.js +1436 -912
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +1436 -912
- package/dist/evui.umd.js.map +1 -1
- package/dist/evui.umd.min.js +1 -1
- package/dist/evui.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/calendar/Calendar.vue +289 -241
- package/src/components/calendar/uses.js +365 -200
- package/src/components/chart/Chart.vue +16 -6
- package/src/components/chart/chart.core.js +38 -17
- package/src/components/chart/element/element.heatmap.js +36 -12
- package/src/components/chart/model/model.store.js +18 -7
- package/src/components/chart/plugins/plugins.interaction.js +249 -98
- package/src/components/chart/scale/scale.step.js +28 -13
- package/src/components/chart/uses.js +60 -32
- package/src/components/chartBrush/chartBrush.core.js +16 -14
- package/src/components/chartGroup/ChartGroup.vue +3 -0
- package/src/components/chartGroup/uses.js +2 -0
- package/src/components/datePicker/uses.js +53 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { numberWithComma } from '@/common/utils';
|
|
2
|
-
import { cloneDeep, defaultsDeep } from 'lodash-es';
|
|
2
|
+
import { cloneDeep, defaultsDeep, inRange } from 'lodash-es';
|
|
3
3
|
|
|
4
4
|
const modules = {
|
|
5
5
|
/**
|
|
@@ -116,9 +116,22 @@ const modules = {
|
|
|
116
116
|
this.isMouseMove = false;
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
+
|
|
119
120
|
const args = { e };
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
const offset = this.getMousePosition(e);
|
|
122
|
+
|
|
123
|
+
const {
|
|
124
|
+
type: chartType,
|
|
125
|
+
selectItem: selectItemOpt,
|
|
126
|
+
selectLabel: selectLabelOpt,
|
|
127
|
+
selectSeries: selectSeriesOpt,
|
|
128
|
+
} = this.options;
|
|
129
|
+
|
|
130
|
+
const useSelectItem = selectItemOpt?.use && selectItemOpt?.useClick;
|
|
131
|
+
const useSelectLabel = selectLabelOpt?.use && selectLabelOpt?.useClick;
|
|
132
|
+
const useSelectSeries = selectSeriesOpt?.use && selectSeriesOpt?.useClick;
|
|
133
|
+
|
|
134
|
+
const setSelectedItemInfo = () => {
|
|
122
135
|
const hitInfo = this.getItemByPosition(offset, false);
|
|
123
136
|
|
|
124
137
|
({
|
|
@@ -129,29 +142,103 @@ const modules = {
|
|
|
129
142
|
acc: args.acc,
|
|
130
143
|
} = hitInfo);
|
|
131
144
|
|
|
132
|
-
if (
|
|
133
|
-
args.
|
|
145
|
+
if (hitInfo?.sId) {
|
|
146
|
+
args.selected = {
|
|
147
|
+
eventTarget: 'item',
|
|
148
|
+
seriesId: this.isDeselectItem(hitInfo) ? null : hitInfo.sId,
|
|
149
|
+
dataIndex: this.isDeselectItem(hitInfo) ? null : hitInfo.maxIndex,
|
|
150
|
+
};
|
|
134
151
|
}
|
|
152
|
+
};
|
|
135
153
|
|
|
136
|
-
|
|
137
|
-
|
|
154
|
+
const setSelectedLabelInfo = (targetAxis) => {
|
|
155
|
+
const {
|
|
156
|
+
labelIndex: clickedLabelIndex,
|
|
157
|
+
} = this.getLabelInfoByPosition(offset, targetAxis);
|
|
158
|
+
|
|
159
|
+
const {
|
|
160
|
+
dataIndex: dataIndexList,
|
|
161
|
+
} = this.regulateSelectedLabelInfo(clickedLabelIndex, targetAxis);
|
|
162
|
+
|
|
163
|
+
this.defaultSelectInfo = this.getSelectedLabelInfoWithLabelData(dataIndexList, targetAxis);
|
|
164
|
+
|
|
165
|
+
if (targetAxis) {
|
|
166
|
+
this.defaultSelectInfo.targetAxis = dataIndexList?.length ? targetAxis : null;
|
|
138
167
|
}
|
|
139
|
-
} else if (this.options.selectLabel.use && this.options.selectLabel.useClick) {
|
|
140
|
-
const offset = this.getMousePosition(e);
|
|
141
|
-
const clickedLabelInfo = this.getLabelInfoByPosition(offset);
|
|
142
|
-
const selected = this.selectLabel(clickedLabelInfo.labelIndex);
|
|
143
|
-
this.renderWithSelected(selected.dataIndex);
|
|
144
168
|
|
|
145
|
-
args.selected =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
169
|
+
args.selected = {
|
|
170
|
+
eventTarget: 'label',
|
|
171
|
+
...cloneDeep(this.defaultSelectInfo),
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const setSelectedSeriesInfo = () => {
|
|
176
|
+
const hitInfo = this.getSeriesInfoByPosition(offset);
|
|
149
177
|
if (hitInfo.sId !== null) {
|
|
150
|
-
const
|
|
151
|
-
this.
|
|
178
|
+
const allSelectedList = this.updateSelectedSeriesInfo(hitInfo.sId);
|
|
179
|
+
this.defaultSelectInfo.seriesId = allSelectedList.seriesId;
|
|
180
|
+
|
|
181
|
+
args.selected = {
|
|
182
|
+
eventTarget: 'series',
|
|
183
|
+
...cloneDeep(this.defaultSelectInfo),
|
|
184
|
+
};
|
|
152
185
|
}
|
|
186
|
+
};
|
|
153
187
|
|
|
154
|
-
|
|
188
|
+
switch (chartType) {
|
|
189
|
+
case 'line': {
|
|
190
|
+
if (useSelectItem) {
|
|
191
|
+
setSelectedItemInfo();
|
|
192
|
+
} else if (useSelectLabel) {
|
|
193
|
+
setSelectedLabelInfo();
|
|
194
|
+
} else if (useSelectSeries) {
|
|
195
|
+
setSelectedSeriesInfo();
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
case 'bar': {
|
|
201
|
+
if (useSelectItem) {
|
|
202
|
+
setSelectedItemInfo();
|
|
203
|
+
} else if (useSelectLabel) {
|
|
204
|
+
setSelectedLabelInfo();
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
case 'heatMap': {
|
|
210
|
+
if (useSelectItem && useSelectLabel) {
|
|
211
|
+
const { useBothAxis } = selectLabelOpt;
|
|
212
|
+
|
|
213
|
+
const location = this.getClickedLocation(offset);
|
|
214
|
+
|
|
215
|
+
if (location === 'chartBackground') {
|
|
216
|
+
this.clearSelectedLabelInfo();
|
|
217
|
+
args.deselected = { eventTarget: 'label' };
|
|
218
|
+
setSelectedItemInfo();
|
|
219
|
+
} else if (location === 'yAxis' || location === 'xAxis') {
|
|
220
|
+
this.clearSelectedItemInfo();
|
|
221
|
+
args.deselected = { eventTarget: 'item' };
|
|
222
|
+
setSelectedLabelInfo(useBothAxis ? location : null);
|
|
223
|
+
}
|
|
224
|
+
} else if (useSelectItem) {
|
|
225
|
+
setSelectedItemInfo();
|
|
226
|
+
} else if (useSelectLabel) {
|
|
227
|
+
setSelectedLabelInfo();
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
case 'pie':
|
|
233
|
+
case 'scatter': {
|
|
234
|
+
if (useSelectItem) {
|
|
235
|
+
setSelectedItemInfo();
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
default:
|
|
241
|
+
break;
|
|
155
242
|
}
|
|
156
243
|
|
|
157
244
|
if (typeof this.listeners.click === 'function') {
|
|
@@ -300,7 +387,7 @@ const modules = {
|
|
|
300
387
|
data: this.findSelectedItems(dragInfo),
|
|
301
388
|
range: type === 'heatMap'
|
|
302
389
|
? this.getSelectionRangeForHeatMap(dragInfo)
|
|
303
|
-
: this.
|
|
390
|
+
: this.getSelectionRange(dragInfo),
|
|
304
391
|
};
|
|
305
392
|
|
|
306
393
|
this.dragInfoBackup = defaultsDeep({}, dragInfo);
|
|
@@ -570,11 +657,12 @@ const modules = {
|
|
|
570
657
|
},
|
|
571
658
|
|
|
572
659
|
/**
|
|
573
|
-
*
|
|
660
|
+
* Select Item
|
|
661
|
+
* Set backup data that selected item information
|
|
662
|
+
* render chart
|
|
574
663
|
* @param targetInfo {object} '{ dataIndex: number, seriesID: string }'
|
|
575
|
-
* @param chartType {string} 'bar', 'line', 'pie', 'scatter'
|
|
664
|
+
* @param chartType {string} 'bar', 'line', 'pie', 'scatter', 'heatMap'
|
|
576
665
|
*
|
|
577
|
-
* @returns {boolean}
|
|
578
666
|
*/
|
|
579
667
|
selectItemByData(targetInfo, chartType) {
|
|
580
668
|
this.defaultSelectItemInfo = targetInfo;
|
|
@@ -586,94 +674,102 @@ const modules = {
|
|
|
586
674
|
sId: targetInfo.seriesID,
|
|
587
675
|
};
|
|
588
676
|
} else {
|
|
589
|
-
|
|
590
|
-
return false;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
foundInfo = this.getItem(targetInfo, false);
|
|
677
|
+
foundInfo = isNaN(targetInfo?.dataIndex) ? null : this.getItem(targetInfo, false);
|
|
594
678
|
}
|
|
595
679
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
} else {
|
|
599
|
-
return false;
|
|
600
|
-
}
|
|
680
|
+
this.render(foundInfo);
|
|
681
|
+
},
|
|
601
682
|
|
|
602
|
-
|
|
683
|
+
/**
|
|
684
|
+
* Select Label
|
|
685
|
+
* set backup data that selected label information list
|
|
686
|
+
* render chart
|
|
687
|
+
* @param labelIndexList {number[]}
|
|
688
|
+
* @param targetAxis {string | null}
|
|
689
|
+
* @returns {boolean}
|
|
690
|
+
*/
|
|
691
|
+
selectLabelByData(labelIndexList, targetAxis) {
|
|
692
|
+
this.defaultSelectInfo = this.getSelectedLabelInfoWithLabelData(labelIndexList, targetAxis);
|
|
693
|
+
this.render();
|
|
603
694
|
},
|
|
604
695
|
|
|
605
696
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
697
|
+
* Select Series
|
|
698
|
+
* set backup data that selected series information list
|
|
699
|
+
* render chart
|
|
700
|
+
* @param seriesIdList {number[]} '
|
|
701
|
+
* @returns {boolean}
|
|
608
702
|
*/
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
this.defaultSelectInfo.dataIndex = list;
|
|
612
|
-
} else if (this.options.selectSeries.use) {
|
|
613
|
-
this.defaultSelectInfo.seriesId = list;
|
|
614
|
-
}
|
|
615
|
-
this.initSelectedInfo();
|
|
703
|
+
selectSeriesByData(seriesIdList) {
|
|
704
|
+
this.defaultSelectInfo.seriesId = seriesIdList;
|
|
616
705
|
this.render();
|
|
617
706
|
},
|
|
618
707
|
|
|
708
|
+
|
|
619
709
|
/**
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
*
|
|
710
|
+
* Get each series data and label text
|
|
711
|
+
* @param labelIndexList{number[]}
|
|
712
|
+
* @param targetAxis{string | null}
|
|
713
|
+
* @returns {object[]}
|
|
623
714
|
*/
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
715
|
+
getSelectedLabelInfoWithLabelData(labelIndexList, targetAxis) {
|
|
716
|
+
const { selectLabel: selectLabelOpt, type: chartType, horizontal } = this.options;
|
|
717
|
+
const result = cloneDeep(this.defaultSelectInfo);
|
|
718
|
+
result.dataIndex = labelIndexList;
|
|
719
|
+
|
|
720
|
+
switch (chartType) {
|
|
721
|
+
case 'bar':
|
|
722
|
+
case 'line': {
|
|
723
|
+
result.dataIndex.splice(selectLabelOpt.limit);
|
|
724
|
+
|
|
725
|
+
result.label = result.dataIndex.map(i => this.data.labels[i]);
|
|
726
|
+
|
|
727
|
+
const dataEntries = Object.entries(this.data.data);
|
|
728
|
+
result.data = result.dataIndex.map(labelIdx => Object.fromEntries(
|
|
729
|
+
dataEntries.map(([sId, data]) => [sId, data[labelIdx]])));
|
|
730
|
+
break;
|
|
628
731
|
}
|
|
629
732
|
|
|
630
|
-
|
|
631
|
-
this.
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
733
|
+
case 'heatMap': {
|
|
734
|
+
const { limit, useBothAxis } = this.options.selectLabel;
|
|
634
735
|
|
|
635
|
-
|
|
636
|
-
const infoObj = this.defaultSelectInfo;
|
|
637
|
-
infoObj.dataIndex.splice(limit);
|
|
638
|
-
infoObj.label = infoObj.dataIndex.map(i => this.data.labels[i]);
|
|
639
|
-
const dataEntries = Object.entries(this.data.data);
|
|
640
|
-
infoObj.data = infoObj.dataIndex.map(labelIdx => Object.fromEntries(
|
|
641
|
-
dataEntries.map(([sId, data]) => [sId, data[labelIdx]])));
|
|
642
|
-
} else if (this.options.selectSeries.use) {
|
|
643
|
-
if (!this.defaultSelectInfo) {
|
|
644
|
-
this.defaultSelectInfo = { seriesId: [] };
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
},
|
|
736
|
+
result.dataIndex.splice(limit);
|
|
648
737
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
const isHorizontal = this.options.horizontal;
|
|
738
|
+
let targetAxisDirection;
|
|
739
|
+
if (useBothAxis) {
|
|
740
|
+
targetAxisDirection = targetAxis === 'yAxis' ? 'y' : 'x';
|
|
741
|
+
} else {
|
|
742
|
+
targetAxisDirection = horizontal ? 'y' : 'x';
|
|
743
|
+
}
|
|
656
744
|
|
|
657
|
-
|
|
658
|
-
infoObj.dataIndex.splice(limit);
|
|
745
|
+
result.label = result.dataIndex.map(i => this.data.labels[targetAxisDirection][i]);
|
|
659
746
|
|
|
660
|
-
|
|
661
|
-
|
|
747
|
+
const dataValues = Object.values(this.data.data)[0];
|
|
748
|
+
result.data = dataValues.filter(({ x, y }) =>
|
|
749
|
+
(result.label.includes(targetAxisDirection === 'y' ? y : x)),
|
|
750
|
+
);
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
default:
|
|
755
|
+
break;
|
|
756
|
+
}
|
|
662
757
|
|
|
663
|
-
|
|
664
|
-
infoObj.data = dataValues.filter(({ x, y }) =>
|
|
665
|
-
(infoObj.label.includes(isHorizontal ? y : x)),
|
|
666
|
-
);
|
|
758
|
+
return result;
|
|
667
759
|
},
|
|
668
760
|
|
|
669
761
|
/**
|
|
670
762
|
* Add or delete selected label index, according to policy and option
|
|
671
|
-
*
|
|
672
|
-
* @param
|
|
763
|
+
* @param labelIndex {number}
|
|
764
|
+
* @param targetAxis {string | null}
|
|
765
|
+
* @returns after {number[]} '[0, 1 ...]' result Label index List
|
|
673
766
|
*/
|
|
674
|
-
|
|
767
|
+
regulateSelectedLabelInfo(labelIndex, targetAxis) {
|
|
675
768
|
const option = this.options?.selectLabel ?? {};
|
|
676
|
-
const before = this.defaultSelectInfo
|
|
769
|
+
const before = this.defaultSelectInfo?.targetAxis === targetAxis
|
|
770
|
+
? { ...this.defaultSelectInfo, targetAxis }
|
|
771
|
+
: { dataIndex: [], targetAxis };
|
|
772
|
+
|
|
677
773
|
const after = cloneDeep(before);
|
|
678
774
|
|
|
679
775
|
if (before.dataIndex.includes(labelIndex)) {
|
|
@@ -693,7 +789,12 @@ const modules = {
|
|
|
693
789
|
return after;
|
|
694
790
|
},
|
|
695
791
|
|
|
696
|
-
|
|
792
|
+
/**
|
|
793
|
+
* Add or delete selected series Index,according to policy and option
|
|
794
|
+
* @param seriesId {number}
|
|
795
|
+
* @returns after {number[]} '[0, 1 ...]' result series Id List
|
|
796
|
+
*/
|
|
797
|
+
updateSelectedSeriesInfo(seriesId) {
|
|
697
798
|
const option = this.options?.selectSeries ?? {};
|
|
698
799
|
const before = this.defaultSelectInfo ?? { seriesId: [] };
|
|
699
800
|
const after = cloneDeep(before);
|
|
@@ -749,7 +850,7 @@ const modules = {
|
|
|
749
850
|
* object.range: coordinate-based range in graph
|
|
750
851
|
* @returns {object}
|
|
751
852
|
*/
|
|
752
|
-
|
|
853
|
+
getSelectionRange({ xsp, ysp, width, height, range }) {
|
|
753
854
|
const dataRangeX = this.axesSteps.x.length ? this.axesSteps.x[0] : null;
|
|
754
855
|
const dataRangeY = this.axesSteps.y.length ? this.axesSteps.y[0] : null;
|
|
755
856
|
|
|
@@ -819,17 +920,67 @@ const modules = {
|
|
|
819
920
|
};
|
|
820
921
|
},
|
|
821
922
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
923
|
+
/**
|
|
924
|
+
* Check hitInfo is deselected Item through re-click
|
|
925
|
+
* @param hitInfo
|
|
926
|
+
* @returns {boolean}
|
|
927
|
+
*/
|
|
928
|
+
isDeselectItem(hitInfo) {
|
|
929
|
+
return this.options.selectItem.useDeselectItem
|
|
930
|
+
&& hitInfo?.maxIndex === this.defaultSelectItemInfo?.dataIndex
|
|
931
|
+
&& hitInfo?.sId === this.defaultSelectItemInfo?.seriesID
|
|
932
|
+
&& !isNaN(hitInfo?.maxIndex);
|
|
933
|
+
},
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Get mouse click location (xAxis, yAxis, chartBackground, canvas)
|
|
937
|
+
* @param offset
|
|
938
|
+
* @returns {string}
|
|
939
|
+
*/
|
|
940
|
+
getClickedLocation(offset) {
|
|
941
|
+
const [offsetX, offsetY] = offset;
|
|
942
|
+
|
|
943
|
+
const aPos = {
|
|
944
|
+
x1: this.chartRect.x1 + this.labelOffset.left,
|
|
945
|
+
x2: this.chartRect.x2 - this.labelOffset.right,
|
|
946
|
+
y1: this.chartRect.y1 + this.labelOffset.top,
|
|
947
|
+
y2: this.chartRect.y2 - this.labelOffset.bottom,
|
|
948
|
+
};
|
|
949
|
+
const xAxisStartPoint = aPos[this.axesX[0].units.rectStart];
|
|
950
|
+
const xAxisEndPoint = aPos[this.axesX[0].units.rectEnd];
|
|
951
|
+
const yAxisStartPoint = aPos[this.axesY[0].units.rectStart];
|
|
952
|
+
const yAxisEndPoint = aPos[this.axesY[0].units.rectEnd];
|
|
953
|
+
|
|
954
|
+
if (
|
|
955
|
+
inRange(offsetX, this.chartRect.x1, aPos.x1)
|
|
956
|
+
&& inRange(offsetY, yAxisStartPoint, yAxisEndPoint)
|
|
957
|
+
) {
|
|
958
|
+
return 'yAxis';
|
|
959
|
+
} else if (
|
|
960
|
+
inRange(offsetX, xAxisStartPoint, xAxisEndPoint)
|
|
961
|
+
&& inRange(offsetY, aPos.y2, this.chartRect.y2)) {
|
|
962
|
+
return 'xAxis';
|
|
963
|
+
} else if (
|
|
964
|
+
inRange(offsetX, aPos.x1, aPos.x2)
|
|
965
|
+
&& inRange(offsetY, aPos.y1, aPos.y2)) {
|
|
966
|
+
return 'chartBackground';
|
|
831
967
|
}
|
|
832
|
-
|
|
968
|
+
|
|
969
|
+
return 'canvas';
|
|
970
|
+
},
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Clear 'defaultSelectInfo'
|
|
974
|
+
*/
|
|
975
|
+
clearSelectedLabelInfo() {
|
|
976
|
+
this.defaultSelectInfo = { dataIndex: [] };
|
|
977
|
+
},
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Clear 'defaultSelectItemInfo'
|
|
981
|
+
*/
|
|
982
|
+
clearSelectedItemInfo() {
|
|
983
|
+
this.defaultSelectItemInfo = null;
|
|
833
984
|
},
|
|
834
985
|
};
|
|
835
986
|
|
|
@@ -69,13 +69,15 @@ class StepScale extends Scale {
|
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Draw axis
|
|
72
|
-
* @param {object} chartRect
|
|
73
|
-
* @param {object} labelOffset
|
|
74
|
-
* @param {object} stepInfo
|
|
72
|
+
* @param {object} chartRect min/max information
|
|
73
|
+
* @param {object} labelOffset label offset information
|
|
74
|
+
* @param {object} stepInfo label steps information
|
|
75
|
+
* @param {object} hitInfo legend Hit Info
|
|
76
|
+
* @param {object} selectedLabelInfo Selected Label Info
|
|
75
77
|
*
|
|
76
78
|
* @returns {undefined}
|
|
77
79
|
*/
|
|
78
|
-
draw(chartRect, labelOffset, stepInfo, hitInfo,
|
|
80
|
+
draw(chartRect, labelOffset, stepInfo, hitInfo, selectedLabelInfo) {
|
|
79
81
|
const ctx = this.ctx;
|
|
80
82
|
const labels = this.labels;
|
|
81
83
|
const aPos = {
|
|
@@ -146,11 +148,24 @@ class StepScale extends Scale {
|
|
|
146
148
|
linePosition = labelCenter + aliasPixel;
|
|
147
149
|
labelText = this.getLabelFormat(item, maxWidth);
|
|
148
150
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
const {
|
|
152
|
+
selectLabel: selectLabelOpt,
|
|
153
|
+
selectItem: selectItemOpt,
|
|
154
|
+
horizontal,
|
|
155
|
+
} = this.options;
|
|
156
|
+
|
|
157
|
+
let targetAxis;
|
|
158
|
+
if (selectedLabelInfo?.targetAxis) {
|
|
159
|
+
targetAxis = selectedLabelInfo?.targetAxis === 'yAxis' ? 'y' : 'x';
|
|
160
|
+
} else {
|
|
161
|
+
targetAxis = horizontal ? 'y' : 'x';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const isBlurredLabel = selectLabelOpt?.use
|
|
165
|
+
&& selectLabelOpt?.useLabelOpacity
|
|
166
|
+
&& targetAxis === this.type
|
|
167
|
+
&& selectedLabelInfo?.dataIndex?.length
|
|
168
|
+
&& !selectedLabelInfo?.dataIndex?.includes(index);
|
|
154
169
|
|
|
155
170
|
const labelColor = this.labelStyle.color;
|
|
156
171
|
let defaultOpacity = 1;
|
|
@@ -167,9 +182,9 @@ class StepScale extends Scale {
|
|
|
167
182
|
ctx.fillText(labelText, xPoint, labelPoint);
|
|
168
183
|
|
|
169
184
|
if (!isBlurredLabel
|
|
170
|
-
&&
|
|
185
|
+
&& selectItemOpt?.showLabelTip
|
|
171
186
|
&& hitInfo?.label
|
|
172
|
-
&& !
|
|
187
|
+
&& !horizontal) {
|
|
173
188
|
const selectedLabel = hitInfo.label;
|
|
174
189
|
if (selectedLabel === labelText) {
|
|
175
190
|
const height = Math.round(ctx.measureText(this.labelStyle?.fontSize).width);
|
|
@@ -182,8 +197,8 @@ class StepScale extends Scale {
|
|
|
182
197
|
borderRadius: 2,
|
|
183
198
|
arrowSize: 3,
|
|
184
199
|
text: labelText,
|
|
185
|
-
backgroundColor:
|
|
186
|
-
textColor:
|
|
200
|
+
backgroundColor: selectItemOpt?.labelTipStyle?.backgroundColor,
|
|
201
|
+
textColor: selectItemOpt?.labelTipStyle?.textColor,
|
|
187
202
|
});
|
|
188
203
|
}
|
|
189
204
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
reactive,
|
|
4
|
+
computed,
|
|
5
|
+
watch,
|
|
6
|
+
getCurrentInstance,
|
|
7
|
+
nextTick,
|
|
8
|
+
onUpdated,
|
|
9
|
+
} from 'vue';
|
|
2
10
|
import { cloneDeep, defaultsDeep, isEqual } from 'lodash-es';
|
|
3
11
|
import { getQuantity } from '@/common/utils';
|
|
4
12
|
import EvChartZoom from '@/components/chart/chartZoom.core';
|
|
@@ -162,6 +170,7 @@ const DEFAULT_OPTIONS = {
|
|
|
162
170
|
},
|
|
163
171
|
showTextTip: false,
|
|
164
172
|
showIndicator: false,
|
|
173
|
+
useBothAxis: false,
|
|
165
174
|
},
|
|
166
175
|
selectSeries: {
|
|
167
176
|
use: false,
|
|
@@ -228,7 +237,7 @@ const DEFAULT_DATA = {
|
|
|
228
237
|
data: {},
|
|
229
238
|
};
|
|
230
239
|
|
|
231
|
-
export const useModel = (
|
|
240
|
+
export const useModel = (injectGroupSelectedLabel) => {
|
|
232
241
|
const { props, emit } = getCurrentInstance();
|
|
233
242
|
|
|
234
243
|
const getNormalizedOptions = (options) => {
|
|
@@ -252,32 +261,56 @@ export const useModel = (selectedLabel) => {
|
|
|
252
261
|
const getNormalizedData = data => defaultsDeep(data, DEFAULT_DATA);
|
|
253
262
|
|
|
254
263
|
const selectItemInfo = cloneDeep(props.selectedItem);
|
|
255
|
-
const selectLabelInfo = cloneDeep(props.selectedLabel ??
|
|
264
|
+
const selectLabelInfo = cloneDeep(props.selectedLabel ?? injectGroupSelectedLabel?.value);
|
|
256
265
|
const selectSeriesInfo = cloneDeep(props.selectedSeries);
|
|
257
266
|
|
|
258
267
|
const eventListeners = {
|
|
259
268
|
click: async (e) => {
|
|
260
269
|
await nextTick();
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
270
|
+
const { seriesId, dataIndex, eventTarget, targetAxis } = e?.selected ?? {};
|
|
271
|
+
const { eventTarget: deselectedEventTarget } = e?.deselected ?? {};
|
|
272
|
+
|
|
273
|
+
switch (eventTarget) {
|
|
274
|
+
case 'item': {
|
|
275
|
+
if (seriesId !== null) {
|
|
276
|
+
emit('update:selectedItem', {
|
|
277
|
+
seriesID: seriesId,
|
|
278
|
+
dataIndex,
|
|
279
|
+
});
|
|
280
|
+
if (deselectedEventTarget === 'label') {
|
|
281
|
+
emit('update:selectedLabel', { dataIndex: [] });
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
emit('update:selectedItem', null);
|
|
266
285
|
}
|
|
267
|
-
|
|
286
|
+
break;
|
|
268
287
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
288
|
+
|
|
289
|
+
case 'label': {
|
|
290
|
+
if (injectGroupSelectedLabel?.value) {
|
|
291
|
+
injectGroupSelectedLabel.value.dataIndex = dataIndex;
|
|
292
|
+
} else {
|
|
293
|
+
emit('update:selectedLabel', {
|
|
294
|
+
dataIndex,
|
|
295
|
+
targetAxis,
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
if (deselectedEventTarget === 'item') {
|
|
299
|
+
emit('update:selectedItem', null);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
276
303
|
}
|
|
304
|
+
|
|
305
|
+
case 'series': {
|
|
306
|
+
emit('update:selectedSeries', { seriesId });
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
default:
|
|
311
|
+
break;
|
|
277
312
|
}
|
|
278
|
-
|
|
279
|
-
emit('update:selectedSeries', { seriesId: e.selected.seriesId });
|
|
280
|
-
}
|
|
313
|
+
|
|
281
314
|
emit('click', e);
|
|
282
315
|
},
|
|
283
316
|
'dbl-click': async (e) => {
|
|
@@ -332,8 +365,9 @@ export const useZoomModel = (
|
|
|
332
365
|
evChartNormalizedOptions,
|
|
333
366
|
{ wrapper: evChartWrapper, evChartGroupRef },
|
|
334
367
|
selectedLabelOrItem,
|
|
368
|
+
evChartPropsInGroup,
|
|
335
369
|
) => {
|
|
336
|
-
const { props,
|
|
370
|
+
const { props, emit } = getCurrentInstance();
|
|
337
371
|
|
|
338
372
|
const isExecuteZoom = ref(false);
|
|
339
373
|
const isUseZoomMode = ref(false);
|
|
@@ -393,23 +427,17 @@ export const useZoomModel = (
|
|
|
393
427
|
};
|
|
394
428
|
|
|
395
429
|
const createEvChartZoom = () => {
|
|
396
|
-
if (evChartGroupRef) {
|
|
430
|
+
if (evChartGroupRef?.value) {
|
|
397
431
|
evChartInfo.dom = evChartGroupRef.value.querySelectorAll('.ev-chart-container');
|
|
398
432
|
|
|
399
|
-
let chartIdx = 0;
|
|
400
433
|
if (evChartInfo.dom.length) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const { options, data } = evChartProps;
|
|
434
|
+
evChartPropsInGroup.value.forEach(({ data, options }, idx) => {
|
|
435
|
+
data.chartIdx = idx;
|
|
404
436
|
|
|
405
|
-
|
|
406
|
-
|
|
437
|
+
evChartInfo.props.data.push(data);
|
|
438
|
+
evChartInfo.props.options.push(options);
|
|
407
439
|
|
|
408
|
-
|
|
409
|
-
evChartInfo.props.options.push(options);
|
|
410
|
-
} else if (type?.name === 'EvChartBrush') {
|
|
411
|
-
brushChartIdx.value.push(evChartProps?.options?.chartIdx ?? 0);
|
|
412
|
-
}
|
|
440
|
+
brushChartIdx.value.push(idx);
|
|
413
441
|
});
|
|
414
442
|
}
|
|
415
443
|
} else {
|