Giter Site home page Giter Site logo

Comments (8)

xile611 avatar xile611 commented on May 16, 2024

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.

isilweo avatar isilweo commented on May 16, 2024

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.

xile611 avatar xile611 commented on May 16, 2024

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.

xile611 avatar xile611 commented on May 16, 2024

Fixed in v0.8.0

from recharts.

isilweo avatar isilweo commented on May 16, 2024

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.

xile611 avatar xile611 commented on May 16, 2024

@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.

isilweo avatar isilweo commented on May 16, 2024

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:

  1. Client side rendering, everything is visible
    selection_116
  2. Disable javascript
    selection_117
  3. REfresh and see server side rendering - lines are invisible
    selection_118

from recharts.

xile611 avatar xile611 commented on May 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.