Skip to content

Static Image Export in plotly.js does not work for polar charts #1654

Closed
@dugagjin

Description

@dugagjin

Hi,

The code here

var d3 = Plotly.d3;
var img_jpg= d3.select('#jpg-export');
// Ploting the Graph
var trace={x:[3,9,8,10,4,6,5],y:[5,7,6,7,8,9,8],type:"scatter"};
var trace1={x:[3,4,1,6,8,9,5],y:[4,2,5,2,1,7,3],type:"scatter"};
var data = [trace,trace1];
var layout = {title : "Simple Javascript Graph"};
Plotly.plot(
  'plotly_div',
   data,
   layout)
// static image in jpg format
.then(
    function(gd)
     {
      Plotly.toImage(gd,{height:300,width:300})
         .then(
            function(url)
         {
             img_jpg.attr("src", url);
             return Plotly.toImage(gd,{format:'jpeg',height:400,width:400});
         }
         )
    });

is from Export Javascript plots as jpeg, png,... and it works for line charts.
But if I replace the x with t and y with r (at the trace variables) to make it a polar chart:

var d3 = Plotly.d3;
var img_jpg= d3.select('#jpg-export');
// Ploting the Graph
var trace={t:[3,9,8,10,4,6,5],r:[5,7,6,7,8,9,8],type:"scatter"};
var trace1={t:[3,4,1,6,8,9,5],r:[4,2,5,2,1,7,3],type:"scatter"};
var data = [trace,trace1];
var layout = {title : "Simple Javascript Graph"};
Plotly.plot(
  'plotly_div',
   data,
   layout)
// static image in jpg format
.then(
    function(gd)
     {
      Plotly.toImage(gd,{height:300,width:300})
         .then(
            function(url)
         {
             img_jpg.attr("src", url);
             return Plotly.toImage(gd,{format:'jpeg',height:400,width:400});
         }
         )
    });

then I don't get the exported image but I get the following error:

plotly-latest.min.js:66 Uncaught (in promise) TypeError: Cannot read property 'framework' of undefined
at e.exports (plotly-latest.min.js:66)
at plotly-latest.min.js:58
at Promise ()
at Object.n [as toImage] (plotly-latest.min.js:58)

You can find a jsfiddle here: https://jsfiddle.net/f87k57nt/ just change the x and y to respectively t and r in order to see the issue. You will see the svg of the polar plot but not the png.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions