1

Having this code snippet in Billboard.js:

var chart = bb.generate({
  data: {
    columns: [
    ["data1", 30, 200, 100, 400, 150, 250],
    ["data2", 130, 100, 140, 200, 150, 50]
    ],
    type: "spline"
  },
  bindto: "#SplineChart"
});

it will generate this chart:

enter image description here

As it can be seen, the Y axis has in this case the minimum value of 0 and the maximum of 400(or somewhere there).

Is there a way to get that value and store it into a variable?

Community
  • 1
  • 1
dadsa
  • 177
  • 1
  • 13

1 Answers1

1

If I understand correctly you want to get the domain for the Y axis. You can achieve it with:

chart.internal.y.domain()

Check the demo below:

var chart = bb.generate({
  data: {
    columns: [
    ["data1", 30, 200, 100, 400, 150, 250],
    ["data2", 130, 100, 140, 200, 150, 50]
    ],
    type: "spline"
  },
  bindto: "#SplineChart"
});

var yDomain = chart.internal.y.domain()
console.log('y domain==> ', yDomain);
<script src="https://d3js.org/d3.v4.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/billboard.js/dist/billboard.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/billboard.js/dist/billboard.min.js"></script>
<div id="SplineChart"></div>
Mikhail Shabrikov
  • 8,453
  • 1
  • 28
  • 35