I am trying to implement Highcharts with this tutorial https://www.highcharts.com/docs/getting-started/your-first-chart but get this error:
Uncaught (in promise) Error: Highcharts error #13: www.highcharts.com/errors/13
It means the div does to render to doesn't exist, but I am pretty sure I have a div with the right class in my code:
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Work+Sans" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap/0.30.7/react-bootstrap.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.24.0/babel.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
<script type="text/babel" src="/js/dashboard.js"></script>
<!--link custom css file-->
<link rel="stylesheet" type="text/css" href="/css/style.css">
</head>
<body>
<div class="container">
<h1 class="text-center">Your Dashboard</h1>
<div class="row">
<div class="col-xs-7">
<h3 class="text-center">Calories Today</h3>
<div class="top-left" id="cal-line">
</div>
</div>
<div class="col-xs-5">
<h3 class="text-center">Calories Over Time</h3>
<div class="top-right" id="cal-today" style="width:100% height:400px;">
</div>
</div>
</div>
</div>
</body>
</html>
And here is my JS in /js/dashboard.js:
/*global React*/
/*global ReactBootstrap*/
/*global ReactDOM*/
/*global fetch*/
/*global location*/
/*global Highcharts*/
/*global $*/
//variable to hold user data from API fetch
let user = {};
const fb_id = location.pathname.replace("/users/","");
$(document).ready(function() {
fetch("https://www.url.com/usersdata/" + fb_id)
.then(rsp => rsp.json())
.then(json => {
//we fetched the user data
if(json.error && json.error.message){
throw new Error(json.error.message);
}
user = json;
console.log(json);
$(function(){
const myChart = Highcharts.chart('top-right',{
chart:{
type: 'bar'
},
title:{
text: 'Calories Over Time'
},
xAxis:{
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis:{
title:{
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1,0,4]
},{
name: 'John',
data: [5,7,3]
}]
});
});
});
});
Anyone can help me what I am doing wrong?