Panning, clamp max X #48
Replies: 1 comment 2 replies
-
|
Hey again 👋 Great question, this was actually a deliberate design choice, but I can see why it's a pain for your use case. Cristalyse currently allows infinite panning in both directions. I removed boundary checks intentionally because most users wanted smooth exploration without hitting walls. The visual clipping handles what's rendered, but the domain itself can go anywhere. Your use case is totally valid, though. Real-time time series is different, you want "pan backwards through history" but "can't look into the future" behavior. That's a specific constraint that doesn't exist right now. Workaround for now: Use CristalyseChart()
.data(data)
.mapping(x: 'timestamp', y: 'value')
.geomLine()
.interaction(
pan: PanConfig(
enabled: true,
updateXDomain: true,
onPanUpdate: (info) {
final now = DateTime.now().millisecondsSinceEpoch.toDouble();
if (info.visibleMaxX! > now) {
// User tried to pan into the future
// Option 1: Rebuild with clamped data
// Option 2: Just ignore and let them hit the visual edge
}
},
),
)
.build()Yeah, it requires a rebuild to actually enforce it, which isn't ideal. But it'll work. Should this be a feature? I could add optional Let me know if this workaround is good enough for your needs or if you need proper boundary support. If it's a blocker for you (or others hit this), I'll prioritize it. Otherwise it goes on the backlog. Also happy to review a PR if you want to take a crack at it yourself! The logic would live in |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi again,
I am trying to use the chart for real time updates (timeseries) and being able to pan backwards in time. I have not found a way to clamp the maximum x value, the timestamp(DateTime.now()) with the internals of cristalyse.
Is is possible to clamp or cap the maximum X value in panning mode, and can it be updateable so I would not need to rebuild the chart?
Beta Was this translation helpful? Give feedback.
All reactions