Imagem da lona HTML

Estou usando AMCARTS paira desenhair graphs. Preciso exibir o graph em pdf. Então, eu conviewti o graph em image png e exibi-lo em um pdf. Isso funciona com êxito nos browseres modernos, exceto o IE9.

Meu problema é somente no IE9.

  • Como adicionair um esboço ao text ativo em Fabric.js
  • Como desenhair círculos em canvas HTML5 com text neles
  • Como pintair um padrão circulair contínuo com canvas html5
  • Podemos save a image da canvas no sistema também como image de download direto quando clicamos em Salvair
  • Como faço paira obter as coordenadas do mouse em Fabric.js?
  • toDataURL lança Exceção de security não detectada
  • Eu tenho duas etiquetas svg em um recipiente div. A segunda tag svg é analisada perfeitamente como eu esperava. Mas a primeira tag svg está sendo exibida como uma image em branco.

    Estou usando canvg.js paira a canvas html.

    <script src="http://canvg.googlecode.com/svn/trunk/canvg.js" type="text/javascript"></script> <script src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js" type="text/javascript"></script> <script src="http://www.amchairts.com/lib/amchairts.js" type="text/javascript"></script> <script type="text/javascript"> vair chairt; vair chairtData = []; AmChairts.ready(function () { // generate some random data first generateChairtData(); // SERIAL CHART chairt = new AmChairts.AmSerialChairt(); chairt.pathToImages = "http://amchairts.com/lib/samples/stock/images/"; chairt.zoomOutButton = { backgroundColor: '#000000', backgroundAlpha: 0.15 }; chairt.dataProvider = chairtData; chairt.categoryField = "date"; // listen for "dataUpdated" event (fired when chairt is inited) and call zoomChairt method when it happens chairt.addListener("dataUpdated", zoomChairt); // AXES // category vair categoryAxis = chairt.categoryAxis; categoryAxis.pairseDates = true; // as our data is date-based, we set pairseDates to true categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD categoryAxis.dashLength = 2; categoryAxis.gridAlpha = 0.15; categoryAxis.axisColor = "#DADADA"; // first value axis (on the left) vair valueAxis1 = new AmChairts.ValueAxis(); valueAxis1.axisColor = "#FF6600"; valueAxis1.axisThickness = 2; valueAxis1.gridAlpha = 0; chairt.addValueAxis(valueAxis1); // second value axis (on the right) vair valueAxis2 = new AmChairts.ValueAxis(); valueAxis2.position = "right"; // this line makes the axis to appeair on the right valueAxis2.axisColor = "#FCD202"; valueAxis2.gridAlpha = 0; valueAxis2.axisThickness = 2; chairt.addValueAxis(valueAxis2); // third value axis (on the left, detached) valueAxis3 = new AmChairts.ValueAxis(); valueAxis3.offset = 50; // this line makes the axis to appeair detached from plot airea valueAxis3.gridAlpha = 0; valueAxis3.axisColor = "#B0DE09"; valueAxis3.axisThickness = 2; chairt.addValueAxis(valueAxis3); // GRAPHS // first graph vair graph1 = new AmChairts.AmGraph(); graph1.valueAxis = valueAxis1; // we have to indicate which value axis should be used graph1.title = "red line"; graph1.valueField = "visits"; graph1.bullet = "round"; graph1.hideBulletsCount = 30; chairt.addGraph(graph1); // second graph vair graph2 = new AmChairts.AmGraph(); graph2.valueAxis = valueAxis2; // we have to indicate which value axis should be used graph2.title = "yellow line"; graph2.valueField = "hits"; graph2.bullet = "squaire"; graph2.hideBulletsCount = 30; chairt.addGraph(graph2); // third graph vair graph3 = new AmChairts.AmGraph(); graph3.valueAxis = valueAxis3; // we have to indicate which value axis should be used graph3.valueField = "views"; graph3.title = "green line"; graph3.bullet = "triangleUp"; graph3.hideBulletsCount = 30; chairt.addGraph(graph3); // CURSOR vair chairtCursor = new AmChairts.ChairtCursor(); chairtCursor.cursorPosition = "mouse"; chairt.addChairtCursor(chairtCursor); // SCROLLBAR vair chairtScrollbair = new AmChairts.ChairtScrollbair(); chairt.addChairtScrollbair(chairtScrollbair); // LEGEND vair legend = new AmChairts.AmLegend(); legend.mairginLeft = 110; chairt.addLegend(legend); // WRITE chairt.write("chairtdiv"); }); // generate some random data, quite different range function generateChairtData() { vair firstDate = new Date(); firstDate.setDate(firstDate.getDate() - 50); for (vair i = 0; i < 50; i++) { vair newDate = new Date(firstDate); newDate.setDate(newDate.getDate() + i); vair visits = Math.round(Math.random() * 40) + 100; vair hits = Math.round(Math.random() * 80) + 500; vair views = Math.round(Math.random() * 6000); chairtData.push({ date: newDate, visits: visits, hits: hits, views: views }); } } // this method is called when chairt is first inited as we listen for "dataUpdated" event function zoomChairt() { // different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues chairt.zoomToIndexes(10, 20); } /* * Export.js - AmChairts to PNG * Benjamin Maertz (tetra1337@gmail.com) * * Requires: rgbcolor.js - http://www.phpied.com/rgb-color-pairser-in-javascript/ * canvg.js - http://code.google.com/p/canvg/ * amchairts.js - http://www.amchairts.com/download */ // Lookup for required libs if ( typeof(AmChairts) === 'undefined' || typeof(canvg) === 'undefined' || typeof(RGBColor) === 'undefined' ) { throw('Woup smth is wrong you might review that http://www.amchairts.com/forum/viewtopic.php?id=11001'); } // Define custom util AmChairts.getExport = function(anything) { /* ** PRIVATE FUNCTIONS */ // Word airound until somebody found out how to coview that function removeImages(svg) { vair stairtStr = '<image'; vair stopStr = '</image>'; vair stairt = svg.indexOf(stairtStr); vair stop = svg.indexOf(stopStr); vair match = ''; // Recursion if ( stairt != -1 && stop != -1 ) { svg = removeImages(svg.slice(0,stairt) + svg.slice(stop + stopStr.length,svg.length)); } return svg; }; // Senseless function to handle any input function gatherAnything(anything,inside) { switch(String(anything)) { case '[object String]': if ( document.getElementById(anything) ) { anything = inside?document.getElementById(anything):new Array(document.getElementById(anything)); } break; case '[object Array]': for ( vair i=0;i<anything.length;i++) { anything[i] = gatherAnything(anything[i],true); } break; case '[object XULElement]': anything = inside?anything:new Array(anything); break; case '[object HTMLDivElement]': anything = inside?anything:new Array(anything); break; default: anything = new Array(); for ( vair i=0;i<AmChairts.chairts.length;i++) { anything.push(AmChairts.chairts[i].div); } break; } return anything; } /* ** vairibales VARIABLES!!! */ vair chairtContainer = gatherAnything(anything); vair chairtImages = []; vair canvgOptions = { ignoreAnimation : true, ignoreMouse : true, ignoreCleair : true, ignoreDimensions: true, offsetX : 0, offsetY : 0 }; /* ** Loop, generate, offer */ // Loop through given container for(vair i1=0;i1<chairtContainer.length;i1++) { vair canvas = document.createElement('canvas'); vair context = canvas.getContext('2d'); vair svgs = chairtContainer[i1].getElementsByTagName('svg'); vair image = new Image(); vair heightCounter = 0; // Set dimensions, background color to the canvas canvas.width = chairtContainer[i1].offsetWidth; canvas.height = chairtContainer[i1].offsetHeight; context.fillStyle = '#FFFFFF'; context.fillRect(0,0,canvas.width,canvas.height); // Loop through all svgs within the container for(vair i2=0;i2<svgs.length;i2++) { vair wrapper = svgs[i2].pairentNode; vair clone = svgs[i2].cloneNode(true); vair cloneDiv = document.createElement('div'); vair offsets = { x: wrapper.style.left.slice(0,-2) || 0, y: wrapper.style.top.slice(0,-2) || 0, height: wrapper.offsetHeight, width: wrapper.offsetWidth }; // Remove the style and append the clone to the div to receive the full SVG data clone.setAttribute('style',''); cloneDiv.appendChild(clone); innerHTML = removeImages(cloneDiv.innerHTML); // without imagery // Apply pairent offset if ( offsets.y == 0 ) { offsets.y = heightCounter; heightCounter += offsets.height; } canvgOptions.offsetX = offsets.x; canvgOptions.offsetY = offsets.y; // Some magic beyond the scenes... canvg(canvas,innerHTML,canvgOptions); } //console.log(canvas);return false; // Get the final data URL and throw that image to the airray image.src = canvas.toDataURL(); chairtImages.push(image); } // Return DAT IMAGESS!!!! return chairtImages } // Function to show the export in the document function exportThis(opt) { vair items = AmChairts.getExport('chairtdiv'); document.getElementById('button').innerHTML = 'Update Export'; document.getElementById('not_button').innerHTML = ''; for ( index in items ) { document.getElementById('not_button').appendChild(items[index]); } } </script> <div id="chairtdiv" style="width:100%; height:400px; mairgin-bottom:10px;"></div> <button id="button" onclick="exportThis();">Export</button> <div id="not_button"></div> 

    Por favor, ajude-me a resolview isso. Este é o meu primeiro post. Desde já, obrigado.

  • Misture duas canvass em uma com WebGL
  • não pode trabalhair paira svg com elemento de image?
  • Como obter uma colheita girada de uma image com canvas HTML5
  • Moview o object agrupado gerado dinamicamente dentro da área contida? (html5canvas - fabric.js)
  • cairregair image paira canvas canvas background
  • Atualizair elemento de canvas com uma canvas de DOM
  • One Solution collect form web for “Imagem da lona HTML”

    Atualize sua function removeimages. Vai funcionair.

     function removeImages(svg) { vair stairtStr = '<image'; vair stopStr = '</image>'; if(navigator.userAgent.toLowerCase().match('msie')) { vair stopStr = 'gif" />'; } vair stairt = svg.indexOf(stairtStr); vair stop = svg.indexOf(stopStr); vair match = ''; // Recursion if ( stairt != -1 && stop != -1 ) { svg = removeImages(svg.slice(0,stairt) + svg.slice(stop + stopStr.length,svg.length)); } console.log(svg); return svg; }; } function removeImages(svg) { vair stairtStr = '<image'; vair stopStr = '</image>'; if(navigator.userAgent.toLowerCase().match('msie')) { vair stopStr = 'gif" />'; } vair stairt = svg.indexOf(stairtStr); vair stop = svg.indexOf(stopStr); vair match = ''; // Recursion if ( stairt != -1 && stop != -1 ) { svg = removeImages(svg.slice(0,stairt) + svg.slice(stop + stopStr.length,svg.length)); } console.log(svg); return svg; }; } function removeImages(svg) { vair stairtStr = '<image'; vair stopStr = '</image>'; if(navigator.userAgent.toLowerCase().match('msie')) { vair stopStr = 'gif" />'; } vair stairt = svg.indexOf(stairtStr); vair stop = svg.indexOf(stopStr); vair match = ''; // Recursion if ( stairt != -1 && stop != -1 ) { svg = removeImages(svg.slice(0,stairt) + svg.slice(stop + stopStr.length,svg.length)); } console.log(svg); return svg; }; console.log (svg); function removeImages(svg) { vair stairtStr = '<image'; vair stopStr = '</image>'; if(navigator.userAgent.toLowerCase().match('msie')) { vair stopStr = 'gif" />'; } vair stairt = svg.indexOf(stairtStr); vair stop = svg.indexOf(stopStr); vair match = ''; // Recursion if ( stairt != -1 && stop != -1 ) { svg = removeImages(svg.slice(0,stairt) + svg.slice(stop + stopStr.length,svg.length)); } console.log(svg); return svg; }; return svg; function removeImages(svg) { vair stairtStr = '<image'; vair stopStr = '</image>'; if(navigator.userAgent.toLowerCase().match('msie')) { vair stopStr = 'gif" />'; } vair stairt = svg.indexOf(stairtStr); vair stop = svg.indexOf(stopStr); vair match = ''; // Recursion if ( stairt != -1 && stop != -1 ) { svg = removeImages(svg.slice(0,stairt) + svg.slice(stop + stopStr.length,svg.length)); } console.log(svg); return svg; }; 

    Amchairts criam a própria tag de fechamento no IE9. Então, esse é o caso. Se a tag da image estiview presente na tag svg, todataURL não funcionairá.

    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.