1

As far as I can tell, my chart is pretty close to the example of a bar graph in the official documentation:

var data = [ { "type": "bar", "x": [ "<=1", "2", "3", "4", "5", "6 - 10", "11 - 20", "21+" ], "y": [ 0, 0, 0, 0, 1, 0, 0, 30 ], "textposition": "auto", "hoverinfo": "x+y", "marker": { "color": "#B5C6D6" } } ];

Plotly.newPlot('myDiv', data);

html

<head>
    <!-- Load plotly.js into the DOM -->
    <script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
</head>

<body>
    <div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
</body>

However, the x axis values are not what I entered into my x-axis array. Instead of 1, 2, 3, ... 21+, I get 1.5, 2, 2.5, etc. I have no idea where these values are coming from.

https://codepen.io/dvdgdnjsph/pen/BaKwRKm?editable=true%3Dhttps%3A%2F%2Fplotly.com%2Fjavascript%2Fbar-charts%2F

Can anyone help me?

4

1 に答える 1