Skip to content

Commit ccccaa0

Browse files
committed
feat: KStackableTimeSeries should emit the legend-clicked event (close #1161)
1 parent 566c2ac commit ccccaa0

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

core/client/components/chart/KTimeSeriesChart.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ const props = defineProps({
4343
})
4444
4545
// Emits
46-
const emit = defineEmits(['zoom-start', 'zoom-end', 'legend-click'])
46+
const emit = defineEmits(['zoom-start', 'zoom-end', 'legend-clicked'])
4747
4848
// Data
4949
let canvas = null
5050
let chart = null
51+
let hiddenSeries = []
5152
const unit2axis = new Map()
5253
const hasData = ref(false)
5354
// Min/Max time (ie for x axis)
@@ -178,7 +179,7 @@ async function makeChartConfig () {
178179
chart.show(index)
179180
legendItem.hidden = false
180181
}
181-
emit('legend-click', { legendItem, legend })
182+
emit('legend-clicked', legendItem, legend)
182183
}
183184
}
184185
}
@@ -328,7 +329,6 @@ async function makeDatasets () {
328329
}
329330
datasets.push(dataset)
330331
}
331-
332332
return datasets
333333
}
334334
function makeAnnotation () {

map/client/components/widget/KStackableTimeSeries.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
:end-time="endTime"
2323
@zoom-start="onZoomStart"
2424
@zoom-end="onZoomEnd"
25+
@legend-clicked="onLegendClicked"
2526
/>
2627
<KDataTable v-else
2728
:ref="components[index].onTableRef"
@@ -55,6 +56,7 @@
5556
:end-time="endTime"
5657
@zoom-start="onZoomStart"
5758
@zoom-end="onZoomEnd"
59+
@legend-clicked="onLegendClicked"
5860
/>
5961
<KDataTable v-else
6062
:ref="components[index].onTableRef"
@@ -84,11 +86,6 @@ import KPanel from '../../../../core/client/components/KPanel.vue'
8486
import KTimeSeriesChart from '../../../../core/client/components/chart/KTimeSeriesChart.vue'
8587
import KDataTable from '../../../../core/client/components/chart/KDataTable.vue'
8688
87-
const emit = defineEmits(['zoom-start', 'zoom-end'])
88-
// const timeseries = [
89-
// { label: 'group1', series: [] }
90-
// { label: 'group2', series: [] }
91-
// ]
9289
const props = defineProps({
9390
timeSeries: { type: Array, default: () => [] },
9491
xAxisKey: { type: String, default: 'x' },
@@ -102,6 +99,9 @@ const props = defineProps({
10299
exportOptions: { type: Object, default: () => ({}) }
103100
})
104101
102+
// Emits
103+
const emit = defineEmits(['zoom-start', 'zoom-end', 'legend-clicked'])
104+
105105
// data
106106
const components = ref([])
107107
const startTime = ref(null)
@@ -195,6 +195,9 @@ function onZoomEnd ({ chart, start, end }) {
195195
endTime.value = moment.utc(end)
196196
emit('zoom-end', { chart, start, end, zoomHistory })
197197
}
198+
function onLegendClicked (legendItem, legend) {
199+
emit('legend-clicked', legendItem, legend)
200+
}
198201
function update () {
199202
_.forEach(components.value, component => {
200203
if (component.chart) component.chart.update()

0 commit comments

Comments
 (0)