Files
inventory-plus-plus/server/ui/charts/bar_test.go
T
angel fb2f4255f4
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Tests / Go tests (push) Failing after 15s
prototyped svg reports
2026-08-20 00:23:54 -06:00

96 lines
2.7 KiB
Go

package charts
import (
"fmt"
"os"
)
func ExampleBar() {
mu := NewBar(
BarValue{
Label: "label: 101",
Value: 101,
},
BarValue{
Label: "label: -09",
Value: -99,
},
BarValue{
Label: "label: 201",
Value: 201,
},
BarValue{
Label: "label: -199",
Value: -199,
},
BarValue{
Label: "label: 301",
Value: 301,
},
BarValue{
Label: "label: -299",
Value: -299,
},
BarValue{
Label: "label: 401",
Value: 401,
},
BarValue{
Label: "label: -399",
Value: -399,
},
BarValue{
Label: "label: 501",
Value: 501,
},
BarValue{
Label: "label: -499",
Value: -499,
},
BarValue{
Label: "label: 601",
Value: 601,
},
BarValue{
Label: "label: -599",
Value: -599,
},
BarValue{
Label: "label: 701",
Value: 701,
},
BarValue{
Label: "label: -699",
Value: -699,
},
BarValue{
Label: "label: 801",
Value: 801,
},
BarValue{
Label: "label: -799",
Value: -799,
},
BarValue{
Label: "label: 901",
Value: 901,
},
BarValue{
Label: "label: -899",
Value: -899,
},
BarValue{
Label: "label: 1001",
Value: 1001,
},
BarValue{
Label: "label: -999",
Value: -999,
},
).SVG().GetMarkup()
os.WriteFile("./test.svg", []byte(mu), 666)
fmt.Println(mu)
// Output: <svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="height: auto; width: 100%" viewBox="0 0 100 100"><rect x="0" y="45" width="4.75" height="55" class="fill-accent"/><rect x="5" y="55" width="4.75" height="45" class="fill-accent"/><rect x="10" y="40" width="4.75" height="60" class="fill-accent"/><rect x="15" y="60" width="4.75" height="40" class="fill-accent"/><rect x="20" y="35" width="4.75" height="65" class="fill-accent"/><rect x="25" y="65" width="4.75" height="35" class="fill-accent"/><rect x="30" y="30" width="4.75" height="70" class="fill-accent"/><rect x="35" y="70" width="4.75" height="30" class="fill-accent"/><rect x="40" y="25" width="4.75" height="75" class="fill-accent"/><rect x="45" y="75" width="4.75" height="25" class="fill-accent"/><rect x="50" y="20" width="4.75" height="80" class="fill-accent"/><rect x="55" y="80" width="4.75" height="20" class="fill-accent"/><rect x="60" y="15" width="4.75" height="85" class="fill-accent"/><rect x="65" y="85" width="4.75" height="15" class="fill-accent"/><rect x="70" y="10" width="4.75" height="90" class="fill-accent"/><rect x="75" y="90" width="4.75" height="10" class="fill-accent"/><rect x="80" y="5" width="4.75" height="95" class="fill-accent"/><rect x="85" y="95" width="4.75" height="5" class="fill-accent"/><rect x="90" y="0" width="4.75" height="100" class="fill-accent"/><rect x="95" y="100" width="4.75" height="0" class="fill-accent"/></svg>
}