Skip to content
Snippets Groups Projects
Commit fc45382b authored by Matthieu BELLUCCI's avatar Matthieu BELLUCCI
Browse files

WIP changing bar charts

parent be7f6d7c
Branches
No related merge requests found
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend,
} from 'chart.js';
import { Component } from 'react';
import { Bar } from 'react-chartjs-2';
ChartJS.register(
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend
);
const default_options = {
indexAxis: 'y',
elements: {
bar: {borderWidth: 1,},
},
responsive: true,
plugins: {
legend: {display: false},
},
title: {
display: false,
text: 'TITLE',
},
};
class BarChart extends Component {
constructor(props) {
super(props);
/*
TODO
* Sort data with labels
* Write extractLabels, extractData and extractBGColor
* See if these functions can or should be merged and how to set state if it is.
*/
this.state = {
options: this.props.options || default_options,
data: {
labels: extractLabels(this.props.data),
datasets: [{
data: extractData(this.props.data),
borderColor: 'black',
backgroundColor: extractBGColor(this.props.data)
}]
},
};
}
}
export default BarChart;
\ No newline at end of file
......@@ -5,6 +5,7 @@ import Image from './Image';
import BarChart from './BarChart';
import Tabs from './Tabs';
import Prediction from './Prediction';
import { BarTest } from './BarCharts';
//import data from './data.json';
const data = require('./data.json')
......@@ -13,4 +14,5 @@ const root = document.getElementById('root');
let arr = [5, 10, 2, 3, 0, 100, 50];
//ReactDOM.render(<BarChart data={arr}/>, root);
const pred = <Prediction data={data} img={image} label="Trombone" />
ReactDOM.render(pred, root);
\ No newline at end of file
// ReactDOM.render(pred, root);
ReactDOM.render(<BarTest />, root);
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment