Line components render offset from rest of chart when the XAxis component's 'scale' property is assigned to 'linear'
See original GitHub issueDo you want to request a feature or report a bug?
Report a bug
What is the current behavior?
When using a scale
of linear
with time series data (encoded in unix timestamps), Line
components within a LineChart
render offset to the rest of the chart. (Mine were wrapped in ResponsiveContainer
, but I have validated that removing this does not solve my occurrence of this issue.)
Appears in the fiddle posted below. Notice how the orange and green lines run off the chart
This behavior does not effect the
Tooltip
’scursor
.
jsfiddle Demo of problem (on right-hand side)
What is the expected behavior?
Line
’s output should render in the appropriate position. Note: this happens with multiple different scale
.
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
macOS High Sierrra, Chrome 62, using the latest npm release at time of writing (1.0.0-beta.6
)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:6 (1 by maintainers)
Top Results From Across the Web
A Complete Guide to Line Charts | Tutorial by Chartio
Line charts are a fundamental chart type generally used to show change in values across time. Learn how to best use this chart...
Read more >Victory | VictoryAxis
VictoryAxis renders a single axis which can be used on its own or composed ... a component instance which will be responsible for...
Read more >Linear Axis - Chart.js
The linear scale is used to chart numerical data. It can be placed on either the x or y-axis. The scatter chart type...
Read more >xAxis.categories | highcharts API Reference
A positive offset moves the axis with it's line, labels and ticks away from the plot area. This is typically used when two...
Read more >How to add annotations and decorations to charts - think-cell
In addition, the X-axis of a line chart may be a value axis, ... then to select appropriate parts in the requested charts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Setting
type='number'
in<XAxis>
solved my problem:Otherwise, the default
type='category'
applies, resulting in categories that center on the tick marks, and thus stray beyond the end of the x-axis.Applying the fix to @B3rry JSFiddle fixes his problem as well: http://jsfiddle.net/zqu3rb8s/4/
I leave it to him to close the issue.
I have also seen this; initial XAxis:
I had to add both type and domain to get rid of the offset:
It should not be necessary to add both domain and type, I would suggest that this is a bug.