react-chartjs

How to show data values or index labels in ChartJs (Latest Version)

限于喜欢 提交于 2019-12-18 03:47:08
问题 How to show data values or index labels in ChartJs (Latest Version) as in the below image: I am using the ChartJs to display charts in my React Project. Everything is working fine, except this. I found an answer in stackoverflow (https://stackoverflow.com/a/31632707), But it uses an old version of chartjs and is not working on the one which I am using. My ChartJs Code: var ctx = document.getElementById("myChart"); var BarChart = new Chart(ctx, { type: 'bar', data: { labels: ["Jan","Feb",

react-charts “stacked:true” is not working

╄→гoц情女王★ 提交于 2019-12-13 18:44:50
问题 I've created a chart in ReactJS using react-charts , with multiple bars. This is my component: import React, { Component } from "react"; import { Chart } from "react-charts"; import axios from "axios"; const qs = require("qs"); class Volume extends Component { state = { load_vol_chart: true, volume_chart_data: [] }; componentDidMount() { this.getVolumeChartData(); } getVolumeChartData() { var name = this.props.name; axios .post( `http://api.mydomain.in/details/`, qs.stringify({ type: name })

Can't resize react-chartjs-2 doughnut chart

喜夏-厌秋 提交于 2019-12-13 13:25:07
问题 I am trying to make a doughnut chart with react and gatsbyjs. The chart works fine but I can not get it to use the full width of the div. It displays too small for the area reserved. render (){ return ( <Doughnut data={this.state.chartData} options={{ padding:"0px", responsive:false, maintainAspectRatio:false, defaultFontSize:"14px", width:"400", height:"400", legend:{ display:false, }, plugins:{ datalabels: { color:'#000000', anchor: "start", align:"end", formatter: function(value, context)

Make a horizontal bar using react-chartjs-2

∥☆過路亽.° 提交于 2019-12-12 16:44:19
问题 I'm struggling to find information to make chart with react-chartjs-2. I made a bar chart using react-chartjs-2. I couldn't find related information about making it horizontal bar. Is it possible to make a horizontal bar with react-chartjs-2? I also have a pie chart next to a bar chart. I use same data from a pie chart to make a bar chart. Any help is appreciated. Here is my code. export default class Categories extends React.Component{ constructor(props){ super(props); this.state = {

Change tool-tip direction in react-chartjs2

回眸只為那壹抹淺笑 提交于 2019-12-11 18:42:30
问题 I have implemented the react-chartjs2 https://www.npmjs.com/package/react-chartjs-2 in my react app. I have implemented it successfully but i need to change the direction of the tooltip when hovering the chart. Currently it looks like this But i want my tooltip to look like this How can i achieve this My code for chart and chart options const barChartOptions = { tooltips: { custom: function(tooltip) { if (!tooltip) return; // disable displaying the color box; tooltip.displayColors = false; },

How to configure multiple bars on same chart using react-charts

ぐ巨炮叔叔 提交于 2019-12-11 16:59:10
问题 I have a react wherein I am able to display the. For this i am using react-charts library. To populate chart data I am making a API call and thereafter updating the state. I want to display multiple values for YAxis. My sample API response is: { "result": 1, "data": [ { "data1": "1272.00", "data2": "1183.00", "price": "131.00" }, { "data1": "1328.00", "data2": "1468.00", "price": "132.00" }, { "data1": "1829.00", "data2": "1445.00", "price": "133.00" }, ] } I want data1 and data2 values

How to set options in react-chartjs-2?

守給你的承諾、 提交于 2019-12-08 02:32:32
问题 React Charts 2 https://github.com/gor181/react-chartjs-2 is referencing below Chart JS http://www.chartjs.org/docs/#getting-started The docs in react-chartjs-2 references chart.js docs and they're all wrong. I can't figure out how to configure the charts in react, specifically the options. Does anybody know? 回答1: <Bar data={{ labels: this.props.labels, datasets: this.props.data }} options={{ legend: { display: false }, scales: { yAxes: [{ ticks: { max: this.props.maxY, min: 0, stepSize: 3 } }

How to set options in react-chartjs-2?

冷暖自知 提交于 2019-12-06 07:47:58
React Charts 2 https://github.com/gor181/react-chartjs-2 is referencing below Chart JS http://www.chartjs.org/docs/#getting-started The docs in react-chartjs-2 references chart.js docs and they're all wrong. I can't figure out how to configure the charts in react, specifically the options. Does anybody know? <Bar data={{ labels: this.props.labels, datasets: this.props.data }} options={{ legend: { display: false }, scales: { yAxes: [{ ticks: { max: this.props.maxY, min: 0, stepSize: 3 } }] }, title: { display: this.props.display, text: this.props.title } }} /> 来源: https://stackoverflow.com

Add text inside doughnut chart from chart js-2 in react

 ̄綄美尐妖づ 提交于 2019-12-04 12:03:03
问题 i want to add a text message inside my doughnut pie chart. To be more specific i want something like this: I came across the same issue here in stack overflow by they use chart js in jquery and since i'm new to javascript i got confused. This is how i define my pie chart: <Doughnut data={sectorsData} width={250} height={250} options={{ legend: { display: false }, maintainAspectRatio: false, responsive: true, cutoutPercentage: 60 }} /> 回答1: My example uses the property text on the data to

Add text inside doughnut chart from chart js-2 in react

半世苍凉 提交于 2019-12-03 06:53:07
i want to add a text message inside my doughnut pie chart. To be more specific i want something like this: I came across the same issue here in stack overflow by they use chart js in jquery and since i'm new to javascript i got confused. This is how i define my pie chart: <Doughnut data={sectorsData} width={250} height={250} options={{ legend: { display: false }, maintainAspectRatio: false, responsive: true, cutoutPercentage: 60 }} /> My example uses the property text on the data to specify the inner text: const data = { labels: [...], datasets: [...], text: '23%' }; import React from 'react';