Repository navigation
v0.6.0
Breaking
The public API is now the single module sparklinekit. The builders and the theme are plain records, so their setters and getters are removed.
sparklinekit/unicode,sparklinekit/line,sparklinekit/barandsparklinekit/themeare removed and their contents move intosparklinekit.unicode.renderissparklinekit.blocks.unicode.render_intsis removed; passlist.map(values, int.to_float).- The opaque
line.Builderandbar.Builderare replaced by the recordsLineOptionsandBarOptionswith the constantsdefault_line_optionsanddefault_bar_options.line.to_svgandline.to_pngareline_svg(values, options)andline_png(values, options), andbar.to_svgandbar.to_pngarebar_svgandbar_png.new,new_ints,with_values,with_int_valuesand everywith_*setter are removed; set the record fields instead (with_sizeiswidthandheight,with_spotisspot_radius,with_bar_gapisgap). with_area_fill,with_area_colorandwith_gradient_areaare replaced by theareafield, which isNoArea,SolidAreaorGradientArea, and the theme'sareacolour.with_color,with_background_colorandwith_negative_colorare replaced by the fields of thetheme, for exampleTheme(..sparklinekit.ocean, foreground: "#22A06B").Themeis a record with the fieldsforeground,background,areaandnegative, so the accessor functions are removed.areais anOption(String);Noneuses the foreground at 22% opacity. The theme functions are constants:theme.ocean()issparklinekit.ocean, andtheme.default()issparklinekit.default_theme.sparklinekit.package_versionis removed.- In PNG output, a foreground or negative colour that is not hex is drawn black. It used to fall back to the colour of the theme set before
with_colororwith_negative_color. - Options out of range (sizes below 1, negative gaps and radii, smoothing outside 0 to 0.5, very large stroke widths and dots) are still clamped, now when the chart is drawn.
Before:
import sparklinekit/line
import sparklinekit/theme
line.new([1.0, 5.0, 3.0, 8.0, 4.0])
|> line.with_theme(theme.ocean())
|> line.with_area_fill(True)
|> line.with_spot(3.0)
|> line.to_svgAfter:
import sparklinekit.{LineOptions}
sparklinekit.line_svg(
[1.0, 5.0, 3.0, 8.0, 4.0],
LineOptions(
..sparklinekit.default_line_options,
theme: sparklinekit.ocean,
area: sparklinekit.GradientArea,
spot_radius: 3.0,
),
)tenbagger uses sparklinekit/line and sparklinekit/theme and needs to follow this change when it updates.
Fixed
- A solid area (
with_gradient_area(False)) under a themed line used a tint of the line colour in SVG and the theme's area colour in PNG. Both now use the theme's area colour. - The dot on the last value kept the colour of the theme it was set with, so after
with_colorit was not the colour of the line, as its documentation said. It now follows the line colour unlessspot_coloris set. - The SVG area gradient under a line that never goes above zero, with at least one value below it, was opaque at the top edge and faded towards the line. It now fades away from the line, as PNG output did.
- The area under a single negative value reached down to the bottom, while two equal negative values filled up to the top. Both now fill up to the top.
- Bars for a constant negative series stood on the bottom edge. They now hang from the top.
- An empty area colour wrote
fill=""into the SVG, which browsers draw black. It now uses the foreground at 22% opacity, asNonedoes. - An area colour of
"none"drew no area in SVG but a tinted one in PNG. PNG output now draws no area either.
Install
gleam add sparklinekitSee HexDocs for the API
reference.