javascript - How to See Only the Image of Chart -
below code generates image of chart after chart has been generated. want see image. possible?
i tried display: none;
chart's div image doesn't seem.
$(function() { var ctx = document.getelementbyid('mychart'); var mychart = new chart(ctx, { type: 'line', data: { labels: ["july","august","september","october","november","december","january","february","march","april"], datasets: [ { label: 'this year', data: [340,0,450,3240,360,200,0,0,1445,350], } , { label: 'last year', data: [330,340,100,160,560,3600,320,0,397.5,300], } ] }, options: { maintainaspectratio: false, responsive: true, animation: { oncomplete: function(animation){ document.queryselector('#mychart').setattribute('href', this.tobase64image()); document.queryselector('#myimage').setattribute('src', this.tobase64image()); } } } }); })
based on question, created fiddle. removing chart using below line.
animation: { duration: 0, oncomplete: function(animation){ document.queryselector('#mychart').remove(); document.queryselector('#myimage').setattribute('src', this.tobase64image()); } }
jsfiddle: here
Comments
Post a Comment