javascriptreactjsbar-chartc3.js

Creating realtime Bar chart with react-rt-chart


Please i need concerning my graph for my project everthing works perfectly just that it is only showing line data instead of bar chart

import RTChart from 'react-rt-chart';
//data changes on state change thats why value for data of object instead of array
const data={
date: Date.now(),
Current: [1800],
Predicted: [500],
    }
// note according to the documentation chart should be similar to c3 js chart option
var chart = {
data:{
types: {
Current: 'line',
},
type:"bar",
axis: {
y: { min: 0, max: 3000 }
},
}
<RTChart
fields={['Current','Predicted']}
data={data}
chart={chart}
/>

Solution

  • The object is wrong it should be both type and types should be in the data object

    let chart = {
    data:{
    type:"bar",
    types: {
    Current: 'line',
    },
    axis: {
    y: { min: 0, max: 3000 }
    },
    }