Creating a marker in line chart when the x axis is based on a time scale
See original GitHub issueI am trying to create a x-axis marker (red line shown in the image) at the 12 PM point.
<ResponsiveLine
...
xScale={{
type: 'time',
format: '%H:%M',
precision: 'minute',
useUTC: false,
}}
xFormat="time:%H:%M"
yScale={{
min: 0,
max: 80,
type: 'linear',
}}
axisLeft={{
...
format: (e) => e + '%',
}}
axisBottom={{
...
format: '%I %p',
tickValues: `every 3 hours`,
}}
markers={[
{
axis: 'y',
value: 50,
lineStyle: { stroke: '#fff', strokeWidth: 2 },
legend: 'y marker',
textStyle: {
fill: '#fff',
fontSize: 15,
},
},
{
axis: 'x',
value: '12:00', // Here is the error, unable to translate on x-axis
lineStyle: {
stroke: '#ff0000',
strokeWidth: 2,
opacity: 1,
},
legend: 'x marker',
textStyle: {
fill: '#fff',
fontSize: 15,
},
},
]}
...
/>
As you can see, the red marker is being rendered at 0 position rather than 12 PM. I feel the error is at value: '12:00'
because the xScale cannot transform the string to a correct pixel value that would have rendered the red line at the right location.
I have tried passing the time in all possible formats but the red line still gets rendered at the 0 point. When inspecting the red line, I get the following error.
Error: <g> attribute transform: Expected number, "translate(undefined, 0)".
<g transform="translate(undefined, 0)">
<line x1="0" x2="0" y1="0" y2="220" stroke="#000000" stroke-width="1" style="stroke: rgb(255, 78, 94); stroke-width: 2; opacity: 1;">
</line>
<text transform="translate(14, 14) rotate(0)" text-anchor="start" dominant-baseline="central" style="fill: rgb(255, 255, 255); font-size: 15px;">x marker</text>
</g>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
How to Create a Date or Time Chart in Excel | Pryor Learning
Open the Axis Options dropdown triangle. Make changes to the Bounds, Units, and so on to adjust the time-scale to display the chart...
Read more >Change data markers in a line, scatter, or radar chart
Click Marker Options, and then under Marker Type, make sure that Built-in is selected. In the Type box, select the marker type that...
Read more >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 >Create a Date Based Axis or Text Based Axis Line Chart
When you create a chart, there are usually many option you have to fine tune the way information is show. One of those...
Read more >How To Create A Line Graph In Excel (With Multiple Lines)
In this tutorial, I will show you how to create a line graph in Excel. I will firstly show you how to create...
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
@rahul-rxr I think you should use
new Date()
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!