Skip to content

Commit f6a185e

Browse files
committed
fixes
1 parent d7eaa94 commit f6a185e

7 files changed

Lines changed: 43 additions & 18 deletions

File tree

ai/system-prompt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const chartRef = useRef()
5858
chartRef.current.push({ x: 1, y: 2 })
5959
<Scatterplot ref={chartRef} xAccessor="x" yAccessor="y" />
6060
```
61-
Methods: `push(datum)`, `pushMany(data)`, `remove(id)` (requires `pointIdAccessor`/`dataIdAccessor`), `update(id, updater)`, `clear()`, `getData()`. Network charts: `removeNode(id)`, `removeEdge(sourceId, targetId)`, `updateNode(id, updater)`, `updateEdge(sourceId, targetId, updater)`. Streaming-specific props (`windowSize`, `decay`, `pulse`) go in `frameProps`. Supported: XY charts, ordinal charts, network charts (ForceDirectedGraph, SankeyDiagram, ChordDiagram), ProportionalSymbolMap, DistanceCartogram. Not supported: hierarchy charts (TreeDiagram, Treemap, CirclePack, OrbitDiagram), ChoroplethMap, FlowMap, ScatterplotMatrix.
61+
Methods: `push(datum)`, `pushMany(data)`, `remove(id)` (requires `pointIdAccessor`/`dataIdAccessor`), `update(id, updater)`, `clear()`, `getData()`. Network charts: `removeNode(id)`, `removeEdge(sourceId, targetId)`, `updateNode(id, updater)`, `updateEdge(sourceId, targetId, updater)`. Geo charts: `update()` is implemented as remove+push internally. Streaming-specific props (`windowSize`, `decay`, `pulse`) go in `frameProps`. Supported: XY charts, ordinal charts, network charts (ForceDirectedGraph, SankeyDiagram, ChordDiagram), ProportionalSymbolMap, DistanceCartogram. Not supported: hierarchy charts (TreeDiagram, Treemap, CirclePack, OrbitDiagram), ChoroplethMap, FlowMap, ScatterplotMatrix.
6262

6363
For advanced streaming control, use Stream Frames (`StreamXYFrame`, `StreamOrdinalFrame`, `StreamNetworkFrame`) with `runtimeMode="streaming"` and ref-based push.
6464

docs/src/pages/features/PushApiPage.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,6 @@ function NetworkDemo() {
191191
setLog(prev => ['removeNode("Cache") — edges cascade', ...prev].slice(0, 10))
192192
}, [])
193193

194-
const removeEdge = useCallback(() => {
195-
// This removes via the HOC's remove() which maps to removeNode
196-
// For edge removal, users go through frameProps or the stream frame directly
197-
setLog(prev => ["Edge removal: use StreamNetworkFrame ref.removeEdge(src, tgt)", ...prev].slice(0, 10))
198-
}, [])
199-
200194
const addEdge = useCallback(() => {
201195
ref.current?.push({ source: "Web", target: "DB" })
202196
setLog(prev => ['push({ source: "Web", target: "DB" })', ...prev].slice(0, 10))
@@ -277,7 +271,8 @@ ref.current.getData() // read current data`} la
277271
<p>
278272
<code>remove()</code> and <code>update()</code> require an ID accessor so
279273
the store can find the item to modify. XY charts use <code>pointIdAccessor</code>,
280-
ordinal charts use <code>dataIdAccessor</code>.
274+
ordinal charts use <code>dataIdAccessor</code>. Geo charts implement
275+
<code>update()</code> as remove + push internally.
281276
</p>
282277

283278
<h2>Push + Remove: Scatterplot</h2>

src/components/charts/geo/DistanceCartogram.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ export const DistanceCartogram = forwardRef(function DistanceCartogram<TDatum ex
235235
push: (point) => geoRef.current?.push(point),
236236
pushMany: (points) => geoRef.current?.pushMany(points),
237237
remove: (id) => geoRef.current?.removePoint(id) ?? [],
238-
update: () => { throw new Error("update() not supported on geo charts — use removePoint + push") },
238+
update: (id, updater) => {
239+
const removed = geoRef.current?.removePoint(id) ?? []
240+
for (const old of removed) geoRef.current?.push(updater(old))
241+
return removed
242+
},
239243
clear: () => geoRef.current?.clear(),
240244
getData: () => geoRef.current?.getData() ?? []
241245
}))

src/components/charts/geo/ProportionalSymbolMap.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ export const ProportionalSymbolMap = forwardRef(function ProportionalSymbolMap<T
7777
push: (point) => frameRef.current?.push(point),
7878
pushMany: (points) => frameRef.current?.pushMany(points),
7979
remove: (id) => frameRef.current?.removePoint(id) ?? [],
80-
update: () => { throw new Error("update() not supported on geo charts — use removePoint + push") },
80+
update: (id, updater) => {
81+
const removed = frameRef.current?.removePoint(id) ?? []
82+
for (const old of removed) frameRef.current?.push(updater(old))
83+
return removed
84+
},
8185
clear: () => frameRef.current?.clear(),
8286
getData: () => frameRef.current?.getData() ?? []
8387
}))
@@ -245,6 +249,7 @@ export const ProportionalSymbolMap = forwardRef(function ProportionalSymbolMap<T
245249
xAccessor: xAccessor as any,
246250
yAccessor: yAccessor as any,
247251
pointStyle: pointStyleFn,
252+
...(props.pointIdAccessor && { pointIdAccessor: props.pointIdAccessor }),
248253
...(resolvedAreas && { areas: resolvedAreas, areaStyle }),
249254
...(graticule != null && { graticule }),
250255
...(fitPadding != null && { fitPadding }),

src/components/stream/NetworkPipelineStore.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,12 @@ export class NetworkPipelineStore {
993993
if (src === sourceId && tgt === targetId) {
994994
const previous = edge.data ?? {}
995995
edge.data = updater(previous)
996-
const newValue = edge.data?.value
996+
// Re-derive edge.value using the configured valueAccessor
997+
const valAcc = this.config.valueAccessor
998+
const valFn = typeof valAcc === "function" ? valAcc
999+
: valAcc ? (d: any) => d[valAcc]
1000+
: (d: any) => d.value
1001+
const newValue = valFn(edge.data)
9971002
if (newValue != null) edge.value = Number(newValue)
9981003
this.layoutVersion++
9991004
return previous

src/components/stream/PipelineStore.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,10 +1035,16 @@ export class PipelineStore {
10351035
const removed = this.buffer.remove(item => ids.has(getPointId(item)))
10361036
if (removed.length === 0) return removed
10371037

1038-
// Evict removed values from extent tracking
1038+
// Evict removed values from extent tracking — mirror ingest() logic
10391039
for (const d of removed) {
10401040
this.xExtent.evict(this.getX(d))
1041-
this.yExtent.evict(this.getY(d))
1041+
if (this.config.chartType === "candlestick" && this.getHigh && this.getLow) {
1042+
this.yExtent.evict(this.getHigh(d))
1043+
this.yExtent.evict(this.getLow(d))
1044+
} else {
1045+
this.yExtent.evict(this.getY(d))
1046+
if (this.getY0) this.yExtent.evict(this.getY0(d))
1047+
}
10421048
}
10431049

10441050
this.needsFullRebuild = true
@@ -1064,16 +1070,28 @@ export class PipelineStore {
10641070
)
10651071
if (previous.length === 0) return previous
10661072

1067-
// Evict old values, push new values into extent tracking
1073+
// Evict old values — mirror ingest() logic for candlestick/y0
10681074
for (const old of previous) {
10691075
this.xExtent.evict(this.getX(old))
1070-
this.yExtent.evict(this.getY(old))
1076+
if (this.config.chartType === "candlestick" && this.getHigh && this.getLow) {
1077+
this.yExtent.evict(this.getHigh(old))
1078+
this.yExtent.evict(this.getLow(old))
1079+
} else {
1080+
this.yExtent.evict(this.getY(old))
1081+
if (this.getY0) this.yExtent.evict(this.getY0(old))
1082+
}
10711083
}
10721084
// Push new extents from the updated buffer
10731085
this.buffer.forEach(d => {
10741086
if (ids.has(getPointId(d))) {
10751087
this.xExtent.push(this.getX(d))
1076-
this.yExtent.push(this.getY(d))
1088+
if (this.config.chartType === "candlestick" && this.getHigh && this.getLow) {
1089+
this.yExtent.push(this.getHigh(d))
1090+
this.yExtent.push(this.getLow(d))
1091+
} else {
1092+
this.yExtent.push(this.getY(d))
1093+
if (this.getY0) this.yExtent.push(this.getY0(d))
1094+
}
10771095
}
10781096
})
10791097

src/components/stream/remove.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { TextEncoder, TextDecoder } from "util"
22
Object.assign(global, { TextEncoder, TextDecoder })
33

4-
import React from "react"
5-
import { render } from "@testing-library/react"
64
import { PipelineStore } from "./PipelineStore"
75
import { OrdinalPipelineStore } from "./OrdinalPipelineStore"
86
import { NetworkPipelineStore } from "./NetworkPipelineStore"

0 commit comments

Comments
 (0)