fix graph

This commit is contained in:
Qiuxia Fan 2022-07-29 11:16:00 +08:00
parent deecce3985
commit d002f307d7

View File

@ -99,50 +99,16 @@ function updateOptions() {
if (!instance) { if (!instance) {
return; return;
} }
if (props.filters) { if (!props.filters) {
if (props.filters.isRange) { return;
if (!props.filters.duration.startTime) { }
setOptions(props.option); if (props.filters.isRange) {
return; const options = eventAssociate();
} if (JSON.stringify(options) === JSON.stringify(props.option)) {
const list = props.option.series[0].data.map(
(d: (number | string)[]) => d[0]
);
if (!list.includes(props.filters.duration.endTime)) {
return;
}
const markArea = {
silent: true,
itemStyle: {
opacity: 0.3,
},
data: [
[
{
xAxis: props.filters.duration.startTime,
},
{
xAxis: props.filters.duration.endTime,
},
],
],
};
const series = (window as any).structuredClone(props.option.series);
for (const [key, temp] of series.entries()) {
if (key === 0) {
temp.markArea = markArea;
}
}
const options = {
...props.option,
series,
};
if (JSON.stringify(options) === JSON.stringify(props.option)) {
return;
}
setOptions(options);
return; return;
} }
setOptions(options);
} else {
instance.dispatchAction({ instance.dispatchAction({
type: "showTip", type: "showTip",
dataIndex: props.filters.dataIndex, dataIndex: props.filters.dataIndex,
@ -151,6 +117,51 @@ function updateOptions() {
} }
} }
function eventAssociate() {
if (!props.filters) {
return;
}
if (!props.filters.duration.startTime) {
return props.option;
}
if (!props.option.series[0]) {
return;
}
const list = props.option.series[0].data.map(
(d: (number | string)[]) => d[0]
);
if (!list.includes(props.filters.duration.endTime)) {
return;
}
const markArea = {
silent: true,
itemStyle: {
opacity: 0.3,
},
data: [
[
{
xAxis: props.filters.duration.startTime,
},
{
xAxis: props.filters.duration.endTime,
},
],
],
};
const series = (window as any).structuredClone(props.option.series);
for (const [key, temp] of series.entries()) {
if (key === 0) {
temp.markArea = markArea;
}
}
const options = {
...props.option,
series,
};
return options;
}
watch( watch(
() => props.option, () => props.option,
(newVal, oldVal) => { (newVal, oldVal) => {
@ -160,7 +171,11 @@ watch(
if (JSON.stringify(newVal) === JSON.stringify(oldVal)) { if (JSON.stringify(newVal) === JSON.stringify(oldVal)) {
return; return;
} }
setOptions(newVal); let options;
if (props.filters && props.filters.isRange) {
options = eventAssociate();
}
setOptions(options || props.option);
} }
); );
watch( watch(