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

Discrete Color Legend strokeDashes and strokeWidth

Open cvalmonte opened this issue 8 years ago • 6 comments

The discrete color legend component should include props to style the stroke (dashed, width, etc.) so that it will match the line series in my graphs.

cvalmonte avatar Jul 05 '18 22:07 cvalmonte

I would accept a PR to address this issue!

mcnuttandrew avatar Jul 10 '18 16:07 mcnuttandrew

StrokeWidth doesn't seem to work.

const legendItems = [
    {
      title: 'Payments',
      color: '#40A695',
      strokeWidth: 6,
    },
    {
      title: 'Expected payments',
      color: '#999',
      strokeStyle: 'dashed',
      strokeWidth: 6,
    },
    {
      title: 'Værkstedsomkostninger',
      color: '#ED7C33',
      strokeWidth: 6,
    },
  ]

...

<DiscreteColorLegend items={this.legendItems} orientation="horizontal" />

skaermbillede 2018-12-07 kl 13 58 34

olefrank avatar Dec 07 '18 12:12 olefrank

Is there a solution?

talc23 avatar Mar 27 '19 20:03 talc23

It looks like strokeWidth doesn't work because the parent svg element with class rv-discrete-color-legend-item__color has a preset height of 2, so the maximum stroke width that shows is 2px

kenfehling avatar Apr 02 '19 06:04 kenfehling

I've added this to my css file as a temp WA: .rv-discrete-color-legend-item__color { height: 10px; }

The question is why on the showcase examples the strokewdith works and on installed npm packages it doesn't? for example, I've played with this example on my local react-vis repo: https://github.com/uber/react-vis/blob/master/showcase/plot/clustered-stacked-bar-chart.js

changed code to: <DiscreteColorLegend style={{position: 'absolute', left: '50px', top: '10px'}} orientation="horizontal" items={[ { title: 'Apples', strokeWidth:50 }, { title: 'Oranges', color: '#79C7E3' } ]} />

And got this:

image

talc23 avatar Apr 05 '19 09:04 talc23

Running into the same issue with stroke-width not working due to the inline height being set. You'll have to go into /react-vis/es/legends/discrete-color-legend-item.js and change the height in line 57 and then restart your webpage until there is a fix.

perryclee avatar Jul 22 '19 20:07 perryclee