question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Allow strings for XAxis data

See original GitHub issue

Description of feature

The x-axis labels could be a list of strings, right? At least that’s what I have. But I’m getting a

Warning: Failed prop type: Invalid prop data[0] supplied to XAxis.

Because of XAxis.propTypes only allowing numbers and objects for the data array items.

If you agree, I’m willing to make a PR to fix this.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
brendan1809commented, Feb 24, 2020

i am using formatLabel={index => data[index].yourValue} to call an item in the array

1reaction
Gogncommented, Apr 22, 2020

As JesperLekland mentioned, xAccessor also works well:

<XAxis
                  style={{marginHorizontal: -10, height: xAxisHeight}}
                  data={data}
                  xAccessor={({item}) => item.date}
                  formatLabel={value => moment(value).format("DD-MM-YYYY")}
                  contentInset={{left: 30, right: 30}}
                  svg={{
                    fontSize: 10,
                    fill: 'black',
                    fontWeight: 'bold',
                    rotation: 20,
                    originY: 15,
                    y: 15
                  }}
                />

https://i.imgur.com/ua6v54n.png

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add Strings on X Axis in iOS-charts? - Stack Overflow
I had to move let xAxisValue = viewForChart.xAxis xAxisValue.valueFormatter = axisFormatDelegate above viewForChart.data = chartData fr it to ...
Read more >
pgfplots using strings *from data table* as x axis labels in bar ...
1. When I add col sep=comma to the table options of the addplot command, your example compiles fine. · Wow, ermm.. · Ok...
Read more >
Labels and string formatting - Highcharts
Format strings are templates for labels, where variables are inserted. Format strings were introduced in Highcharts 2.3 and improved in 3.0 to allow...
Read more >
Analytics formatting per type in QuickSight
Specify axis range and label tick on the x-axis and axis range and step on the y-axis. Show or hide axis lines, axis...
Read more >
Line Chart - Google Developers
You can smooth the lines by setting the curveType option to function : ... row in the table represents a set of data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found