DonJayamanne / typescript-notebook

Run JavaScript and TypeScript in node.js within VS Code notebooks with excellent support for debugging, tensorflowjs visulizations, plotly, danfojs, etc
https://marketplace.visualstudio.com/items?itemName=donjayamanne.typescript-notebook
MIT License
910 stars 40 forks source link

Danfo.js plotting support for latest version #41

Closed risenW closed 2 years ago

risenW commented 3 years ago

Hi @DonJayamanne

Thanks once again for supporting Danfo.js in the Nodejs notebook. It works very well for Danfojs v0.2.7

Sadly, plotting does not work for the latest version (v0.3.3). I am curious as to how you're supporting plotting directly from the danfojs-node, as we did not package it with Plotly features.

Did you write a custom renderer for this? And if yes, how do we support the latest version of Danfojs.

If there's any way I can be of help, do let me know.

Cheers, and great work!

DonJayamanne commented 3 years ago

@risenW Looks like DataFrame.plot method has been removed in the latest version Let me see where that is now.

DonJayamanne commented 3 years ago

Yup, thats not showing up in the latest type definitions. curious, was that deliberate? https://danfo.jsdata.org/api-reference/plotting/timeseries-plots

Something like this would not get completions even if targetting web

new_df = df.set_index({ column: "Date" })                
new_df.plot("plot_div").lin

Or has the plotting API changed?

DonJayamanne commented 3 years ago

am curious as to how you're supporting plotting directly from the danfojs-node,

I had over wrote the Datafarme.prorotype.plot method with my own implementation.

risenW commented 3 years ago

Yup, thats not showing up in the latest type definitions. curious, was that deliberate? https://danfo.jsdata.org/api-reference/plotting/timeseries-plots

Something like this would not get completions even if targetting web

new_df = df.set_index({ column: "Date" })                
new_df.plot("plot_div").lin

Or has the plotting API changed?

Yea, we took it out of the Nodejs version. It only ships with the browser version.

risenW commented 3 years ago

am curious as to how you're supporting plotting directly from the danfojs-node,

I had over wrote the Datafarme.prorotype.plot method with my own implementation.

Oh I see. Do you have a suggestion for fixing this without adding back the plot module to the Nodejs version?

DonJayamanne commented 3 years ago

only ships with the browser version.

How do you make the distinction. I could be using danfo.js in a web app with typescript, now I won't get any competitions , And would assume that it's not available in browser either?

I'd suggest adding it back and when the plot method is executed you check whether it's the browser or not and throw an error if it's not running in the browser.

risenW commented 3 years ago

only ships with the browser version.

How do you make the distinction. I could be using danfo.js in a web app with typescript, now I won't get any competitions , And works assume that it's not available in browser either?

I'd suggest adding it back and when the plot method is executed you check whether it's the browser or not and throw an error if it's not running in the browser.

Thanks for the suggestion. I'll do that, and let you know.

aheissenberger commented 2 years ago

I use "danfojs-node": "^1.0.4" and get this error - which looks like it again does not support plot in node:

Error: Not supported in NodeJS
    at DataFrame.plot (../node_modules/danfojs-node/dist/danfojs-base/core/frame.js:2363:19)

my code:

try {
  df.plot("plot_div").scatter({
    config: { x: "rating", y: "detailview_count" }
  })
} catch(e) {
    console.log(e)
}
SYip commented 2 years ago

danfojs-node examples are failing as well.

Some methods are renamed in the latest version of danfojs.

read_csv -> readCSV set_index -> setIndex

The plot method does not work and I end up using plotly directly.

It is a great work! Thanks a lot for the plugin!

DonJayamanne commented 2 years ago

Fixed, in the latest version, will release soon

nashspence commented 1 year ago

Was testing this today in VSCode. Showing this error when I try to run the example:

"Error: Not supported in NodeJS\n at DataFrame.plot (/Users/nashspence/Desktop/boop/node_modules/danfojs-node/dist/danfojs-base/core/frame.js:2401:19)\n at /var/folders/6l/9j_v8g9s5fgd52sgxqc021240000gn/T/vscode-notebook-xAqRgO/notebook_cell_X23sZmlsZQ==.js:14:16\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async C (/Users/nashspence/.vscode/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:113337)\n at async t.execCode (/Users/nashspence/.vscode/extensions/donjayamanne.typescript-notebook-2.0.6/out/extension/server/index.js:2:114306)"