Exporting To PNG Losing text Added In Rendered Event

Posted by: marcus.nixon on 14 April 2019, 7:31 pm EST

  • Posted 14 April 2019, 7:31 pm EST

    Hi,

    I've got a pie chart in donut form, and I use the rendered event to place some text into the centre using engine.drawString. However, if I then export the chart to a PNG using saveImageToFile, the text that I have draw is not visible. Why is that? Thanks in advance.
  • Replied 14 April 2019, 11:00 pm EST

    Can I also just report another even more strange issue relating to export as image.

    So our web page has a dashboard, containing a bunch of pie charts. Some of those pie charts have text in the centre, and some do not. If I export one of the charts that has no centre text, then for some reason the charts that do have centre text are magically updated and have their text cleared! I dont see why exporting 1 chart can have any impact on any other chart, but that looks like what is happening. This happens 9 out of 10 times. Its such a strange bug, I can't really begin to understand what is going on. Any ideas?
  • Replied 15 April 2019, 8:52 pm EST

    Hi,

    We are sorry but we were not able to replicate the issue. Could you please have a look at the following sample and let us know if we are missing something in order to replicate the issue:
    https://jsfiddle.net/rs3akdu7/

    Feel free to modify the sample so that it replicates the issue.

    Also, please let us know the wijmo version you are using so that we may test on the same version once.

    ~Sharad
  • Replied 15 April 2019, 10:41 pm EST

    ok mate, thanks. I'll take a look at that in more detail when I get time. However, one quick observation I can make is that your charts export to PNG with a white background, but when I export they are transparent. That may or may not be related to this issue, but its odd. I would very much like outs to have a white background also, is there anything you have done specifically to enable the white background? I posted a forum question about this a short time back, and was told that PNG files always export with a transparent background.

    FYI, i'm using IE.
  • Replied 17 April 2019, 5:17 pm EST

    Hi,

    Could you please try setting the Chart Background to white in css before exporting and let us know if this helps.

    wj-flexchart {
    background: white;
    }
  • Replied 17 April 2019, 8:14 pm EST

    OK, that fixed the transparent background when exporting, thanks for that. Still doesn't show the text that i've added with engine.drawString though.

    FYI, the reason the background is transparent by default is because it's in your wijmo.css. Oddly, its set it to white, and then a few lines later its set it to transparent.

    .wj-flexchart {
    height: 400px;
    padding: 15px 10px;
    margin-bottom: 12px;
    background: white;
    border: 1px solid #e4e4e4;
    display: block;
    background: transparent; }
  • Replied 17 April 2019, 8:44 pm EST

    UPDATE:

    OK, i've gotten to the bottom of why the text doesnt appear when exporting. Its because i have the reference to wijmo.chart.render.js included. If I remove that, then it exports in Chrome just fine, including the text drawn with engine.drawString.

    The problem is that it is needed under IE otherwise I get a "security error" message. However, under IE it still does not render the text drawn with engine.drawString. You should be able to replicate this issue by including the render JS file in your sample and running it under IE or Chrome.

    I do not know if the issue I reported above whereby all the pie charts update their text magically when exporting a single chart will now be fixed, so I'm going to test that out and report back.

    I have a real sense of deja vu with this, as I'm almost certain that I discovered the exact same issue using wijmo 3 charts, now I come to think about it.
  • Replied 21 April 2019, 10:12 pm EST

    Hi Marcus,

    We have added a feature request with internal tracking ID 375818 to implement this feature. I have added you as a correspondent and will notify you once this case gets implemented.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels