Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play nicely with Seed framework #16

Closed
leroycep opened this issue Jun 25, 2019 · 1 comment
Closed

Play nicely with Seed framework #16

leroycep opened this issue Jun 25, 2019 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@leroycep
Copy link
Contributor

Hello, I'm using seed for a frontend project, and want to use plotters to render graphs.
Seed doesn't allow direct access to the elements that it creates, so drawing to a canvas through seed doesn't work.

Right now I'm using plotlib for generating graphs. I render an svg to a buffer and convert it into a blob. Then I create an <image> that points to the blob. This doesn't work in plotters because the svg and bitmap backends are completely disabled for wasm.

The easiest fix is to simply allow the in memory targets for the svg and bitmap backends in wasm and only disable the file target.

Another fix might be too create a backend specific to seed, or to have some way of accepting a canvas from seed. I think this might be a better route in the long term, but I'm not exactly sure how it would work.

@38
Copy link
Member

38 commented Jun 25, 2019

Thanks for the suggestion.

The WASM compile flag is too strict, I already fixed this in version 0.2.2. Feel free to play with it! It should come with SVG support which should be able to do the thing you describe.

    let mut buffer = vec![];
    {
        let root = SVGBackend::with_buffer(&mut buffer, (640,480)).into_drawing_area();
        // do drawing here
    }
       let svg:String = String::from_utf8_lossy(buffer.as_slice()).into();

Unfortunately, bitmap backend requires font rendering library, which doesn't supported by WASM yet. So I believe it's not easy to get bitmap backend.

For the seed support, currently we pass an element id for the canvas object. But I am planning to make it accept the canvas object directly as well, after that, I think it would be able to make the seed's canavs work.

Closing this issue, and open another issue #17 tracking the last one.

Thanks for feedback and hope that will help. Feel free to reopen it if you have any concern.

@38 38 closed this as completed Jun 25, 2019
@38 38 added enhancement New feature or request bug Something isn't working labels Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants