So If I'm duplicating this example from billboard.js documentation it seems easy to add optional Y grid lines. This is something I want, since I'm adding them dynamically in different scenario.
The thing that I cannot seem to figure out is how to add custom style to the text when talking about a background color. It seems like you cannot add style to a svg g element (in billboard you get a svg <g>
element containing a <line>
and a <text>
).
So if I want to make it seem like the text element is in some kind of let's say green bubble, is there a way to achieve that?
var chart = bb.generate({
data: {
columns: [
["sample", 30, 200, 100, 400, 150, 250],
["sample2", 1300, 1200, 1100, 1400, 1500, 1250]
],
axes: {
sample2: "y2"
}
},
axis: {
y2: {
show: true
}
},
grid: {
y: {
lines: [
{
value: 50,
text: "Label with some bublly background"
},
{
value: 1300,
text: "Label 1300 for bubbly style",
axis: "y2",
position: "start"
},
{
value: 350,
text: "Label 350 for y",
position: "middle"
}
]
}
},
bindto: "#OptionalYGridLines"
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/billboard.js/dist/billboard.min.css" />
<script src="https://cdn.jsdelivr.net/npm/billboard.js/dist/billboard.pkgd.min.js"></script>
<title>JS Bin</title>
</head>
<body>
<div id="OptionalYGridLines"></div>
</body>
</html>