Chart diagram is displayed without colors

I tried to make a radar chart using reactive charts ( https://github.com/reactjs/react-chartjs ). It does, but no colors.

enter image description here

What am I missing? I pretty much copied a large fragment of the example at https://reactcommunity.org/react-chartjs/index.html . (I simplified the data for one data set.)

import React, {PropTypes} from 'react';
import {Grid} from 'react-bootstrap';
const {Radar} = require("react-chartjs");
const ReactDOM = require('react-dom');

function rand(min, max, num) {
	var rtn = [];
	while (rtn.length < num) {
		rtn.push((Math.random() * (max - min)) + min);
	}
	return rtn;
}

var chartData = {
	labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
	datasets: [
	{
		label: "My First dataset",
		backgroundColor: "rgba(179,181,198,0.2)",
		borderColor: "red",
		pointBackgroundColor: "rgba(179,181,198,1)",
		pointBorderColor: "#fff",
		pointHoverBackgroundColor: "#fff",
		pointHoverBorderColor: "rgba(179,181,198,1)",
		data: [65, 59, 90, 81, 56, 55, 40]
	}
	]
};

var chartOptions = {
	scale: {
		reverse: true,
		ticks: {
			beginAtZero: true
		}
	}
};

function TasteGraph({rating}) {
	//loop through and output one slider and one value per component
	return (
		<div>
		<Radar data={chartData} options={chartOptions}/>
		</div>
		);

}
TasteGraph.propTypes = {
	rating: PropTypes.array
};

TasteGraph.defaultProps = {
	rating: []
};

export default TasteGraph;
Run codeHide result

There seems to be no import or a clear error. I tried to surround chartOptions and ChartData "[" and "]" based on another related SO question.

+4
source share
1 answer

backgroundColor fillColor. , borderColor strokeColor.

. jsfiddle. ( chart.js - , )

+3

Source: https://habr.com/ru/post/1669417/


All Articles