-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathline_chart.lua
More file actions
43 lines (39 loc) · 1.24 KB
/
line_chart.lua
File metadata and controls
43 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---@type lplotPublicModuleClass
local plot = require("lplot")
local notebook = plot.newNotebook()
-- Single-series line chart (simple dict)
notebook.add_title("Monthly Revenue")
notebook.add_line_chart(
{ Jan=4200, Feb=3800, Mar=5100, Apr=4700, May=6200, Jun=5800 },
{
title = "Revenue 2026",
subtitle = "Single series",
colors = { value = "#3498db" },
size = { width = 700, height = 350 },
}
)
notebook.add_separator()
-- Multi-series line chart
notebook.add_subtitle("Revenue vs Costs")
notebook.add_line_chart(
{
{ x = "Jan", revenue = 4200, costs = 2100 },
{ x = "Feb", revenue = 3800, costs = 2300 },
{ x = "Mar", revenue = 5100, costs = 2000 },
{ x = "Apr", revenue = 4700, costs = 2400 },
{ x = "May", revenue = 6200, costs = 2600 },
{ x = "Jun", revenue = 5800, costs = 2500 },
},
{
title = "Revenue vs Costs 2026",
subtitle = "Multi-series",
x_key = "x",
colors = { revenue = "#2ecc71", costs = "#e74c3c" },
size = { width = 700, height = 350 },
}
)
local html = notebook.get_html()
local f = io.open("line_chart.html", "w")
f:write(html)
f:close()
print("Saved to line_chart.html")