Skip to content

Commit

Permalink
Adding legend to the image fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kloivenn committed Jul 26, 2023
1 parent 8a2cdd9 commit 3ccbcbb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/chartBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,23 +300,23 @@ export function chartBase() {

function saveAsPng(chart) {
function drawInlineSVG(svgElement, ctx, callback, legend){
var svgInnerHTML;
var svgInnerHTML, w = 0;
if(legend !== undefined){
var w, h = 0, lsvg, hlist;
var h = 0, lsvg, hlist;
svgInnerHTML = "<g>" + svgElement.innerHTML + "</g>";
legend.container().selectAll("tr").each(function(d, i){
w = 0;
hlist = [];
d3.select(this).selectAll("td").each(function(dtd, itd){
lsvg = d3.select(this).selectAll("svg");
svgInnerHTML += "<g transform='translate(" + (legend.chart.width() + w) + ", "+ h + ")'>" +
svgInnerHTML += "<g transform='translate(" + (legend.chart.width() + w) + ", "+ (h + chart.paddings().top) + ")'>" +
lsvg.node().innerHTML + "</g>"
hlist.push(lsvg.attr("height"));
w += +lsvg.attr("width");
});
h += +d3.max(hlist);
});
svgInnerHTML = "<svg xmlns='http://www.w3.org/2000/svg' width='" + chart.width() + "' height='" + chart.height() + "'>" + svgInnerHTML + "</svg>";
svgInnerHTML = "<svg xmlns='http://www.w3.org/2000/svg' width='" + (chart.width() + w) + "' height='" + chart.height() + "'>" + svgInnerHTML + "</svg>";
} else
svgInnerHTML = new XMLSerializer().serializeToString(svgElement);

Expand Down Expand Up @@ -402,7 +402,7 @@ function saveAsSvg(chart){
hlist = [];
d3.select(this).selectAll("td").each(function(){
lsvg = d3.select(this).selectAll("svg");
html += "<g transform='translate(" + (chart.width() + w) + ", " + h + ")'>" +
html += "<g transform='translate(" + (chart.width() + w) + ", " + (h + chart.paddings().top) + ")'>" +
lsvg.node().innerHTML + "</g>"
hlist.push(lsvg.attr("height"));
w += +lsvg.attr("width");
Expand Down

0 comments on commit 3ccbcbb

Please sign in to comment.