inkplot 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/LICENSE.txt +1 -1
- data/README.md +43 -67
- data/bench/inkplot.rb +12 -3
- data/docs/index.html +31 -0
- data/examples/gallery/01-line.svg +1 -1
- data/examples/gallery/02-line-gaps.svg +1 -1
- data/examples/gallery/03-series.svg +1 -1
- data/examples/gallery/09-histogram.svg +1 -0
- data/examples/gallery/12-time.svg +1 -0
- data/examples/gallery/13-annotations.svg +1 -0
- data/examples/gallery/14-dark-theme.svg +1 -0
- data/examples/gallery/15-category-labels.svg +1 -0
- data/examples/gallery/16-custom-bins.svg +1 -0
- data/examples/gallery/17-connected-gaps.svg +1 -0
- data/examples/gallery/18-step-series.svg +1 -0
- data/examples/gallery/19-combined-marks.svg +1 -0
- data/examples/gallery/20-scatter-sizes.svg +1 -0
- data/examples/gallery/README.md +7 -7
- data/examples/gallery.rb +26 -44
- data/lib/inkplot/core.rb +309 -140
- data/lib/inkplot/renderers/png.rb +390 -0
- data/lib/inkplot/renderers/svg.rb +3 -1
- data/lib/inkplot/version.rb +1 -1
- data/lib/inkplot.rb +3 -3
- data/sig/inkplot.rbs +7 -6
- data/test/snapshots/inkplot/01-line.png +0 -0
- data/test/snapshots/inkplot/02-line-gaps.png +0 -0
- data/test/snapshots/inkplot/03-series.png +0 -0
- data/test/snapshots/inkplot/04-scatter.png +0 -0
- data/test/snapshots/inkplot/05-bars.png +0 -0
- data/test/snapshots/inkplot/06-horizontal-bars.png +0 -0
- data/test/snapshots/inkplot/07-grouped-bars.png +0 -0
- data/test/snapshots/inkplot/08-stacked-bars.png +0 -0
- data/test/snapshots/inkplot/09-histogram.png +0 -0
- data/test/snapshots/inkplot/10-area.png +0 -0
- data/test/snapshots/inkplot/11-step.png +0 -0
- data/test/snapshots/inkplot/12-time.png +0 -0
- data/test/snapshots/inkplot/13-annotations.png +0 -0
- data/test/snapshots/inkplot/14-dark-theme.png +0 -0
- data/test/snapshots/inkplot/15-category-labels.png +0 -0
- data/test/snapshots/inkplot/16-custom-bins.png +0 -0
- data/test/snapshots/inkplot/17-connected-gaps.png +0 -0
- data/test/snapshots/inkplot/18-step-series.png +0 -0
- data/test/snapshots/inkplot/19-combined-marks.png +0 -0
- data/test/snapshots/inkplot/20-scatter-sizes.png +0 -0
- metadata +36 -15
- data/examples/gallery/09-signed-stack.svg +0 -1
- data/examples/gallery/12-histogram.svg +0 -1
- data/examples/gallery/13-log-scale.svg +0 -1
- data/examples/gallery/14-time-axis.svg +0 -1
- data/examples/gallery/15-category-order.svg +0 -1
- data/examples/gallery/16-dark-theme.svg +0 -1
- data/examples/gallery/17-annotations.svg +0 -1
- data/examples/gallery/18-combo.svg +0 -1
- data/examples/gallery/19-legend-position.svg +0 -1
- data/examples/gallery/20-long-categories.svg +0 -1
- data/lib/inkplot/renderers/raster.rb +0 -322
data/examples/gallery.rb
CHANGED
|
@@ -31,69 +31,51 @@ module InkplotGallery
|
|
|
31
31
|
p.bar(%w[Mon Tue Wed Thu Fri], [12, 16, 11, 19, 22], label: "Direct", stacked: true)
|
|
32
32
|
p.bar(%w[Mon Tue Wed Thu Fri], [8, 9, 13, 10, 14], label: "Search", stacked: true)
|
|
33
33
|
end],
|
|
34
|
-
["09-
|
|
35
|
-
p.bar(%w[Mon Tue Wed Thu Fri], [8, -4, 5, -2, 9], label: "New", stacked: true)
|
|
36
|
-
p.bar(%w[Mon Tue Wed Thu Fri], [3, -6, 2, -5, 4], label: "Removed", stacked: true)
|
|
37
|
-
end],
|
|
34
|
+
["09-histogram", Inkplot.histogram([12, 14, 15, 15, 16, 18, 19, 20, 22, 24, 25, 31, 35, 42], title: "Request latency", bins: :auto, x_label: "ms")],
|
|
38
35
|
["10-area", Inkplot.plot(title: "Build time over a release") { |p| p.area((1..8).to_a, [25, 29, 27, 38, 36, 44, 40, 51], label: "Seconds") }],
|
|
39
36
|
["11-step", Inkplot.plot(title: "Queue depth") { |p| p.step((0..7).to_a, [3, 3, 5, 5, 4, 8, 8, 2], label: "Jobs") }],
|
|
40
|
-
["12-
|
|
41
|
-
|
|
42
|
-
p.
|
|
43
|
-
p.line((0..5).to_a, [1, 3, 9, 27, 81, 243])
|
|
44
|
-
end],
|
|
45
|
-
["14-time-axis", Inkplot.plot(title: "Hourly requests") do |p|
|
|
46
|
-
p.x_axis(label: "UTC", type: :time)
|
|
47
|
-
p.line((0..6).map do |hour|
|
|
48
|
-
Time.utc(2026, 9, 24, hour * 4)
|
|
49
|
-
end, [12, 17, 15, 24, 31, 27, 38])
|
|
37
|
+
["12-time", Inkplot.plot(title: "Monthly active users") do |p|
|
|
38
|
+
p.x_axis(label: "Month", type: :time)
|
|
39
|
+
p.line((0..11).map { |month| Time.utc(2026, month + 1, 1) }, [34, 37, 36, 42, 48, 51, 49, 57, 62, 66, 72, 79], label: "Users")
|
|
50
40
|
end],
|
|
51
|
-
["
|
|
52
|
-
p.
|
|
53
|
-
p.
|
|
41
|
+
["13-annotations", Inkplot.plot(title: "Release performance") do |p|
|
|
42
|
+
p.line(%w[v1.0 v1.1 v1.2 v1.3], [34, 42, 39, 55], label: "Requests/s")
|
|
43
|
+
p.hline(45, label: "Target", color: "#D55E00")
|
|
44
|
+
p.vline("v1.2", label: "Cache enabled", color: "#0072B2")
|
|
45
|
+
p.annotate("v1.3", 55, "peak", anchor: :end)
|
|
54
46
|
end],
|
|
55
|
-
["
|
|
56
|
-
p.line(
|
|
57
|
-
p.
|
|
47
|
+
["14-dark-theme", Inkplot.plot(title: "Dark theme", theme: :dark) do |p|
|
|
48
|
+
p.line(%w[Mon Tue Wed Thu Fri], [12, 16, 14, 22, 19], label: "Deploys")
|
|
49
|
+
p.line(%w[Mon Tue Wed Thu Fri], [8, 9, 13, 12, 18], label: "Rollbacks")
|
|
58
50
|
end],
|
|
59
|
-
["
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
p.
|
|
63
|
-
p.text(4.1, 42, "deploy")
|
|
51
|
+
["15-category-labels", Inkplot.bar((1..18).to_h { |index| ["Region #{index} very long", ((index * 7) % 31) + 4] }, title: "Regional volume")],
|
|
52
|
+
["16-custom-bins", Inkplot.histogram([2, 4, 5, 7, 9, 11, 14, 18, 21, 24, 28, 35], bins: [0, 10, 20, 30, 40], title: "Custom latency ranges")],
|
|
53
|
+
["17-connected-gaps", Inkplot.plot(title: "Bridge short gaps") do |p|
|
|
54
|
+
p.line((0..8).to_a, [2, 3, nil, 5, 6, nil, 4, 7, 8], label: "Estimated", gaps: :connect)
|
|
64
55
|
end],
|
|
65
|
-
["18-
|
|
66
|
-
p.
|
|
67
|
-
p.
|
|
56
|
+
["18-step-series", Inkplot.plot(title: "Rate limit changes") do |p|
|
|
57
|
+
p.step((0..6).to_a, [50, 50, 75, 75, 100, 100, 125], label: "Requests/min")
|
|
58
|
+
p.hline(100, label: "Current limit")
|
|
68
59
|
end],
|
|
69
|
-
["19-
|
|
70
|
-
p.
|
|
71
|
-
p.line(
|
|
72
|
-
p.legend(position: :bottom_left)
|
|
60
|
+
["19-combined-marks", Inkplot.plot(title: "Quarterly sales") do |p|
|
|
61
|
+
p.bar(%w[Q1 Q2 Q3 Q4], [16, 20, 18, 27], label: "Previous")
|
|
62
|
+
p.line(%w[Q1 Q2 Q3 Q4], [19, 25, 24, 34], label: "Current")
|
|
73
63
|
end],
|
|
74
|
-
["20-
|
|
75
|
-
p.
|
|
76
|
-
p.
|
|
64
|
+
["20-scatter-sizes", Inkplot.plot(title: "Session length vs. pages") do |p|
|
|
65
|
+
p.scatter([12, 18, 21, 27, 32, 38, 44], [2, 3, 5, 4, 7, 8, 10], size: [1, 2, 3, 2, 5, 6, 8], label: "Sessions")
|
|
66
|
+
p.annotate(38, 8, "engaged")
|
|
77
67
|
end]
|
|
78
68
|
]
|
|
79
69
|
end
|
|
80
70
|
end
|
|
81
71
|
|
|
82
72
|
if $PROGRAM_NAME == __FILE__
|
|
83
|
-
|
|
84
|
-
raise ArgumentError, "usage: ruby examples/gallery.rb [--update-snapshots]" unless ARGV.empty?
|
|
73
|
+
raise ArgumentError, "usage: ruby examples/gallery.rb" unless ARGV.empty?
|
|
85
74
|
|
|
86
75
|
svg_dir = File.expand_path("gallery", __dir__)
|
|
87
76
|
FileUtils.mkdir_p(svg_dir)
|
|
88
77
|
|
|
89
78
|
InkplotGallery.charts.each do |name, chart|
|
|
90
79
|
File.write(File.join(svg_dir, "#{name}.svg"), chart.to_svg)
|
|
91
|
-
next unless update_snapshots
|
|
92
|
-
|
|
93
|
-
require "tessel"
|
|
94
|
-
require "glyphic"
|
|
95
|
-
png_dir = File.expand_path("../spec/snapshots", __dir__)
|
|
96
|
-
FileUtils.mkdir_p(png_dir)
|
|
97
|
-
File.binwrite(File.join(png_dir, "#{name}.png"), Tessel::PNG.encode(chart.to_image))
|
|
98
80
|
end
|
|
99
81
|
end
|