mauriciopoppe / function-plot

A 2d function plotter for the web

Home Page:https://mauriciopoppe.github.io/function-plot/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incompatible with d3 v4

QuentinRoy opened this issue · comments

D3 v4 does not include d3.svg anymore. Hence, function-plot is broken.

That's right, function-plot is compatible with d3 v3 only.

As of now, I'm planning on rewriting this library as a react library so it's highly probably that the dependency on the v3 version doesn't change.

Really? As much as I like React, are you sure you want to add another dependancy?

What I meant is that I'd rewrite this library in react + d3 v4, but I'd only use d3 for things that are not related to manage DOM stuff like scales, this would be a new project based on what I wrote for this project.

Upgrading this library to d3 v4 is also on my TODO list.

FunctionPlot for React would be fantastic! any progress with this? Also any documentation or help in setting it up with react for the moment?

Might I suggest making this a web component instead? Then it would be effectively standard across all browsers and frameworks. And if you really like the declarative and functional nature of React, take a look at lit-html.

@lastmjs thank you for the suggestion, I'll definitely consider it for the next version

In case it's helpful, here's the custom element we're making to help us in our application. Definitely not full-featured, but it's an example of what using vanilla web components might look like: https://github.com/Prendus/function-plot-element/blob/master/function-plot-element.ts

@pezzullig

If function-plot is crashing your current react project, you either need to add d3 to global window or modify the current module.

The modifications necessary would be to change all
var d3 = window.d3
to:
var d3 = require('d3')

If you choose this second route you will need to install d3@3..

Now as far as using it with React, you would use it the same way, the only big difference would be calling your function when componentDidMount().

Hopefully that helps.

Well I am a Vue user since last week. Not willing to move to React. and currently I can't use this library because some of my own Components use d3 v5 and the component for plotting functions would require d3 v3 if I use function-plot

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

For a React example check #118