jupyter-widgets-contrib / ipycanvas

Interactive Canvas in Jupyter
https://ipycanvas.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
688 stars 64 forks source link

[Help needed]inspired by this project #276

Closed dentistfrankchen closed 2 years ago

dentistfrankchen commented 2 years ago

Recently one of the founders of this project recommended to me this project. I read some of its source code, and I found something that inspired me. I noticed that in your package, you used the widget to create canvas. However, in my project, I did not make it. Here's my code: %%javascript require.undef('counter');

define('counter', ["@jupyter-widgets/base"], function(widgets) { var CounterView = widgets.DOMWidgetView.extend({ render: function() { var canvas = this.el, ctx = canvas.getContext("2d");

    }
});

return {
    CounterView : CounterView
};

});

jupyter says that canvas.getContext is not a function in i.render, how to fix it and generate the canvas?

dentistfrankchen commented 2 years ago

Today I solved this problem. Closing issue.