react-vis icon indicating copy to clipboard operation
react-vis copied to clipboard

ChartLabel style prop not overriding default styles

Open OPerel opened this issue 6 years ago • 6 comments

Hello, I'm trying to set the Chart Label's font-size via the style attribute. I see my styles being rendered and if they don't collide with the default styles it's all good. But if the style property is also set in the react-vis stylesheet, e.g font-size, than the stylesheet styles override my custom styles.

<ChartLabel  
    text="חומר גלם קיים"
    includeMargin={false}
    xPercent={0.4}
    yPercent={0.05}
    style={{
          transform: 'rotate(270)',
          fontSize: '1.2em'
     }}
    />

Capture

  • Note: the chart is in hebrew, it's not a bug or anything

Thanks a lot!!

OPerel avatar Jul 08 '19 08:07 OPerel

Same problem here.

fontWeight and transform seem to be the Only two properties working.

DiegoGorgazzi avatar Jul 10 '19 11:07 DiegoGorgazzi

This is an issue for me as well. The inner class applied to the text appears to override any passed styles.

jkerrwilson avatar Jul 18 '19 18:07 jkerrwilson

Same here: fill and fontSize won't work.

maltebaer avatar Aug 22 '19 13:08 maltebaer

I found a round-about-way of doing this. I created a .css and am over writing their class for this element.

newStyles.css .rv-xy-plot__axis__title text{fill:#6b6b76;font-size:18px;}

In index.jsx import 'react-vis/dist/style.css'; import './newStyles.css';

ajosep514 avatar Nov 01 '19 16:11 ajosep514

Thanks @ajosep514

OPerel avatar Nov 04 '19 08:11 OPerel

try this

<FlexibleWidthXYPlot 
            height={300}
            xType="ordinal">
                <HorizontalGridLines style={{ stroke: '#dedede' }} />
                <XAxis
                    title="Date"
                    style={{
                        line: {stroke: '#ADDDE1'},
                        ticks: {stroke: '#ADDDE1'},
                        text: {stroke: 'none', fill: '#6b6b76', fontWeight: 600}
                    }}
                    tickLabelAngle={-35}
                />
                <YAxis />
                <LineSeries
                    className="productive-hours-line"
                    style={{strokeWidth: '2px',stroke: '#eca251'}}
                    data={hoursMatrix}
                />
                <LineSeries
                    className="events-line"
                    style={{strokeWidth: '2px',stroke: '#0398a8'}}
                    data={taskMatrix}
                />
            </FlexibleWidthXYPlot>
```

jemuelpup avatar Oct 15 '21 08:10 jemuelpup