You must be logged in to post your query.
Home › Forums › Feature Requests & Feedback › A Code to export all data graph to clipboard by tab separator
Tagged: Copy Table
This implementation code add into dropdown menu a copy to table tool that export all informations of the graph to table text separated by tab that can paste into Excel:
CultureInfo: { … copyData: “Copy Data”, copiedData: “Copied to clipboard”, … }
…
p.prototype.add_dropdownMenu = function(html,fn_click) { var obj=this; var opStatus=false; var opMenu = document.createElement(“div”); opMenu.style.cssText=”padding: 12px 8px 12px 8px”; opMenu.innerHTML=html; opMenu.style.backgroundColor = obj.toolbar.backgroundColor; opMenu.style.color = obj.toolbar.fontColor; obj._dropdownMenu.appendChild(opMenu); O(opMenu, “touchstart”, function(a) {opStatus=true}, obj.allDOMEventHandlers); O(opMenu, “mouseover”, function() { opStatus || (this.style.backgroundColor = obj.toolbar.backgroundColorOnHover, this.style.color = obj.toolbar.fontColorOnHover) }, obj.allDOMEventHandlers, !0); O(opMenu, “mouseout”, function() { opStatus || (this.style.backgroundColor = obj.toolbar.backgroundColor, this.style.color = obj.toolbar.fontColor) }, obj.allDOMEventHandlers, !0); O(opMenu, “click”, fn_click, obj.allDOMEventHandlers, !0); };
p.prototype.copyData = function(fileName,sepFields,sepLines) { var dt={}; var header=[this.axisX && this.axisX[0] && this.axisX[0].title?this.axisX[0].title:’Date’]; if(this.title && this.title.text) header.push(‘Title’); for(var i=0;i<this.subtitles.length;i++) header.push(‘Subtitle’+(i+1)); if(this.axisY && this.axisY[0] && this.axisY[0].title) { var axisY=this.axisY[0].title; header.push(‘Unit’); } else var axisY=false; for(var i=0;i<this.data.length;i++) { header.push(this.data[i].legendText); for(var j=0;j<this.data[i].dataPoints.length;j++) { var d=this.data[i].dataPoints[j].x; if(dt[d]==undefined) { dt[d]=new Array(1); var oD=new Date(d); var e=oD.getTimezoneOffset(); dt[d][0]=oD.getFullYear()+ (‘-0’+(oD.getMonth()+1)+’-0’+oD.getDate()+’ 0’+oD.getHours()+’:0’+oD.getMinutes()+’:0’+oD.getSeconds()).replace(/0(\d{2})/g,’$1′)+’ ‘+ (0 < e ? “-” : “+”)+(“0″+Math.floor(Math.abs(e) / 60)).replace(/0(\d{2})/g,’$1′)+(“0″+Math.floor(Math.abs(e) % 60)).replace(/0(\d{2})/g,’$1′);
if(this.title && this.title.text) dt[d].push(this.title.text); for(var i=0;i<this.subtitles.length;i++) dt[d].push(this.subtitles[i].text); if(axisY) dt[d].push(axisY); } dt[d].push(this.data[i].dataPoints[j].y); } } var out=Object.values(dt); out.unshift(header); for(var i=0;i<out.length;i++) out[i]=out[i].join(sepFields||’\t’); out=out.join(sepLines||’\n’);
window.$.copy(out);/*Ed.js*/ alert(this._cultureInfo.copiedData); };
You must be logged in to reply to this topic. Login/Register