Comments (8)
Wow that's very weird! Thanks for the report.
Actually had some similar bug here before and it was because of the data format / sorting.
Could you post a small part of your data and if you do the scales that you pass to the graph?
from react-d3-components.
I don't pass any scale to the graph.
Below is the code for reproducing:
var data = [
{label:"1",values:[{x:"0",y:1},{x:"1",y:1},{x:"4",y:1}},
{label:"2",values:[{x:"0",y:1},{x:"1",y:2},{x:"4",y:0}]},
{label:"null",values:[{x:"0",y:6},{x:"1",y:0},{x:"4",y:0}]}
];
return (<LineChart data={data} width={840} height={500} margin={{top: 10, bottom: 50, left: 50, right: 10}} />)
It seems that the issue happens when the "x" values are string.
Below is the graph for the same data points when "x" values are ints (works well in this case)
from react-d3-components.
Thanks for the details! Any reason you pass is in as string? Just for clarification.
from react-d3-components.
Thinking of it. If you pass a string the default scales will be ordinal and what you want is linear, which will be generated automatically if you pass numbers. So if you want to pass strings and have a linear scale you might make a scale yourself with the correct settings and pass it to the graph.
from react-d3-components.
I'm passing the values as string because they're not necessarily numbers (could be dates, numbers, strings...)
I think I should cast the values from strings to numbers when they're actually numbers since I assume that the default ordering for strings is lexicographic?
That example being apart, I will have other cases where the values will be strings. I will try passing a scale as you suggested in those cases.
Getting back to you asap to tell you if that worked.
from react-d3-components.
At the moment it's automatically decided by looking at a single data point in https://github.com/codesuki/react-d3-components/blob/master/src/DefaultScalesMixin.jsx
Supported are ordinal, numerical and date scales by default. But what you pass in yourself is not limited of course.
from react-d3-components.
The x-axis offset for ordinal scales is being caused by bar padding in _makeOrdinalXScale of DefaultScalesMixin.jsx. Bar padding defaults to 0.5, which is why it shows up correctly for bar charts but not for any other chart type. If you pass barPadding={1} as a property to charts (other than bar charts), it should fix the issue.
from react-d3-components.
Good catch!
from react-d3-components.
Related Issues (20)
- Feature Suggestion: Having a line when hovering over the chart HOT 1
- Responsive chart HOT 1
- Series colors
- X-axis is not showing in the graph with smaller Y-axis value
- PieChart not rendering HOT 1
- Documentation HOT 1
- Bar Chart Tootlip & tickFormat with image
- dots in tooltip not showing correctlly while hovering HOT 1
- toolTip not working properly on line chart
- Q: Is support react native?
- Is this repo still maintained? HOT 2
- I want to pass xscale value to Bar Chart, how to achieve that!
- PieChart hides label when data is unevenly distributed HOT 4
- Interested to maintain the project HOT 4
- How to customize strokeColor for LineChart? HOT 1
- how to increase column width of barchar and yAix value default like 0 to 100
- How to add stroke color for area chart HOT 1
- NPM vulnerability HOT 1
- 同学,您这个项目引入了615个开源组件,存在27个漏洞,辛苦升级一下
- Integrating D3 into a Vite-TS Project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-d3-components.