Skip to content

Commit

Permalink
feat: Allow using "idx" as field name in plot data. (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci authored Oct 9, 2023
1 parent 913a7c4 commit 42008b7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ui/src/plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ const
return mark
},
refactorData = (ds: any[], marks: MarkExt[]): any[] => {
ds.forEach((d, idx) => d.idx = idx)
ds.forEach((d, idx) => d.wave_idx = idx)
for (const m of marks) {
if (m.x_scale === 'time') {
for (const { x_field, x0_field } of marks) {
Expand Down Expand Up @@ -1048,8 +1048,8 @@ tooltipContainer.className = 'g2-tooltip'
const PlotTooltip = ({ items, originalItems, dateKeys }: { items: TooltipItem[], originalItems: any[], dateKeys: Set<S> }) =>
<>
{items.map(({ data, mappingData, color }: TooltipItem) =>
Object.keys(originalItems[data.idx]).map((itemKey, idx) => {
let item = originalItems[data.idx][itemKey]
Object.keys(originalItems[data.wave_idx]).map((itemKey, idx) => {
let item = originalItems[data.wave_idx][itemKey]
if (!(item instanceof Date) && dateKeys.has(itemKey)) item = new Date(item)

return (
Expand Down Expand Up @@ -1131,8 +1131,8 @@ export const
const e = ev.gEvent.originalEvent
if (e.stateStatus && e.state === 'selected' && model.name && e.element.geometry.customOption.interactive) {
const ret = Array.isArray(e.element?.data)
? e.element.data.map(({ idx }: any) => ({ idx, ...originalDataRef.current[idx] }))
: [{ idx: e.element.data.idx, ...originalDataRef.current[e.element.data.idx] }]
? e.element.data.map(({ wave_idx }: any) => ({ idx: wave_idx, ...originalDataRef.current[wave_idx] }))
: [{ idx: e.element.data.wave_idx, ...originalDataRef.current[e.element.data.wave_idx] }]
wave.emit(model.name, event, ret)
}
})
Expand Down

0 comments on commit 42008b7

Please sign in to comment.