question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

user-defined series path builder

See original GitHub issue

While I’ve seen the note in README I wonder if you would consider at least accepting a user-supplied bezier-drawing function to smooth curves which is particularily nice to have on plots with only a few data points.

I’m no expert on canvas drawing, but I imagine for every line to render, you could call the user’s function using (xStart, yStart, xEnd, yEnd) arguments, do ctx.moveTo(xStart, yStart); and accept back the arguments to use on ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) to draw the curve.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
leeoniyacommented, Feb 20, 2020

updates:

series.draw is gone, replaced by series.paths: () => null. (candlestick demo updated, cc @ldstein)

the API for series.paths matches the internal buildPaths() [1] signature:

paths: (u, sidx, xdata, ydata, scaleX, scaleY) => {
  return {stroke, fill, clip};     // Path2D instances
}

a minor inconvenience remains with the fact that the internal buildPaths() is able to use getXPos() & getYPos() directly to get canvas offsets, but the exposed .valToPos() returns css pixel offsets, making you re-multiply by devicePixelRatio. you can see this already being done here:

https://github.com/leeoniya/uPlot/blob/01be7829ce6a743fb19dad2a930b8f66b57ff48e/demos/candlestick-ohlc.html#L143-L147

i should add extra methods, or a bool param to u.valToPos(val,"x", true) to directly return canvas pixels.

i also realized that this change is insufficient to fully convert the candlestick rendering in the demo because the the candles are effectively custom path “points”, for which i’ll soon add a similar-ish api as part of #10.

[1] https://github.com/leeoniya/uPlot/blob/master/src/Line.js#L682

1reaction
leeoniyacommented, May 6, 2022

uPlot now includes a smooth spline pathBuilder in the core, with a much better implementation than what’s in this demo.

https://leeoniya.github.io/uPlot/demos/line-paths.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is key Path in user defined runtime attributes?
Use user defined runtime attributes to set an initial value for objects that do not have an interface builder inspector. For example, if...
Read more >
Help Online - Tutorials - User Defined Fitting Function
In this tutorial, we will mainly illustrate how to create a user-defined fitting function in Fitting Function Builder, carry out nonlinear curve fit...
Read more >
User-defined transformations ‒ Qlik Replicate
The path is the same on Linux, but with slashes (/)instead of backslashes (\). ... be available in the Expression Builder under Functions->User...
Read more >
Experiment in Journey Builder with Path Optimizer
Configure an automatic or manual winner with up to 10 paths with user-defined distributions. The system automatically picks a winner on email engagement...
Read more >
POSTPROCESSOR BUILDING - "User Defined Events (UDEs)"
POSTPROCESSOR BUILDING - " User Defined Events (UDEs)" Interesujesz się programowaniem obrabiarek CNC? Sprawdź informacje na temat NX CAM: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found