abdelaz3r / sparkline_svg Goto Github PK
View Code? Open in Web Editor NEWSparkline SVG is simple, zero-dependency, Elixir library to generate SVG sparkline charts.
License: Apache License 2.0
Sparkline SVG is simple, zero-dependency, Elixir library to generate SVG sparkline charts.
License: Apache License 2.0
Hi, thanks for sharing this awesome library!
Is there a way to use only vertical padding?
When using smoothing (even the default 0.15), the line can be cropped at the top and bottom borders:
This can be fixed by setting padding, but then I also get horizontal padding, it would be great to have only padding at the top and bottom.
If the list of values has less than 2, we get this crash:
[error] GenServer #PID<0.1465.0> terminating
** (ArithmeticError) bad argument in arithmetic expression
(sparkline_svg 0.3.0) lib/sparkline_svg/core.ex:132: SparklineSvg.Core.resize_x/3
(sparkline_svg 0.3.0) lib/sparkline_svg/core.ex:62: anonymous fn/4 in SparklineSvg.Core.resize_datapoints/4
(elixir 1.14.5) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
(sparkline_svg 0.3.0) lib/sparkline_svg/core.ex:35: SparklineSvg.Core.compute/1
(sparkline_svg 0.3.0) lib/sparkline_svg.ex:688: SparklineSvg.compute/1
(sparkline_svg 0.3.0) lib/sparkline_svg.ex:605: SparklineSvg.to_svg/1
(sparkline_svg 0.3.0) lib/sparkline_svg.ex:635: SparklineSvg.to_svg!/1
Maybe this could be handled by the library and return a better error?
If there are 0 values, I just don't show the sparkline, but I have a case where I can have 1 value:
In my stats I have a date selector that can display the last 7, 30 or 365 days, but the user can also choose to show a single day. In this case the library will crash, so a workaround might be showing 2 points when we have only 1, by repeating it:
However this feels a bit weird, it might be preferable to just show a single dot and no line?
Proposal of change:
SimpleCharts.new(datapoints, options2)
|> SimpleCharts.show_dots(options3)
|> SimpleCharts.show_line(options4)
|> SimpleCharts.show_area(options5)
|> SimpleCharts.add_dot(p1, options)
|> SimpleCharts.add_line(p2, options)
# or
|> SimpleCharts.add_annotation(:line, p1, options)
# or
|> SimpleCharts.add_line_annotation(p1, options)
|> SimpleCharts.to_svg()
annotations
for reporting incident (eg.)A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.