12345678910 |
- /*!
- * filename: ej2-office-chart.min.js
- * version : 19.1.63
- * Copyright Syncfusion Inc. 2001 - 2020. All rights reserved.
- * Use of this code is subject to the terms of our license.
- * A copy of the current license can be obtained at any time by e-mailing
- * licensing@syncfusion.com. Any infringement will be prosecuted under
- * applicable laws.
- */
- this.ej=this.ej||{},this.ej.officechart=function(e,t,r,a){"use strict";t.Chart.Inject(t.AreaSeries,t.StackingAreaSeries,t.BarSeries,t.PieSeries,t.StackingBarSeries,t.PolarSeries,t.ScatterSeries,t.BubbleSeries,t.RadarSeries,t.DateTime,t.ColumnSeries,t.StackingColumnSeries,t.LineSeries,t.StackingLineSeries,t.ErrorBar,t.Trendlines,t.SplineSeries,t.DataLabel,t.Category,t.Legend,t.Tooltip,t.Export),t.AccumulationChart.Inject(t.AccumulationLegend,t.PieSeries,t.AccumulationTooltip,t.AccumulationDataLabel);var i=function(){function e(){}return e.prototype.chartRender=function(e){this.chartType=e.chartType,this.isPieType="Pie"===this.chartType||"Doughnut"===this.chartType;var r=this.chartData(e,this.chartType),a={enableAnimation:!1,width:e.width*(96/72)+"px",height:e.height*(96/72)+"px"};this.isPieType?this.chart=new t.AccumulationChart(a):(this.chart=new t.Chart(a),this.chart.primaryXAxis=this.chartPrimaryXAxis(e.chartPrimaryCategoryAxis,this.chartType),this.chart.primaryYAxis=this.chartPrimaryYAxis(e.chartPrimaryValueAxis)),this.chart.series=this.chartSeries(e.chartSeries,r,this.chartType);for(var i=0;i<this.chart.series.length;i++)this.chart.series[i].animation.enable=!1;this.chart.title=e.chartTitle,this.chart.legendSettings=this.parseChartLegend(e.chartLegend)},e.prototype.convertChartToImage=function(e,t,r){var i=this;return new Promise(function(n,s){var o=0,c=0,h=i.getControlsValue([e],t,r);o=o||h.width,c=c||h.height;var l=a.createElement("canvas"),p=Math.max(1,window.devicePixelRatio||1);l.width=o*p,l.height=c*p,l.style.width=o+"px",l.style.height=c+"px";var u=window.URL.createObjectURL(new Blob([(new XMLSerializer).serializeToString(h.svg)],{type:"image/svg+xml"})),d=new Image,m=l.getContext("2d");m.scale(p,p),d.onload=function(){m.drawImage(d,0,0),window.URL.revokeObjectURL(u);var e=l.toDataURL("image/png");n(e)},d.onerror=function(){s("Invalid data")},d.src=u})},e.prototype.getControlsValue=function(e,t,a){var i=0,n=0,s="",o=new r.SvgRenderer("").createSvg({id:"Image_Export",width:200,height:200});return e.map(function(e){if(e){var r=e.svgObject.cloneNode(!0),a=e.renderer.createGroup({style:"transform: translateY("+n+"px)"});a.appendChild(r),i=Math.max(e.availableSize.width,t),n+=e.availableSize.height,s+=e.svgObject.outerHTML,o.appendChild(a)}}),o.setAttribute("width",i+""),o.setAttribute("height",n+""),{width:i,height:n,svg:o}},e.prototype.officeChartType=function(e){var t="";switch(e){case"Area_Stacked":t="StackingArea";break;case"Area":t="Area";break;case"Area_Stacked_100":t="StackingArea100";break;case"Bar_Clustered":t="Bar";break;case"Bar_Stacked":t="StackingBar";break;case"Bar_Stacked_100":t="StackingBar100";break;case"Column_Clustered":t="Column";break;case"Column_Stacked":t="StackingColumn";break;case"Column_Stacked_100":t="StackingColumn100";break;case"Scatter_Markers":t="Scatter";break;case"Bubble":t="Bubble";break;case"Doughnut":case"Pie":t="Pie";break;case"Line_Stacked_100":case"Line_Markers_Stacked_100":t="StackingLine100";break;case"Line":case"Line_Markers":t="Line";break;case"Line_Stacked":case"Line_Markers_Stacked":t="StackingLine"}return t},e.prototype.chartSeries=function(e,t,r){for(var a=[],i=0;i<e.length;i++){var n=e[i],s=this.writeChartSeries(n,t,r,i);a.push(s)}return a},e.prototype.writeChartSeries=function(e,t,r,a){var i,n=this.officeChartType(r),s={};s.type=n,s.dataSource=t,s.name=e.seriesName,s.xName="x",s.yName="y"+a,"Bubble"===r&&(s.size="size"+a);var o=e.dataPoints[0];if(this.isPieType?(s.pointColorMapping="color","Doughnut"===r&&(s.innerRadius="75%",s.radius="70%")):(i=this.chartFormat(o,n),s.fill=i),"Line_Markers"!==r&&"Line_Markers_Stacked"!==r&&"Line_Markers_Stacked_100"!==r||(s.marker={visible:!0}),e.hasOwnProperty("dataLabel"))if(this.isPieType)s.dataLabel=this.parseDataLabels(e.dataLabel);else{var c={};c.dataLabel=this.parseDataLabels(e.dataLabel),s.marker=c}if(e.hasOwnProperty("errorBar")){var h=e.errorBar;s.errorBar=this.parseErrorBars(h)}if(e.hasOwnProperty("trendLines"))for(var l=e.trendLines,p=[],u=0;u<l.length;u++){var d=l[u],m={};m=this.parseTrendLines(d,i),p.push(m),s.trendlines=p}return s},e.prototype.parseDataLabels=function(e){var t={};return t.visible=!0,this.isPieType?"BestFit"===e.position||"Inside"===e.position?t.position="Inside":t.position="Outside":t.position=this.dataLabelPosition(e.position),t},e.prototype.parseErrorBars=function(e){var t={};return t.visible=!0,t.type=e.type,t.direction=e.direction,"Cap"===e.endStyle?t.errorBarCap={width:1}:t.errorBarCap={width:0},t},e.prototype.parseTrendLines=function(e,t){var r={};return r.type=e.type,r.name=e.name,r.forwardForecast=e.forward,r.backwardForecast=e.backward,"NaN"===e.intercept?r.intercept=0:r.intercept=e.intercept,r.fill=t,r},e.prototype.dataLabelPosition=function(e){var t="Auto";switch(e){case"Outside":t="Outer";break;case"Center":t="Middle";break;case"Inside":t="Top";break;case"OutsideBase":t="Bottom"}return t},e.prototype.chartFormat=function(e,t){var r=e;return"Line"===t||"StackingLine"===t||"StackingLine100"===t?r.line.rgb:r.fill.rgb},e.prototype.chartPrimaryXAxis=function(e,t){var r={};e.chartTitle&&(r.title=e.chartTitle);var a=this.chartCategoryType(e.categoryType);return r.valueType=a,"DateTime"===a&&(r.intervalType="Days",r.labelFormat="M/d/yyyy",r.edgeLabelPlacement="Shift"),"Scatter_Markers"!==t&&"Bubble"!==t||this.checkAndSetAxisValue(r,e),e.hasMajorGridLines&&(r.majorGridLines={width:1}),e.hasMinorGridLines&&(r.minorTicksPerInterval=4),r},e.prototype.chartCategoryType=function(e){var t="";switch(e){case"Time":t="DateTime";break;case"Automatic":t="Category"}return t},e.prototype.chartPrimaryYAxis=function(e){var t={};return e.chartTitle&&(t.title=e.chartTitle),this.checkAndSetAxisValue(t,e),e.hasMajorGridLines&&(t.majorGridLines={width:1}),e.hasMinorGridLines&&(t.minorTicksPerInterval=4),t},e.prototype.checkAndSetAxisValue=function(e,t){a.isNullOrUndefined(t.minimumValue)||(e.minimum=t.minimumValue),a.isNullOrUndefined(t.maximumValue)||0===t.maximumValue||(e.maximum=t.maximumValue),a.isNullOrUndefined(t.majorUnit)||0===t.majorUnit||(e.interval=t.majorUnit)},e.prototype.chartData=function(e,t){for(var r=e.chartCategory,a=[],i=0;i<r.length;i++){var n=r[i],s=this.chartPlotData(n,e,t,i);a.push(s)}return a},e.prototype.chartPlotData=function(e,t,r,a){var i={},n=t.chartSeries;if("m/d/yyyy"===t.chartPrimaryCategoryAxis.numberFormat){var s=e.categoryXName.split("/"),o=Number(s[0]),c=Number(s[1]),h=Number(s[2]);i.x=new Date(h,o-1,c)}else i.x=e.categoryXName;for(var l=0;l<n.length;l++){var p=e.chartData[l];if(i["y"+l]=p.yValue,"Bubble"===r&&(i["size"+l]=p.size),"Pie"===t.chartType||"Doughnut"===t.chartType){var u=n[l].dataPoints[a];i.color=this.chartFormat(u,r)}}return i},e.prototype.parseChartLegend=function(e){var t={},r=e.position;return"Corner"===r&&(r="right"),r?(t.visible=!0,t.position=r.charAt(0).toUpperCase()+r.slice(1)):t.visible=!1,t},e.prototype.destroy=function(){this.chart&&this.chart.destroy(),this.chart=void 0},e}();return e.ChartComponent=i,e}({},ej.charts,ej.svgbase,ej.base),this.ejs=ej;
|