qlik-oss / picasso.js

A charting library streamlined for building interactive visualizations for the Qlik product suites.
https://qlik.dev/libraries-and-tools/picassojs
MIT License
188 stars 55 forks source link

How do you use canvas to render figures? #65

Open slowkow opened 6 years ago

slowkow commented 6 years ago

This tutorial suggests that picasso.js can render to a canvas, an svg element, or the dom:

https://beta.observablehq.com/@cbt1/picasso-js-creating-your-own-tooltip-component

Is that true?

I don't see any documentation about specifying canvas instead of svg to render figures.

Could I please ask for a minimal example?

It would be nice if I could search for "canvas" or "render" and find instructions on the documentation page: https://picassojs.com/docs/chart.html#render-a-chart

mindspank commented 6 years ago

Each component will have a rendering target where canvas is the prefered one. You can also specify a priority order on the picasso instance picasso.renderer.prio(['canvas'])

slowkow commented 6 years ago

Thanks, Alexander!

Here is a minimal example showing how to switch from SVG to canvas.

Note that SVG is the default renderer, not canvas.

https://jsfiddle.net/slowkow/5ry08e77/

This uses canvas to render the figure:

// this works
picasso.renderer.prio(['canvas'])

// this also works
picasso.renderer.default('canvas')

var mychart = picasso.chart({})

This uses SVG to render the figure:

var mychart = picasso.chart({})

Could I please ask you to add this to the documentation?

The page exists: https://picassojs.com/docs/picasso.html

But there is no link to this page in the documentation, as far as I can tell.

I only found that page because I saw it in the GitHub repo here: docs/dist/picasso.md

mindspank commented 6 years ago

@miralemd ^^ Assuming picasso.renderer.prio() is stable enough to document? If so I can take a stab at it.

miralemd commented 6 years ago

We do indeed support canvas rendering but have apparently completely missed to document that :D.

The way to enable it is to specify the defaultrenderer you want to use on the picasso instance

picasso.renderer.default('canvas')`

@mindspank Stab it :P