Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React, { Component } from 'react'
import axios from 'axios';
import { Line } from 'react-chartjs-2';
import Chart from "react-apexcharts";
export class Linechart extends Component {
constructor(props) {
super(props);
this.state = {
options: {
},
series: [
]
};
}
componentDidMount() {
axios.get(`http://localhost:3030/?data=4`)
.then(res => {
const ipl = res.data.vehicle_class;
let hour = Object.keys(ipl);
let number = Object.values(ipl);
console.log("in react js!",ipl);
this.setState({
options:{
chart: {
id: "basic-bar"
},
xaxis: {
categories: hour
}
},
series:[{
name: "series-1",
data: number
}]
});
}).catch(er =>{
console.log(er);
});
}
render() {
return (
<div>
<Chart
options={this.state.options}
series={this.state.series}
type="line"
width="500"
/>
</div>
)
}
}
export default Linechart;