javascript - dojox.charting.Chart SVG surface issue -


i need export dojo chart image format preferably png. unfortunality there no in-built feature have found way around this. dojo charts based on svg graphics:

i first svg string after chart rendered, send string server via ajax , use imagemagick php library convert png. whole process working there issue:

the svg string dojo charts not contain full details, chart title , axis values , markers not present in svg string, can possible issue?

following code in have re-printed extracted svg string dojo chart div, can see difference visually.

var mychart;  require(["dojo/ready", "dojox/charting/chart2d", "dojox/gfx/utils", "dojox/charting/action2d/tooltip", "dojox/charting/action2d/highlight", "dojox/charting/themes/claro"], function (ready, chart, utils, tooltip, highlight, clarotheme) {   ready(function () {     mychart = chart("mychart");     mychart.title = "my chart";      mychart.addplot("column_plot", {       type: "columns",       lines: true,       areas: false,       markers: true     });      var column_tooltip = new tooltip(mychart, "column_plot");     var column_highlight = new highlight(mychart, "column_plot");      mychart.addaxis("x", {vertical: false});     mychart.addaxis("y", {vertical: true});      mychart.addseries("column_series", [1, 3, 5, 2, 6, 1, 0, 4, 6, 4, 1], {       plot: "column_plot"     });      mychart.settheme(clarotheme);     mychart.render();       //this function called after render send svg server via ajax     document.getelementbyid("syncbutton").onclick = function (e) {        var svgstring = utils.tosvg(mychart.surface).results[0];        document.getelementbyid("svgchart").innerhtml = svgstring;            };    }); }); 

http://jsfiddle.net/hafsd/7/

by default, labels drawn using html markups, not part of gfx scene. that's why not in generated svg output. should explicitly turn off html labels rendering htmllabels: false axis property.

    chart.addaxis("x", {           type : "default",            fixlower: "minor",           natural: true,           enablecache: true,           htmllabels: false,           majortick: {color: "red", length: 4},           minortick: {color: "blue", length: 2}     }); 

in configuration, labels rendered via underlying gfx renderer (svg, canvas, etc) , in svg output.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -