Comments (8)
stroke-dasharray: 0px 1px;
means that you want to draw the line with 0px
dash and 1px
gap repeatedly.
Then of course, the path is invisible. You can view the following example, and you will find that normal behavior of the browser always been this way.
https://jsfiddle.net/dv8b287f/
You can also view the following documents about stroke-dasharray
further:
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
https://www.w3.org/TR/SVG/painting.html#StrokeDasharrayProperty
from recharts.
I understand that stroke-dasharray: 0px 1px;
. But don't you think that rendering behavior should be same on server side and client side? I've got exactly same code and different results. From the other side I think that default behavior of component should be that it is visible rather than hidden.
from recharts.
Sorry for misunderstanding what you mean.
And of course, rendering behavior should be same on server side and client side.
Some bug happens in server side rendering when stroke-dasharray
is set in Line
.
from recharts.
Fixed in v0.8.0
from recharts.
It still doesn't work for me, or I don't understand something. I have updated to 0.8
After server side rendering i still don't see Path because in Path i Have stroke-dasharray="none" style="stroke-dasharray:0px 1px;"
I understand that behavior of SSR and CSR is same when rendering, but after componentDidMount you change style to style="stroke-dasharray: 1180.76px, 0px; transition: stroke-dasharray 1500ms ease;"
to have nice animation and it becomes visible.
I will repeat my opinion: default props of chart should be that path is visible. I can make it visible by setting up strokeDasharray to "1180 0" or what is also intereseting isAnimationActive to false.
btw. i couldn't find how to disable animation in documentation.
thnx for fixing other bugs
from recharts.
@isilweo Can you show you code here? I do not quite understand what is your problem now.
And I will add the apis about animation in the document.
from recharts.
sure. https://github.com/isilweo/recharts-ssr-test/ here is very simple repo with standard ssr rendering and on the end client side js is loaded.
Exact code is in shared/chart.js in my repo
import {LineChart, Line, Legend} from 'recharts';
import React from 'react';
export default class Chart extends React.Component {
render() {
const data = [
{name: 'Page A', uv: 4000, pv: 2400, amt: 2400},
{name: 'Page B', uv: 3000, pv: 1398, amt: 2210},
{name: 'Page C', uv: 2000, pv: 9800, amt: 2290},
{name: 'Page D', uv: 2780, pv: 3908, amt: 2000},
{name: 'Page E', uv: 1890, pv: 4800, amt: 2181},
{name: 'Page F', uv: 2390, pv: 3800, amt: 2500},
{name: 'Page G', uv: 3490, pv: 4300, amt: 2100},
];
return (
<LineChart width={600} height={300} data={data}>
<Legend />
<Line type="monotone" dataKey="pv" stroke="#8884d8" />
<Line type="monotone" dataKey="uv" stroke="#82ca9d" />
</LineChart>
);
}
}
Look also on this screenshots, maybe it will be more obvious:
- Client side rendering, everything is visible
- Disable javascript
- REfresh and see server side rendering - lines are invisible
from recharts.
@isilweo
I have found the reason. The paths have attributes stroke-dasharray="none"
, style="stroke-dasharray: 0px 1px;"
because we need to hide the path before animation of paths start, otherwise paths will blink in client side.
And It seems impossible that the behavior of SSR and CSR is exactly the same when paths have animation.
Maybe you can set isAnimationActive={false}
in Line
when you need SSR.
<LineChart width={600} height={300} data={data}>
<Legend />
<Line type="monotone" dataKey="pv" stroke="#8884d8" isAnimationActive={false} />
<Line type="monotone" dataKey="uv" stroke="#82ca9d" isAnimationActive={false}/>
</LineChart>
from recharts.
Related Issues (20)
- Reference Line not coming with single data point
- Apply `className` to the `RadarChart` component. HOT 2
- Server-side rendering not working with Next.js HOT 7
- The first hover over a Scatter chart point displays the custom tooltip in an incorrect position HOT 4
- Accessibility issue with Brush component HOT 5
- Support for defaultProps will be removed from function components in a future major release. HOT 1
- Cannot customize recharts-active-dot HOT 1
- Uncaught TypeError: import_events.default is not a constructor HOT 3
- Apply `className` to the `label` and `labelLine` in `PieChart` component. HOT 1
- Layer: TypeScript error with latest `@types/react` version HOT 19
- accessibility issue with using 2 charts on the same page. HOT 7
- Pie charts that are 100% a single value have a line that shouldn't be there HOT 5
- how can I pin a tooltip in a chart HOT 8
- Automatically format large axis label values HOT 6
- Tooltip deprecation HOT 1
- Negative interval number HOT 5
- Getting lowest and highest possible x and y in a line chart? HOT 22
- Tooltip first render HOT 7
- YAxis is missing if value = null || undefined HOT 2
- different name on tooltip from xaxis on barchart HOT 4
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 recharts.