import React from "react";
import { render } from "react-dom";
import {XYPlot, XAxis, YAxis, HorizontalGridLines, VerticalGridLines, LineSeries} from 'react-vis';
import "react-table/react-table.css";
var bgColors = { "Default": "#81b71a",
"Blue": "#00B1E1",
"Cyan": "#37BC9B",
"Green": "#8CC152",
"Red": "#E9573F",
"Yellow": "#F6BB42",
};
class App extends React.Component {
constructor() {
super();
this.state = {
chartData: [{x: 0, y: 8}, {x: 1, y: 5}, {x: 2, y: 4}, {x: 3, y: 9}, {x: 4, y: 1}, {x: 5, y: 7}, {x: 6, y: 6}, {x: 7, y: 3}, {x: 8, y: 2}, {x: 9, y: 0}]
};
}
render() {
const { data } = this.state;
return (
<div>
<XYPlot height={70} width={350} style={{backgroundColor: bgColors.Yellow}}>
<LineSeries color="black" data={this.state.chartData} />
</XYPlot>
</div>
);
}
}
The top code creates a line-list chart.
As I understand it, the background color of this chart should be yellow, but the result is black.
Could you please tell me what's wrong with my code?

Hey @spdhskfmeh It looks like you haven't imported the style sheet! Go ahead and import the style via including
@import "./node_modules/react-vis/dist/style";
in your scss file and everything should be fine
note that we're working on a solution for when importing a css/scss file is too complicated.
hey, do you already have any solution? because im facing this problem too, line series make an area fill to close with black color , even im not using "fill to close" style -.-
How's that coming along?
If using scss isn't your game you can always include the style sheet via a script tag, like:
<link rel="stylesheet" href="https://unpkg.com/react-vis/dist/style.css">
Oh! That would have been useful. I didn't expect so soon a reply, so went and figured a solution. Mind you, I'm a total noob to frontend development, and hand no css or scss in my app yet.
So, in case your situation is exactly like mine (React + webpack):
@import "./node_modules/react-vis/dist/style";
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader"]
}
From the dir that contains your node_modules dir, run:
npm install --save-dev style-loader css-loader sass-loader node-sass
In your App.js, add a line to the top:
import './App.scss;'
And I had to add the scss file to my watch patterns in package.json. I think that was it.
What is the best way to fix this in case I've hashed class names during a webpack build?
P.S importing just .css file also doesn't work
P.P.S here is the solution
:global {
@import '../../../../../node_modules/react-vis/dist/main.scss';
}
I think line
import 'react-vis/dist/style.css';
should be in docs instead of importing scss file.
The reason for this is that the css applies fill: none;. You "technically" don't need to import the styling in the original example if you do this it works:
<LineSeries color="black" data={this.state.chartData} style={{ fill: 'none' }} />
How I landed to this issue.
react-vis is a great package, but for a first-time user it might be difficult to use.
Most helpful comment
Hey @spdhskfmeh It looks like you haven't imported the style sheet! Go ahead and import the style via including
@import "./node_modules/react-vis/dist/style";
in your scss file and everything should be fine