Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitelist style attributes on data objects #610

Closed
amaschas opened this issue Jun 1, 2017 · 3 comments · Fixed by FormidableLabs/victory-core#333
Closed

Whitelist style attributes on data objects #610

amaschas opened this issue Jun 1, 2017 · 3 comments · Fixed by FormidableLabs/victory-core#333
Assignees

Comments

@amaschas
Copy link

amaschas commented Jun 1, 2017

I'm having difficulty determining why this is, but I'm passing a data array (array of objects) to a bar chart, and I get this error:

Warning: a path tag (owner: Bar) was passed a numeric string value for CSS property TotalAcquired (value: 38) which will be treated as a unitless number in a future version of React.

When I try to debug, I find that the individual bars are being passed the values from my data array as styles. Those styles never end up getting applied to the resulting component, I'm guessing because they're not valid CSS, but React still complains about the unitless numbers. My implementation looks vaguely like this, (the dataTitle key ends up populating a custom tooltip):

const bars = [
  {
    TotalAcquired: "38",
    dataTitle: "Total Subscribers",
    date: "2017-02-01" 
  },
  {
    TotalAcquired: "47",
    dataTitle: "Total Subscribers",
    date: "2017-02-02" 
  },
  ...
]

<VictoryBar
  data={bars}
  x={datum => new Date(datum['date'])}
  y={datum => parseInt(datum['TotalAcquired'], 10)}
/>
@d4ncer
Copy link

d4ncer commented Jun 7, 2017

I'm having the same issue.

@boygirl boygirl changed the title Bar primitive adding data props to styles object Whitelist style attributes on data objects Jun 8, 2017
@chrisbolin
Copy link
Contributor

@boygirl i added this to #642. I think the fix we make for this issue should hopefully cover the others mentioned as well.

@boygirl
Copy link
Contributor

boygirl commented Jan 22, 2018

Implementation:

Add a style helper that takes an object, and returns a new object with only valid svg style attributes from the original object.

We will need to add a manual list of all camelCased svg style attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants