0

I am referring chartist docs -> https://gionkunz.github.io/chartist-js/examples.html#stacked-bar

I have seen the code in above link so I am trying to implement it in react component.

chart.js:

import React, { Component } from 'react';
import ChartistGraph from "react-chartist";

const simpleChartData = {
          labels: ['Q1', 'Q2', 'Q3', 'Q4'],
          series: [
            [800000, 1200000, 1400000, 1300000],
            [200000, 400000, 500000, 300000],
            [100000, 200000, 400000, 600000]
          ],
        stackBars: true
}

class Chart extends Component {

  render(){
    return(
      <div>
            <ChartistGraph data={simpleChartData} type={'Bar'} /> 
      </div>

    )}

}

export default Chart;

I am not getting stacked bar charts instead I am getting simple bar charts. See screenshot:

enter image description here

stone rock
  • 1,923
  • 9
  • 43
  • 72

1 Answers1

1

Try placing stackBars: true into options property of ChartistGraph:

import React, { Component } from 'react';
import ChartistGraph from "react-chartist";

const simpleChartData = {
          labels: ['Q1', 'Q2', 'Q3', 'Q4'],
          series: [
            [800000, 1200000, 1400000, 1300000],
            [200000, 400000, 500000, 300000],
            [100000, 200000, 400000, 600000]
          ]

}

const options = {
     stackBars: true
}
class Chart extends Component {

  render(){
    return(
      <div>
            <ChartistGraph data={simpleChartData} options={options} type={'Bar'} /> 
      </div>

    )}

}

export default Chart;
Sachi Tekina
  • 1,800
  • 5
  • 28
  • 50
  • Can you please help me here: https://stackoverflow.com/questions/51011612/how-to-style-elements-for-responsive-web-design – stone rock Jun 24 '18 at 16:15