You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@syncfusion/ej2-office-chart

Package Overview
Dependencies
Maintainers
3
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@syncfusion/ej2-office-chart - npm Package Compare versions

Comparing version
31.1.17
to
31.2.2
+2
-0
.eslintrc.json

@@ -42,2 +42,4 @@ {

"security/detect-bidi-characters":"error",
"no-prototype-builtins": "warn",
"no-extend-native": ["warn"],
"@typescript-eslint/no-inferrable-types": "off",

@@ -44,0 +46,0 @@ "@typescript-eslint/ban-types": ["warn", {

+3
-3
/*!
* filename: ej2-office-chart.min.js
* version : 31.1.17
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* version : 31.2.2
* Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
* Use of this code is subject to the terms of our license.

@@ -10,2 +10,2 @@ * A copy of the current license can be obtained at any time by e-mailing

*/
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("SyncfusionCharts"),require("SyncfusionSvgBase"),require("SyncfusionBase")):"function"==typeof define&&define.amd?define(["SyncfusionCharts","SyncfusionSvgBase","SyncfusionBase"],r):"object"==typeof exports?exports.SyncfusionOfficeChart=r(require("SyncfusionCharts"),require("SyncfusionSvgBase"),require("SyncfusionBase")):e.SyncfusionOfficeChart=r(e.SyncfusionCharts,e.SyncfusionSvgBase,e.SyncfusionBase)}(self,((e,r,t)=>(()=>{"use strict";var i={766:e=>{e.exports=t},60:r=>{r.exports=e},727:e=>{e.exports=r}},a={};function o(e){var r=a[e];if(void 0!==r)return r.exports;var t=a[e]={exports:{}};return i[e](t,t.exports,o),t.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{ChartComponent:()=>i,backwardProperty:()=>M,categoryTypeProperty:()=>O,categoryXNameProperty:()=>R,chartCategoryProperty:()=>h,chartDataProperty:()=>d,chartLegendProperty:()=>y,chartPrimaryCategoryAxisProperty:()=>p,chartPrimaryValueAxisProperty:()=>l,chartSeriesProperty:()=>c,chartTitleProperty:()=>u,chartTypeProperty:()=>k,dataLabelProperty:()=>m,dataPointsProperty:()=>x,directionProperty:()=>T,endStyleProperty:()=>A,errorBarProperty:()=>g,fillProperty:()=>S,foreColorProperty:()=>P,forwardProperty:()=>B,hasMajorGridLinesProperty:()=>j,hasMinorGridLinesProperty:()=>V,heightProperty:()=>s,idProperty:()=>v,interceptProperty:()=>N,isAutoMajorProperty:()=>U,lineProperty:()=>I,majorUnitProperty:()=>D,maximumValueProperty:()=>F,minimumValueProperty:()=>z,nameProperty:()=>_,numberFormatProperty:()=>Y,positionProperty:()=>C,rgbProperty:()=>b,seriesFormatProperty:()=>X,seriesNameProperty:()=>f,sizeProperty:()=>G,trendLinesProperty:()=>w,typeProperty:()=>L,widthProperty:()=>a,yValueProperty:()=>E});var e=o(60),r=o(727),t=o(766);e.Chart.Inject(e.AreaSeries,e.StackingAreaSeries,e.BarSeries,e.PieSeries,e.StackingBarSeries,e.PolarSeries,e.ScatterSeries,e.BubbleSeries,e.RadarSeries,e.DateTime,e.ColumnSeries,e.StackingColumnSeries,e.LineSeries,e.StackingLineSeries,e.ErrorBar,e.Trendlines,e.SplineSeries,e.DataLabel,e.Category,e.Legend,e.Tooltip,e.Export),e.AccumulationChart.Inject(e.AccumulationLegend,e.PieSeries,e.AccumulationTooltip,e.AccumulationDataLabel);var i=function(){function i(){this.keywordIndex=void 0,this.chartYValues=[]}return i.prototype.chartRender=function(r,i){this.keywordIndex=(0,t.isNullOrUndefined)(i)?0:i,this.chartType=r[k[this.keywordIndex]],this.isPieType="Pie"===this.chartType||"Doughnut"===this.chartType;var o=this.chartData(r,this.chartType),n={enableAnimation:!1,width:r[a[this.keywordIndex]]*(96/72)+"px",height:r[s[this.keywordIndex]]*(96/72)+"px"};this.isPieType?this.chart=new e.AccumulationChart(n):(this.chart=new e.Chart(n),this.chart.primaryXAxis=this.chartPrimaryXAxis(r[p[this.keywordIndex]],this.chartType),this.chart.primaryYAxis=this.chartPrimaryYAxis(r[l[this.keywordIndex]])),this.chart.series=this.chartSeries(r[c[this.keywordIndex]],o,this.chartType);for(var d=0;d<this.chart.series.length;d++)this.chart.series[parseInt(d.toString(),10)].animation.enable=!1;this.chart.title=r[u[this.keywordIndex]],this.chart.legendSettings=this.parseChartLegend(r[y[this.keywordIndex]])},i.prototype.convertChartToImage=function(e,r,i){var a=this;return new Promise((function(o,n){var s=0,d=0,h=a.getControlsValue([e],r,i);s=s||h.width,d=d||h.height;var c=(0,t.createElement)("canvas"),y=Math.max(1,window.devicePixelRatio||1);c.width=s*y,c.height=d*y,c.style.width=s+"px",c.style.height=d+"px";var p=window.URL.createObjectURL(new Blob([(new XMLSerializer).serializeToString(h.svg)],{type:"image/svg+xml"})),l=new Image,u=c.getContext("2d");u.scale(y,y),l.onload=function(){u.drawImage(l,0,0),window.URL.revokeObjectURL(p);var e=c.toDataURL("image/png");o(e)},l.onerror=function(){n("Invalid data")},l.src=p}))},i.prototype.getControlsValue=function(e,t,i){var a=0,o=0,n=new r.SvgRenderer("").createSvg({id:"Image_Export",width:200,height:200});return e.map((function(e){if(e){var r=e.svgObject.cloneNode(!0),i=e.renderer.createGroup({style:"transform: translateY("+o+"px)"});i.appendChild(r),a=Math.max(e.availableSize.width,t),o+=e.availableSize.height,e.svgObject.outerHTML,n.appendChild(i)}})),n.setAttribute("width",a+""),n.setAttribute("height",o+""),{width:a,height:o,svg:n}},i.prototype.officeChartType=function(e){var r="";switch(e){case"Area_Stacked":r="StackingArea";break;case"Area":r="Area";break;case"Area_Stacked_100":r="StackingArea100";break;case"Bar_Clustered":r="Bar";break;case"Bar_Stacked":r="StackingBar";break;case"Bar_Stacked_100":r="StackingBar100";break;case"Column_Clustered":r="Column";break;case"Column_Stacked":r="StackingColumn";break;case"Column_Stacked_100":r="StackingColumn100";break;case"Scatter_Markers":r="Scatter";break;case"Bubble":r="Bubble";break;case"Doughnut":case"Pie":r="Pie";break;case"Line_Stacked_100":case"Line_Markers_Stacked_100":r="StackingLine100";break;case"Line":case"Line_Markers":r="Line";break;case"Line_Stacked":case"Line_Markers_Stacked":r="StackingLine"}return r},i.prototype.chartSeries=function(e,r,t){for(var i=[],a=0;a<e.length;a++){var o=e[parseInt(a.toString(),10)],n=this.writeChartSeries(o,r,t,a);i.push(n)}return i},i.prototype.writeChartSeries=function(e,r,i,a){var o,n=this.officeChartType(i),s=e[x[this.keywordIndex]][parseInt(a.toString(),10)],d={};if(d.type=n,d.dataSource=r,d.name=e[f[this.keywordIndex]],d.xName="x",d.yName="y"+a,"Bubble"===i&&(d.size="size"+a),this.isPieType?(d.pointColorMapping="color","Doughnut"===i&&(d.innerRadius="75%",d.radius="70%")):((0,t.isNullOrUndefined)(s)&&(s=e[x[this.keywordIndex]][0]),o=this.chartFormat(s,n),d.fill=o,(0,t.isNullOrUndefined)(s[S[this.keywordIndex]][P[this.keywordIndex]])||(d.pointColorMapping="color")),"Line_Markers"!==i&&"Line_Markers_Stacked"!==i&&"Line_Markers_Stacked_100"!==i||(d.marker={visible:!0}),e.hasOwnProperty(m[this.keywordIndex]))if(this.isPieType)d.dataLabel=this.parseDataLabels(e[m[this.keywordIndex]]);else{var h={};h.dataLabel=this.parseDataLabels(e[m[this.keywordIndex]]),d.marker=h}if(e.hasOwnProperty(g[this.keywordIndex])){var c=e[g[this.keywordIndex]];d.errorBar=this.parseErrorBars(c)}if(e.hasOwnProperty(w[this.keywordIndex]))for(var y=e[w[this.keywordIndex]],p=[],l=0;l<y.length;l++){var u,k=y[parseInt(l.toString(),10)];u=this.parseTrendLines(k,o),p.push(u),d.trendlines=p}return d},i.prototype.parseDataLabels=function(e){var r={visible:!0};return this.isPieType?"BestFit"===e[C[this.keywordIndex]]||"Inside"===e[C[this.keywordIndex]]?r.position="Inside":r.position="Outside":r.position=this.dataLabelPosition(e[C[this.keywordIndex]]),r},i.prototype.parseErrorBars=function(e){var r={visible:!0};return r.type=e[L[this.keywordIndex]],r.direction=e[T[this.keywordIndex]],"Cap"===e[A[this.keywordIndex]]?r.errorBarCap={width:1}:r.errorBarCap={width:0},r},i.prototype.parseTrendLines=function(e,r){var t={};return t.type=e[L[this.keywordIndex]],t.name=e[_[this.keywordIndex]],t.forwardForecast=e[B[this.keywordIndex]],t.backwardForecast=e[M[this.keywordIndex]],"NaN"===e[N[this.keywordIndex]]?t.intercept=0:t.intercept=e[N[this.keywordIndex]],t.fill=r,t},i.prototype.dataLabelPosition=function(e){var r="Auto";switch(e){case"Outside":r="Outer";break;case"Center":r="Middle";break;case"Inside":r="Top";break;case"OutsideBase":r="Bottom"}return r},i.prototype.chartFormat=function(e,r){var t=e;return"Line"===r||"StackingLine"===r||"StackingLine100"===r?t[I[this.keywordIndex]][b[this.keywordIndex]]:t[S[this.keywordIndex]][b[this.keywordIndex]]},i.prototype.chartPrimaryXAxis=function(e,r){var t={};e[u[this.keywordIndex]]&&(t.title=e[u[this.keywordIndex]]);var i=this.chartCategoryType(e[O[this.keywordIndex]]);return t.valueType=i,"DateTime"===i&&(t.intervalType="Days",t.labelFormat="M/d/yyyy",t.edgeLabelPlacement="Shift"),"Scatter_Markers"!==r&&"Bubble"!==r||this.checkAndSetAxisValue(t,e),this.parseBoolValue(e[j[this.keywordIndex]])&&(t.majorGridLines={width:1}),this.parseBoolValue(e[V[this.keywordIndex]])&&(t.minorTicksPerInterval=4),t},i.prototype.chartCategoryType=function(e){var r="";switch(e){case"Time":r="DateTime";break;case"Automatic":r="Category"}return r},i.prototype.chartPrimaryYAxis=function(e){var r={};return e[u[this.keywordIndex]]&&(r.title=e[u[this.keywordIndex]]),this.checkAndSetAxisValue(r,e),e[j[this.keywordIndex]]&&(r.majorGridLines={width:1}),e[V[this.keywordIndex]]&&(r.minorTicksPerInterval=4),r},i.prototype.checkAndSetAxisValue=function(e,r){if(0!==r[z[this.keywordIndex]]&&(e.minimum=r[z[this.keywordIndex]]),0!==r[F[this.keywordIndex]]&&(e.maximum=r[F[this.keywordIndex]]),0!==r[D[this.keywordIndex]]){var t=r[U[this.keywordIndex]];if(t&&this.parseBoolValue(t)){var i=this.calculateMajorUnit(this.chartYValues);i<10&&("Bar_Stacked_100"===this.chartType||"Line_Stacked_100"===this.chartType||"Column_Stacked_100"===this.chartType||"Line_Markers_Stacked_100"===this.chartType||"Area_Stacked_100"===this.chartType)?e.interval=10:e.interval=i}else e.interval=r[D[this.keywordIndex]]}},i.prototype.calculateMajorUnit=function(e){if(e&&e.length>0){for(var r=Number.MIN_VALUE,t=Number.MAX_VALUE,i=0;i<e.length;i++){var a=e[parseInt(i.toString(),10)];a>r&&(r=a),a<t&&(t=a)}var o=(r-t)/1.5;return this.roundToNiceNumber(o)}return 1},i.prototype.roundToNiceNumber=function(e){var r=Math.floor(Math.log(e)/Math.log(10)),t=Math.pow(10,r),i=e/t;return i<1.5?1*t:i<3?2*t:i<7?5*t:10*t},i.prototype.chartData=function(e,r){for(var t=e[h[this.keywordIndex]],i=[],a=0;a<t.length;a++){var o=t[parseInt(a.toString(),10)],n=this.chartPlotData(o,e,r,a);i.push(n)}return i},i.prototype.chartPlotData=function(e,r,i,a){var o=this,n={},s=r[c[this.keywordIndex]];if("m/d/yyyy"===r[p[this.keywordIndex]][Y[this.keywordIndex]]){var h=e[R[this.keywordIndex]].split("/"),y=Number(h[0]),l=Number(h[1]),u=Number(h[2]);n.x=new Date(u,y-1,l)}else n.x=e[R[this.keywordIndex]];for(var w=0;w<s.length;w++){var f=e[d[this.keywordIndex]][parseInt(w.toString(),10)];if(!(0,t.isNullOrUndefined)(f)){var m=f[E[this.keywordIndex]];this.chartYValues.push(m),n["y"+w]=m,"Bubble"===i&&(n["size"+w]=f[G[this.keywordIndex]])}if("Pie"===r[k[this.keywordIndex]]||"Doughnut"===r[k[this.keywordIndex]]||"Column_Stacked"===r[k[this.keywordIndex]]){var g=s[parseInt(w.toString(),10)],I=g[x[this.keywordIndex]].find((function(e){return e[v[o.keywordIndex]]===a}));if((0,t.isNullOrUndefined)(I)){if(g[x[this.keywordIndex]].length>1&&0===g[x[this.keywordIndex]][parseInt(a.toString(),10)][v[this.keywordIndex]]){I=g[x[this.keywordIndex]][parseInt(a.toString(),10)];P=this.chartFormat(I,i);"Column_Stacked"!==r[k[this.keywordIndex]]?n.color=P:n["color"+w]=P}else if(!(0,t.isNullOrUndefined)(g[X[this.keywordIndex]])&&!(0,t.isNullOrUndefined)(g[X[this.keywordIndex]][S[this.keywordIndex]])&&g[X[this.keywordIndex]][S[this.keywordIndex]][b[this.keywordIndex]].length>7){P=this.getColor(g[X[this.keywordIndex]][S[this.keywordIndex]][b[this.keywordIndex]]);"Column_Stacked"!==r[k[this.keywordIndex]]?n.color=P:n["color"+w]=P}}else{var P=this.chartFormat(I,i);"Column_Stacked"!==r[k[this.keywordIndex]]?n.color=P:n["color"+w]=P}}}return n},i.prototype.getColor=function(e){return e.length>0&&"#"===e[0]&&e.length>7?e.substr(0,7):e},i.prototype.parseChartLegend=function(e){var r={},t=e[C[this.keywordIndex]];return"Corner"===t&&(t="right"),t?(r.visible=!0,r.position=t.charAt(0).toUpperCase()+t.slice(1)):r.visible=!1,r},i.prototype.parseBoolValue=function(e){return"string"==typeof e||e instanceof String?!(0,t.isNullOrUndefined)(e)&&"f"!==e&&"0"!==e&&"off"!==e&&"false"!==e:1===e||!0===e},i.prototype.destroy=function(){this.chart&&this.chart.destroy(),this.chart=void 0,this.chartYValues&&(this.chartYValues=[]),this.chartYValues=void 0},i}(),a=["width","w"],s=["height","h"],d=["chartData","chd"],h=["chartCategory","c"],c=["chartSeries","cs"],y=["chartLegend","cl"],p=["chartPrimaryCategoryAxis","cpca"],l=["chartPrimaryValueAxis","cpva"],u=["chartTitle","ctt"],k=["chartType","ct"],w=["trendLines","tl"],x=["dataPoints","dp"],f=["seriesName","sn"],m=["dataLabel","sl"],g=["errorBar","eb"],S=["fill","f"],I=["line","l"],b=["rgb","rgb"],v=["id","i"],P=["foreColor","fc"],C=["position","p"],L=["type","t"],_=["name","n"],T=["direction","dir"],A=["endStyle","est"],B=["forward","fw"],M=["backward","bw"],N=["intercept","itr"],O=["categoryType","ct"],j=["hasMajorGridLines","hmajgl"],V=["hasMinorGridLines","hmingl"],D=["majorUnit","maju"],U=["isAutoMajor","iam"],F=["maximumValue","maxv"],z=["minimumValue","minv"],R=["categoryXName","cx"],Y=["numberFormat","nf"],E=["yValue","y"],G=["size","sz"],X=["seriesFormat","sf"]})(),n})()));
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("SyncfusionCharts"),require("SyncfusionSvgBase"),require("SyncfusionBase")):"function"==typeof define&&define.amd?define(["SyncfusionCharts","SyncfusionSvgBase","SyncfusionBase"],r):"object"==typeof exports?exports.SyncfusionOfficeChart=r(require("SyncfusionCharts"),require("SyncfusionSvgBase"),require("SyncfusionBase")):e.SyncfusionOfficeChart=r(e.SyncfusionCharts,e.SyncfusionSvgBase,e.SyncfusionBase)}(self,(e,r,t)=>(()=>{"use strict";var i={766:e=>{e.exports=t},60:r=>{r.exports=e},727:e=>{e.exports=r}},a={};function o(e){var r=a[e];if(void 0!==r)return r.exports;var t=a[e]={exports:{}};return i[e](t,t.exports,o),t.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{ChartComponent:()=>i,backwardProperty:()=>M,categoryTypeProperty:()=>O,categoryXNameProperty:()=>R,chartCategoryProperty:()=>h,chartDataProperty:()=>d,chartLegendProperty:()=>y,chartPrimaryCategoryAxisProperty:()=>p,chartPrimaryValueAxisProperty:()=>l,chartSeriesProperty:()=>c,chartTitleProperty:()=>u,chartTypeProperty:()=>k,dataLabelProperty:()=>m,dataPointsProperty:()=>x,directionProperty:()=>T,endStyleProperty:()=>A,errorBarProperty:()=>g,fillProperty:()=>S,foreColorProperty:()=>P,forwardProperty:()=>B,hasMajorGridLinesProperty:()=>j,hasMinorGridLinesProperty:()=>V,heightProperty:()=>s,idProperty:()=>v,interceptProperty:()=>N,isAutoMajorProperty:()=>U,lineProperty:()=>I,majorUnitProperty:()=>D,maximumValueProperty:()=>F,minimumValueProperty:()=>z,nameProperty:()=>_,numberFormatProperty:()=>Y,positionProperty:()=>C,rgbProperty:()=>b,seriesFormatProperty:()=>X,seriesNameProperty:()=>f,sizeProperty:()=>G,trendLinesProperty:()=>w,typeProperty:()=>L,widthProperty:()=>a,yValueProperty:()=>E});var e=o(60),r=o(727),t=o(766);e.Chart.Inject(e.AreaSeries,e.StackingAreaSeries,e.BarSeries,e.PieSeries,e.StackingBarSeries,e.PolarSeries,e.ScatterSeries,e.BubbleSeries,e.RadarSeries,e.DateTime,e.ColumnSeries,e.StackingColumnSeries,e.LineSeries,e.StackingLineSeries,e.ErrorBar,e.Trendlines,e.SplineSeries,e.DataLabel,e.Category,e.Legend,e.Tooltip,e.Export),e.AccumulationChart.Inject(e.AccumulationLegend,e.PieSeries,e.AccumulationTooltip,e.AccumulationDataLabel);var i=function(){function i(){this.keywordIndex=void 0,this.chartYValues=[]}return i.prototype.chartRender=function(r,i){this.keywordIndex=(0,t.isNullOrUndefined)(i)?0:i,this.chartType=r[k[this.keywordIndex]],this.isPieType="Pie"===this.chartType||"Doughnut"===this.chartType;var o=this.chartData(r,this.chartType),n={enableAnimation:!1,width:r[a[this.keywordIndex]]*(96/72)+"px",height:r[s[this.keywordIndex]]*(96/72)+"px"};this.isPieType?this.chart=new e.AccumulationChart(n):(this.chart=new e.Chart(n),this.chart.primaryXAxis=this.chartPrimaryXAxis(r[p[this.keywordIndex]],this.chartType),this.chart.primaryYAxis=this.chartPrimaryYAxis(r[l[this.keywordIndex]])),this.chart.series=this.chartSeries(r[c[this.keywordIndex]],o,this.chartType);for(var d=0;d<this.chart.series.length;d++)this.chart.series[parseInt(d.toString(),10)].animation.enable=!1;this.chart.title=r[u[this.keywordIndex]],this.chart.legendSettings=this.parseChartLegend(r[y[this.keywordIndex]])},i.prototype.convertChartToImage=function(e,r,i){var a=this;return new Promise(function(o,n){var s=0,d=0,h=a.getControlsValue([e],r,i);s=s||h.width,d=d||h.height;var c=(0,t.createElement)("canvas"),y=Math.max(1,window.devicePixelRatio||1);c.width=s*y,c.height=d*y,c.style.width=s+"px",c.style.height=d+"px";var p=window.URL.createObjectURL(new Blob([(new XMLSerializer).serializeToString(h.svg)],{type:"image/svg+xml"})),l=new Image,u=c.getContext("2d");u.scale(y,y),l.onload=function(){u.drawImage(l,0,0),window.URL.revokeObjectURL(p);var e=c.toDataURL("image/png");o(e)},l.onerror=function(){n("Invalid data")},l.src=p})},i.prototype.getControlsValue=function(e,t,i){var a=0,o=0,n=new r.SvgRenderer("").createSvg({id:"Image_Export",width:200,height:200});return e.map(function(e){if(e){var r=e.svgObject.cloneNode(!0),i=e.renderer.createGroup({style:"transform: translateY("+o+"px)"});i.appendChild(r),a=Math.max(e.availableSize.width,t),o+=e.availableSize.height,e.svgObject.outerHTML,n.appendChild(i)}}),n.setAttribute("width",a+""),n.setAttribute("height",o+""),{width:a,height:o,svg:n}},i.prototype.officeChartType=function(e){var r="";switch(e){case"Area_Stacked":r="StackingArea";break;case"Area":r="Area";break;case"Area_Stacked_100":r="StackingArea100";break;case"Bar_Clustered":r="Bar";break;case"Bar_Stacked":r="StackingBar";break;case"Bar_Stacked_100":r="StackingBar100";break;case"Column_Clustered":r="Column";break;case"Column_Stacked":r="StackingColumn";break;case"Column_Stacked_100":r="StackingColumn100";break;case"Scatter_Markers":r="Scatter";break;case"Bubble":r="Bubble";break;case"Doughnut":case"Pie":r="Pie";break;case"Line_Stacked_100":case"Line_Markers_Stacked_100":r="StackingLine100";break;case"Line":case"Line_Markers":r="Line";break;case"Line_Stacked":case"Line_Markers_Stacked":r="StackingLine"}return r},i.prototype.chartSeries=function(e,r,t){for(var i=[],a=0;a<e.length;a++){var o=e[parseInt(a.toString(),10)],n=this.writeChartSeries(o,r,t,a);i.push(n)}return i},i.prototype.writeChartSeries=function(e,r,i,a){var o,n=this.officeChartType(i),s=e[x[this.keywordIndex]][parseInt(a.toString(),10)],d={};if(d.type=n,d.dataSource=r,d.name=e[f[this.keywordIndex]],d.xName="x",d.yName="y"+a,"Bubble"===i&&(d.size="size"+a),this.isPieType?(d.pointColorMapping="color","Doughnut"===i&&(d.innerRadius="75%",d.radius="70%")):((0,t.isNullOrUndefined)(s)&&(s=e[x[this.keywordIndex]][0]),o=this.chartFormat(s,n),d.fill=o,(0,t.isNullOrUndefined)(s[S[this.keywordIndex]][P[this.keywordIndex]])||(d.pointColorMapping="color")),"Line_Markers"!==i&&"Line_Markers_Stacked"!==i&&"Line_Markers_Stacked_100"!==i||(d.marker={visible:!0}),e.hasOwnProperty(m[this.keywordIndex]))if(this.isPieType)d.dataLabel=this.parseDataLabels(e[m[this.keywordIndex]]);else{var h={};h.dataLabel=this.parseDataLabels(e[m[this.keywordIndex]]),d.marker=h}if(e.hasOwnProperty(g[this.keywordIndex])){var c=e[g[this.keywordIndex]];d.errorBar=this.parseErrorBars(c)}if(e.hasOwnProperty(w[this.keywordIndex]))for(var y=e[w[this.keywordIndex]],p=[],l=0;l<y.length;l++){var u,k=y[parseInt(l.toString(),10)];u=this.parseTrendLines(k,o),p.push(u),d.trendlines=p}return d},i.prototype.parseDataLabels=function(e){var r={visible:!0};return this.isPieType?"BestFit"===e[C[this.keywordIndex]]||"Inside"===e[C[this.keywordIndex]]?r.position="Inside":r.position="Outside":r.position=this.dataLabelPosition(e[C[this.keywordIndex]]),r},i.prototype.parseErrorBars=function(e){var r={visible:!0};return r.type=e[L[this.keywordIndex]],r.direction=e[T[this.keywordIndex]],"Cap"===e[A[this.keywordIndex]]?r.errorBarCap={width:1}:r.errorBarCap={width:0},r},i.prototype.parseTrendLines=function(e,r){var t={};return t.type=e[L[this.keywordIndex]],t.name=e[_[this.keywordIndex]],t.forwardForecast=e[B[this.keywordIndex]],t.backwardForecast=e[M[this.keywordIndex]],"NaN"===e[N[this.keywordIndex]]?t.intercept=0:t.intercept=e[N[this.keywordIndex]],t.fill=r,t},i.prototype.dataLabelPosition=function(e){var r="Auto";switch(e){case"Outside":r="Outer";break;case"Center":r="Middle";break;case"Inside":r="Top";break;case"OutsideBase":r="Bottom"}return r},i.prototype.chartFormat=function(e,r){var t=e;return"Line"===r||"StackingLine"===r||"StackingLine100"===r?t[I[this.keywordIndex]][b[this.keywordIndex]]:t[S[this.keywordIndex]][b[this.keywordIndex]]},i.prototype.chartPrimaryXAxis=function(e,r){var t={};e[u[this.keywordIndex]]&&(t.title=e[u[this.keywordIndex]]);var i=this.chartCategoryType(e[O[this.keywordIndex]]);return t.valueType=i,"DateTime"===i&&(t.intervalType="Days",t.labelFormat="M/d/yyyy",t.edgeLabelPlacement="Shift"),"Scatter_Markers"!==r&&"Bubble"!==r||this.checkAndSetAxisValue(t,e),this.parseBoolValue(e[j[this.keywordIndex]])&&(t.majorGridLines={width:1}),this.parseBoolValue(e[V[this.keywordIndex]])&&(t.minorTicksPerInterval=4),t},i.prototype.chartCategoryType=function(e){var r="";switch(e){case"Time":r="DateTime";break;case"Automatic":r="Category"}return r},i.prototype.chartPrimaryYAxis=function(e){var r={};return e[u[this.keywordIndex]]&&(r.title=e[u[this.keywordIndex]]),this.checkAndSetAxisValue(r,e),e[j[this.keywordIndex]]&&(r.majorGridLines={width:1}),e[V[this.keywordIndex]]&&(r.minorTicksPerInterval=4),r},i.prototype.checkAndSetAxisValue=function(e,r){if(0!==r[z[this.keywordIndex]]&&(e.minimum=r[z[this.keywordIndex]]),0!==r[F[this.keywordIndex]]&&(e.maximum=r[F[this.keywordIndex]]),0!==r[D[this.keywordIndex]]){var t=r[U[this.keywordIndex]];if(t&&this.parseBoolValue(t)){var i=this.calculateMajorUnit(this.chartYValues);i<10&&("Bar_Stacked_100"===this.chartType||"Line_Stacked_100"===this.chartType||"Column_Stacked_100"===this.chartType||"Line_Markers_Stacked_100"===this.chartType||"Area_Stacked_100"===this.chartType)?e.interval=10:e.interval=i}else e.interval=r[D[this.keywordIndex]]}},i.prototype.calculateMajorUnit=function(e){if(e&&e.length>0){for(var r=Number.MIN_VALUE,t=Number.MAX_VALUE,i=0;i<e.length;i++){var a=e[parseInt(i.toString(),10)];a>r&&(r=a),a<t&&(t=a)}var o=(r-t)/1.5;return this.roundToNiceNumber(o)}return 1},i.prototype.roundToNiceNumber=function(e){var r=Math.floor(Math.log(e)/Math.log(10)),t=Math.pow(10,r),i=e/t;return i<1.5?1*t:i<3?2*t:i<7?5*t:10*t},i.prototype.chartData=function(e,r){for(var t=e[h[this.keywordIndex]],i=[],a=0;a<t.length;a++){var o=t[parseInt(a.toString(),10)],n=this.chartPlotData(o,e,r,a);i.push(n)}return i},i.prototype.chartPlotData=function(e,r,i,a){var o=this,n={},s=r[c[this.keywordIndex]];if("m/d/yyyy"===r[p[this.keywordIndex]][Y[this.keywordIndex]]){var h=e[R[this.keywordIndex]].split("/"),y=Number(h[0]),l=Number(h[1]),u=Number(h[2]);n.x=new Date(u,y-1,l)}else n.x=e[R[this.keywordIndex]];for(var w=0;w<s.length;w++){var f=e[d[this.keywordIndex]][parseInt(w.toString(),10)];if(!(0,t.isNullOrUndefined)(f)){var m=f[E[this.keywordIndex]];this.chartYValues.push(m),n["y"+w]=m,"Bubble"===i&&(n["size"+w]=f[G[this.keywordIndex]])}if("Pie"===r[k[this.keywordIndex]]||"Doughnut"===r[k[this.keywordIndex]]||"Column_Stacked"===r[k[this.keywordIndex]]){var g=s[parseInt(w.toString(),10)],I=g[x[this.keywordIndex]].find(function(e){return e[v[o.keywordIndex]]===a});if((0,t.isNullOrUndefined)(I)){if(g[x[this.keywordIndex]].length>1&&0===g[x[this.keywordIndex]][parseInt(a.toString(),10)][v[this.keywordIndex]]){I=g[x[this.keywordIndex]][parseInt(a.toString(),10)];P=this.chartFormat(I,i);"Column_Stacked"!==r[k[this.keywordIndex]]?n.color=P:n["color"+w]=P}else if(!(0,t.isNullOrUndefined)(g[X[this.keywordIndex]])&&!(0,t.isNullOrUndefined)(g[X[this.keywordIndex]][S[this.keywordIndex]])&&g[X[this.keywordIndex]][S[this.keywordIndex]][b[this.keywordIndex]].length>7){P=this.getColor(g[X[this.keywordIndex]][S[this.keywordIndex]][b[this.keywordIndex]]);"Column_Stacked"!==r[k[this.keywordIndex]]?n.color=P:n["color"+w]=P}}else{var P=this.chartFormat(I,i);"Column_Stacked"!==r[k[this.keywordIndex]]?n.color=P:n["color"+w]=P}}}return n},i.prototype.getColor=function(e){return e.length>0&&"#"===e[0]&&e.length>7?e.substr(0,7):e},i.prototype.parseChartLegend=function(e){var r={},t=e[C[this.keywordIndex]];return"Corner"===t&&(t="right"),t?(r.visible=!0,r.position=t.charAt(0).toUpperCase()+t.slice(1)):r.visible=!1,r},i.prototype.parseBoolValue=function(e){return"string"==typeof e||e instanceof String?!(0,t.isNullOrUndefined)(e)&&"f"!==e&&"0"!==e&&"off"!==e&&"false"!==e:1===e||!0===e},i.prototype.destroy=function(){this.chart&&this.chart.destroy(),this.chart=void 0,this.chartYValues&&(this.chartYValues=[]),this.chartYValues=void 0},i}(),a=["width","w"],s=["height","h"],d=["chartData","chd"],h=["chartCategory","c"],c=["chartSeries","cs"],y=["chartLegend","cl"],p=["chartPrimaryCategoryAxis","cpca"],l=["chartPrimaryValueAxis","cpva"],u=["chartTitle","ctt"],k=["chartType","ct"],w=["trendLines","tl"],x=["dataPoints","dp"],f=["seriesName","sn"],m=["dataLabel","sl"],g=["errorBar","eb"],S=["fill","f"],I=["line","l"],b=["rgb","rgb"],v=["id","i"],P=["foreColor","fc"],C=["position","p"],L=["type","t"],_=["name","n"],T=["direction","dir"],A=["endStyle","est"],B=["forward","fw"],M=["backward","bw"],N=["intercept","itr"],O=["categoryType","ct"],j=["hasMajorGridLines","hmajgl"],V=["hasMinorGridLines","hmingl"],D=["majorUnit","maju"],U=["isAutoMajor","iam"],F=["maximumValue","maxv"],z=["minimumValue","minv"],R=["categoryXName","cx"],Y=["numberFormat","nf"],E=["yValue","y"],G=["size","sz"],X=["seriesFormat","sf"]})(),n})());
/*!
* filename: ej2-office-chart.umd.min.js
* version : 31.1.17
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* version : 31.2.2
* Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
* Use of this code is subject to the terms of our license.

@@ -6,0 +6,0 @@ * A copy of the current license can be obtained at any time by e-mailing

/*!
* filename: ej2-office-chart.min.js
* version : 31.1.17
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* version : 31.2.2
* Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
* Use of this code is subject to the terms of our license.

@@ -6,0 +6,0 @@ * A copy of the current license can be obtained at any time by e-mailing

/*!
* filename: index.d.ts
* version : 31.1.17
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* version : 31.2.2
* Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
* Use of this code is subject to the terms of our license.

@@ -6,0 +6,0 @@ * A copy of the current license can be obtained at any time by e-mailing

{
"_from": "@syncfusion/ej2-office-chart@*",
"_id": "@syncfusion/ej2-office-chart@20.4.0",
"_inBundle": false,
"_integrity": "sha512-6nSL046VzczzVyaHIdISja1GeqY/f3C5SAYns/zfqOMqXffQ7NxBNddm67yp9TzY/AHkwEvJMs947zMrbO3LfQ==",
"_location": "/@syncfusion/ej2-office-chart",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@syncfusion/ej2-office-chart@*",
"name": "@syncfusion/ej2-office-chart",
"escapedName": "@syncfusion%2fej2-office-chart",
"scope": "@syncfusion",
"rawSpec": "*",
"saveSpec": null,
"fetchSpec": "*"
},
"_requiredBy": [
"/",
"/@syncfusion/ej2",
"/@syncfusion/ej2-documenteditor"
],
"_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-development/@syncfusion/ej2-office-chart/-/ej2-office-chart-20.4.0.tgz",
"_shasum": "c2878638a898317ea79e4562e45a031f6b660060",
"_spec": "@syncfusion/ej2-office-chart@*",
"_where": "D:\\SF3992\\WFH\\Nexus\\release",
"author": {
"name": "Syncfusion Inc."
},
"bugs": {
"url": "https://github.com/syncfusion/ej2-office-chart/issues"
},
"bundleDependencies": false,
"name": "@syncfusion/ej2-office-chart",
"version": "31.2.2",
"description": "Essential JS 2 Component",
"author": "Syncfusion Inc.",
"license": "SEE LICENSE IN license",
"main": "./dist/ej2-office-chart.umd.min.js",
"module": "./index.js",
"es2015": "./dist/es6/ej2-office-chart.es5.js",
"dependencies": {
"@syncfusion/ej2-charts": "~31.1.17"
"@syncfusion/ej2-charts": "~31.2.2"
},
"deprecated": false,
"description": "Essential JS 2 Component",
"devDependencies": {},
"es2015": "./dist/es6/ej2-office-chart.es5.js",
"homepage": "https://www.syncfusion.com/javascript-ui-controls",
"keywords": [

@@ -48,13 +19,9 @@ "ej2",

],
"license": "SEE LICENSE IN license",
"main": "./dist/ej2-office-chart.umd.min.js",
"module": "./index.js",
"name": "@syncfusion/ej2-office-chart",
"repository": {
"type": "git",
"url": "git+https://github.com/syncfusion/ej2-office-chart.git"
"url": "https://github.com/syncfusion/ej2-office-chart.git"
},
"typings": "index.d.ts",
"version": "31.1.17",
"sideEffects": false
"sideEffects": false,
"homepage": "https://www.syncfusion.com/javascript-ui-controls"
}
/**
* export word-chart modules
*/
export * from './office-chart/index';
/**
* export word-chart modules
*/
export * from './office-chart/index';
import { Chart, AccumulationChart } from '@syncfusion/ej2-charts';
/**
* Chart component is used to convert office charts to ej2-charts.
*/
export declare class ChartComponent {
/**
* @private
*/
chart: Chart | AccumulationChart;
/**
* @private
*/
private chartType;
/**
* @private
*/
private isPieType;
/**
* @private
*/
private keywordIndex;
/**
* @private
*/
private chartYValues;
/**
* @private
*/
chartRender(chart: any, keywordIndex?: number): void;
/**
* @private
*/
convertChartToImage(chart: Chart | AccumulationChart, elementWidth: number, elementHeight: number): Promise<string>;
private getControlsValue;
private officeChartType;
private chartSeries;
private writeChartSeries;
private parseDataLabels;
private parseErrorBars;
private parseTrendLines;
private dataLabelPosition;
private chartFormat;
private chartPrimaryXAxis;
private chartCategoryType;
private chartPrimaryYAxis;
private checkAndSetAxisValue;
private calculateMajorUnit;
private roundToNiceNumber;
private chartData;
private chartPlotData;
getColor(color: string): string;
private parseChartLegend;
private parseBoolValue;
/**
* Destroys the internal objects which is maintained.
*/
destroy(): void;
}
/* eslint-disable */
/* tslint:disable:no-any */
import {
Chart, AccumulationChart, AccumulationLegend, PieSeries, AccumulationTooltip, AccumulationDataLabel, DateTime, BarSeries,
StackingBarSeries, LineSeries, StackingLineSeries, ColumnSeries, StackingColumnSeries, AreaSeries, StackingAreaSeries,
Trendlines, ScatterSeries, BubbleSeries, RadarSeries, PolarSeries, ErrorBar, SplineSeries,
DataLabel, Category, Legend, Tooltip, Export, ChartModel, AccumulationChartModel
} from '@syncfusion/ej2-charts';
Chart.Inject(
AreaSeries, StackingAreaSeries, BarSeries, PieSeries, StackingBarSeries, PolarSeries, ScatterSeries, BubbleSeries,
RadarSeries, DateTime, ColumnSeries, StackingColumnSeries, LineSeries, StackingLineSeries, ErrorBar, Trendlines,
SplineSeries, DataLabel, Category, Legend, Tooltip, Export);
AccumulationChart.Inject(AccumulationLegend, PieSeries, AccumulationTooltip, AccumulationDataLabel);
import { SvgRenderer } from '@syncfusion/ej2-svg-base';
import { createElement, isNullOrUndefined } from '@syncfusion/ej2-base';
import { chartTypeProperty, widthProperty, heightProperty, chartDataProperty, chartCategoryProperty, chartLegendProperty, chartPrimaryCategoryAxisProperty, chartSeriesProperty, chartTitleProperty, chartPrimaryValueAxisProperty, dataPointsProperty, seriesNameProperty, errorBarProperty, dataLabelProperty, trendLinesProperty, fillProperty, foreColorProperty, positionProperty, typeProperty, directionProperty, endStyleProperty, nameProperty, forwardProperty, backwardProperty, interceptProperty, lineProperty, rgbProperty, categoryTypeProperty, hasMajorGridLinesProperty, hasMinorGridLinesProperty, minimumValueProperty, maximumValueProperty, majorUnitProperty, categoryXNameProperty, numberFormatProperty, yValueProperty, sizeProperty, seriesFormatProperty, idProperty, isAutoMajorProperty } from '../index';
/**
* Chart component is used to convert office charts to ej2-charts.
*/
export class ChartComponent {
/**
* @private
*/
public chart: Chart | AccumulationChart;
/**
* @private
*/
private chartType: string;
/**
* @private
*/
private isPieType: boolean;
/**
* @private
*/
private keywordIndex: number = undefined;
/**
* @private
*/
private chartYValues: number[] = [];
/**
* @private
*/
public chartRender(chart: any, keywordIndex?: number): void {
this.keywordIndex = !isNullOrUndefined(keywordIndex) ? keywordIndex : 0;
this.chartType = chart[chartTypeProperty[this.keywordIndex]];
this.isPieType = (this.chartType === 'Pie' || this.chartType === 'Doughnut');
let chartData: object[] = this.chartData(chart, this.chartType);
let chartModel: AccumulationChartModel | ChartModel = {
enableAnimation: false,
width: chart[widthProperty[this.keywordIndex]] * (96 / 72) + 'px',
height: chart[heightProperty[this.keywordIndex]] * (96 / 72) + 'px'
};
if (this.isPieType) {
this.chart = new AccumulationChart(chartModel as AccumulationChartModel);
} else {
this.chart = new Chart(chartModel as ChartModel);
this.chart.primaryXAxis = this.chartPrimaryXAxis(chart[chartPrimaryCategoryAxisProperty[this.keywordIndex]], this.chartType);
this.chart.primaryYAxis = this.chartPrimaryYAxis(chart[chartPrimaryValueAxisProperty[this.keywordIndex]]);
}
this.chart.series = this.chartSeries(chart[chartSeriesProperty[this.keywordIndex]], chartData, this.chartType);
for (let i: number = 0; i < this.chart.series.length; i++) {
this.chart.series[parseInt(i.toString(), 10)].animation.enable = false;
}
this.chart.title = chart[chartTitleProperty[this.keywordIndex]];
this.chart.legendSettings = this.parseChartLegend(chart[chartLegendProperty[this.keywordIndex]]);
}
/**
* @private
*/
public convertChartToImage(chart: Chart | AccumulationChart, elementWidth: number, elementHeight: number): Promise<string> {
let promise: Promise<string>;
return promise = new Promise((resolve: Function, reject: Function) => {
let width: number = 0;
let height: number = 0;
const dataInfo: ChartImageInfo = this.getControlsValue([chart], elementWidth, elementHeight);
width = width ? width : dataInfo.width;
height = height ? height : dataInfo.height;
const element: HTMLCanvasElement = <HTMLCanvasElement>createElement('canvas');
const displayPixelRatio: number = Math.max(1, window.devicePixelRatio || 1);
element.width = width * (displayPixelRatio);
element.height = height * (displayPixelRatio);
element.style.width = width + 'px';
element.style.height = height + 'px';
// tslint:disable-next-line:max-line-length
const url: string = window.URL.createObjectURL(new Blob([(new XMLSerializer()).serializeToString(dataInfo.svg)], { type: 'image/svg+xml' }));
const image: HTMLImageElement = new Image();
const canvasContext: CanvasRenderingContext2D = element.getContext('2d');
canvasContext.scale(displayPixelRatio, displayPixelRatio);
image.onload = (() => {
canvasContext.drawImage(image, 0, 0);
window.URL.revokeObjectURL(url);
const dataURL: string = element.toDataURL('image/png');
resolve(dataURL);
});
image.onerror = (() => {
reject('Invalid data');
});
image.src = url;
});
}
private getControlsValue(controls: (Chart | AccumulationChart)[], elementWidth: number, elementHeight: number): ChartImageInfo {
let width: number = 0;
let height: number = 0;
let content: string = '';
const svgRenderer: Element = new SvgRenderer('').createSvg({
id: 'Image_Export',
width: 200, height: 200
});
controls.map((control: Chart | AccumulationChart) => {
if (control) {
const svgElement: Node = control.svgObject.cloneNode(true);
const groupElement: Element = control.renderer.createGroup({
style: 'transform: translateY(' + height + 'px)'
});
groupElement.appendChild(svgElement);
width = Math.max(control.availableSize.width, elementWidth);
height += control.availableSize.height;
content += control.svgObject.outerHTML;
svgRenderer.appendChild(groupElement);
}
});
svgRenderer.setAttribute('width', width + '');
svgRenderer.setAttribute('height', height + '');
return {
'width': width,
'height': height,
'svg': svgRenderer
};
}
private officeChartType(type: string): any {
let chartType: string = '';
switch (type) {
case 'Area_Stacked':
chartType = 'StackingArea';
break;
case 'Area':
chartType = 'Area';
break;
case 'Area_Stacked_100':
chartType = 'StackingArea100';
break;
case 'Bar_Clustered':
chartType = 'Bar';
break;
case 'Bar_Stacked':
chartType = 'StackingBar';
break;
case 'Bar_Stacked_100':
chartType = 'StackingBar100';
break;
case 'Column_Clustered':
chartType = 'Column';
break;
case 'Column_Stacked':
chartType = 'StackingColumn';
break;
case 'Column_Stacked_100':
chartType = 'StackingColumn100';
break;
case 'Scatter_Markers':
chartType = 'Scatter';
break;
case 'Bubble':
chartType = 'Bubble';
break;
case 'Doughnut':
case 'Pie':
chartType = 'Pie';
break;
case 'Line_Stacked_100':
case 'Line_Markers_Stacked_100':
chartType = 'StackingLine100';
break;
case 'Line':
case 'Line_Markers':
chartType = 'Line';
break;
case 'Line_Stacked':
case 'Line_Markers_Stacked':
chartType = 'StackingLine';
break;
}
return chartType;
}
private chartSeries(series: any[], data: any[], type: string): object[] {
// json data
const chartSeries: object[] = [];
for (let i: number = 0; i < series.length; i++) {
const seriesData: any = series[parseInt(i.toString(), 10)];
const seriesValue: any = this.writeChartSeries(seriesData, data, type, i);
chartSeries.push(seriesValue);
}
return chartSeries;
}
private writeChartSeries(seriesData: any, data: any[], type: string, count: number): any {
const chartType: string = this.officeChartType(type);
// let isAreaType: boolean = (type === 'Area_Stacked_100' || type === 'Area' || type === 'Area_Stacked');
let seriesFormat: any = seriesData[dataPointsProperty[this.keywordIndex]][parseInt(count.toString(), 10)];
const series: any = {};
let fill: string;
series.type = chartType;
series.dataSource = data;
series.name = seriesData[seriesNameProperty[this.keywordIndex]];
series.xName = 'x';
series.yName = 'y' + count;
if (type === 'Bubble') {
series.size = 'size' + count;
}
if (this.isPieType) {
series.pointColorMapping = 'color';
if (type === 'Doughnut') {
series.innerRadius = '75%';
series.radius = '70%';
}
} else {
if (isNullOrUndefined(seriesFormat)) {
seriesFormat = seriesData[dataPointsProperty[this.keywordIndex]][0];
}
fill = this.chartFormat(seriesFormat, chartType);
series.fill = fill;
if (!isNullOrUndefined(seriesFormat[fillProperty[this.keywordIndex]][foreColorProperty[this.keywordIndex]])) {
series.pointColorMapping = 'color';
}
}
if (type === 'Line_Markers' || type === 'Line_Markers_Stacked' || type === 'Line_Markers_Stacked_100') {
series.marker = { visible: true };
}
if (seriesData.hasOwnProperty(dataLabelProperty[this.keywordIndex])) {
if (this.isPieType) {
series.dataLabel = this.parseDataLabels(seriesData[dataLabelProperty[this.keywordIndex]]);
} else {
const data: any = {};
data.dataLabel = this.parseDataLabels(seriesData[dataLabelProperty[this.keywordIndex]]);
series.marker = data;
}
}
if (seriesData.hasOwnProperty(errorBarProperty[this.keywordIndex])) {
const errorBarData: any = seriesData[errorBarProperty[this.keywordIndex]];
series.errorBar = this.parseErrorBars(errorBarData);
}
if (seriesData.hasOwnProperty(trendLinesProperty[this.keywordIndex])) {
const trendLines: any = seriesData[trendLinesProperty[this.keywordIndex]];
let trendLinesData: any[] = [];
for (let count: number = 0; count < trendLines.length; count++) {
let trendLine: any = trendLines[parseInt(count.toString(), 10)];
let data: any = {};
data = this.parseTrendLines(trendLine, fill);
trendLinesData.push(data);
series.trendlines = trendLinesData;
}
}
return series;
}
private parseDataLabels(label: any): any {
let dataLabel: any = {};
dataLabel.visible = true;
if (this.isPieType) {
if (label[positionProperty[this.keywordIndex]] === 'BestFit' || label[positionProperty[this.keywordIndex]] === 'Inside') {
dataLabel.position = 'Inside';
} else {
dataLabel.position = 'Outside';
}
} else {
dataLabel.position = this.dataLabelPosition(label[positionProperty[this.keywordIndex]]);
}
return dataLabel;
}
private parseErrorBars(errorBarData: any): any {
let errorBar: any = {};
errorBar.visible = true;
errorBar.type = errorBarData[typeProperty[this.keywordIndex]];
errorBar.direction = errorBarData[directionProperty[this.keywordIndex]];
if (errorBarData[endStyleProperty[this.keywordIndex]] === 'Cap') {
errorBar.errorBarCap = { width: 1 };
} else {
errorBar.errorBarCap = { width: 0 };
}
return errorBar;
}
private parseTrendLines(trendLines: any, fill: string): any {
let trendLine: any = {};
trendLine.type = trendLines[typeProperty[this.keywordIndex]];
trendLine.name = trendLines[nameProperty[this.keywordIndex]];
trendLine.forwardForecast = trendLines[forwardProperty[this.keywordIndex]];
trendLine.backwardForecast = trendLines[backwardProperty[this.keywordIndex]];
if (trendLines[interceptProperty[this.keywordIndex]] === 'NaN') {
trendLine.intercept = 0;
} else {
trendLine.intercept = trendLines[interceptProperty[this.keywordIndex]];
}
trendLine.fill = fill;
return trendLine;
}
private dataLabelPosition(position: string): string {
let labelPosition: string = 'Auto';
switch (position) {
case 'Outside':
labelPosition = 'Outer';
break;
case 'Center':
labelPosition = 'Middle';
break;
case 'Inside':
labelPosition = 'Top';
break;
case 'OutsideBase':
labelPosition = 'Bottom';
break;
}
return labelPosition;
}
private chartFormat(dataPoints: any, type: string): any {
let format: any = dataPoints;
if (type === 'Line' || type === 'StackingLine' || type === 'StackingLine100') {
return format[lineProperty[this.keywordIndex]][rgbProperty[this.keywordIndex]];
} else {
return format[fillProperty[this.keywordIndex]][rgbProperty[this.keywordIndex]];
}
}
private chartPrimaryXAxis(data: any, type: string): object {
// json data
let primaryXAxis: any = {};
if (data[chartTitleProperty[this.keywordIndex]]) {
primaryXAxis.title = data[chartTitleProperty[this.keywordIndex]];
}
let categoryType: string = this.chartCategoryType(data[categoryTypeProperty[this.keywordIndex]]);
primaryXAxis.valueType = categoryType;
if (categoryType === 'DateTime') {
primaryXAxis.intervalType = 'Days';
primaryXAxis.labelFormat = 'M/d/yyyy';
primaryXAxis.edgeLabelPlacement = 'Shift';
}
if (type === 'Scatter_Markers' || type === 'Bubble') {
this.checkAndSetAxisValue(primaryXAxis, data);
}
if (this.parseBoolValue(data[hasMajorGridLinesProperty[this.keywordIndex]])) {
primaryXAxis.majorGridLines = { width: 1 };
}
if (this.parseBoolValue(data[hasMinorGridLinesProperty[this.keywordIndex]])) {
primaryXAxis.minorTicksPerInterval = 4;
}
return primaryXAxis;
}
private chartCategoryType(categoryType: string): any {
let type: string = '';
switch (categoryType) {
case 'Time':
type = 'DateTime';
break;
case 'Automatic':
type = 'Category';
break;
}
return type;
}
private chartPrimaryYAxis(data: any): any {
// json data
let primaryYAxis: any = {};
if (data[chartTitleProperty[this.keywordIndex]]) {
primaryYAxis.title = data[chartTitleProperty[this.keywordIndex]];
}
this.checkAndSetAxisValue(primaryYAxis, data);
if (data[hasMajorGridLinesProperty[this.keywordIndex]]) {
primaryYAxis.majorGridLines = { width: 1 };
}
if (data[hasMinorGridLinesProperty[this.keywordIndex]]) {
primaryYAxis.minorTicksPerInterval = 4;
}
return primaryYAxis;
}
private checkAndSetAxisValue(primaryYAxis: any, data: any): any {
if (data[minimumValueProperty[this.keywordIndex]] !== 0) {
primaryYAxis.minimum = data[minimumValueProperty[this.keywordIndex]];
}
if (data[maximumValueProperty[this.keywordIndex]] !== 0) {
primaryYAxis.maximum = data[maximumValueProperty[this.keywordIndex]];
}
if (data[majorUnitProperty[this.keywordIndex]] !== 0) {
const isAutoMajor: any = data[isAutoMajorProperty[this.keywordIndex]];
if (isAutoMajor && this.parseBoolValue(isAutoMajor)) {
const majorUnit: number = this.calculateMajorUnit(this.chartYValues);
if (majorUnit < 10 && (this.chartType === "Bar_Stacked_100" || this.chartType === "Line_Stacked_100" || this.chartType === "Column_Stacked_100" || this.chartType === "Line_Markers_Stacked_100" || this.chartType === "Area_Stacked_100")) {
primaryYAxis.interval = 10;
}
else {
primaryYAxis.interval = majorUnit;
}
} else {
primaryYAxis.interval = data[majorUnitProperty[this.keywordIndex]];
}
}
}
private calculateMajorUnit(chartYValues: number[]): number {
if (chartYValues && chartYValues.length > 0) {
let maxValue: number = Number.MIN_VALUE;
let minValue: number = Number.MAX_VALUE;
for (let i: number = 0; i < chartYValues.length; i++) {
const yValue: number = chartYValues[parseInt(i.toString(), 10)];
if (yValue > maxValue) {
maxValue = yValue;
}
if (yValue < minValue) {
minValue = yValue;
}
}
const range: number = maxValue - minValue;
const intervalSize: number = range / 1.5;
return this.roundToNiceNumber(intervalSize);
}
return 1;
}
private roundToNiceNumber(range: number): number {
const log10: number = Math.floor(Math.log(range) / Math.log(10));
const pow10: number = Math.pow(10, log10);
const frac: number = range / pow10;
if (frac < 1.5) {
return 1 * pow10;
} else if (frac < 3) {
return 2 * pow10;
} else if (frac < 7) {
return 5 * pow10;
} else {
return 10 * pow10;
}
}
private chartData(chart: any, type: string): any[] {
// json data
const data: any[] = chart[chartCategoryProperty[this.keywordIndex]];
const chartData: object[] = [];
for (let i: number = 0; i < data.length; i++) {
const xData: any = data[parseInt(i.toString(), 10)];
const plotValue: any = this.chartPlotData(xData, chart, type, i);
chartData.push(plotValue);
}
return chartData;
}
private chartPlotData(data: any, chart: any, type: string, count: number): any {
let plotValue: any = {};
let series: any = chart[chartSeriesProperty[this.keywordIndex]];
if (chart[chartPrimaryCategoryAxisProperty[this.keywordIndex]][numberFormatProperty[this.keywordIndex]] === 'm/d/yyyy') {
const date: string = data[categoryXNameProperty[this.keywordIndex]];
const array: string[] = date.split('/');
const month: number = Number(array[0]);
const day: number = Number(array[1]);
const year: number = Number(array[2]);
plotValue.x = new Date(year, month - 1, day);
} else {
plotValue.x = data[categoryXNameProperty[this.keywordIndex]];
}
for (let j: number = 0; j < series.length; j++) {
const yData: any = data[chartDataProperty[this.keywordIndex]][parseInt(j.toString(), 10)];
if (!isNullOrUndefined(yData)) {
const yValue: any = yData[yValueProperty[this.keywordIndex]];
this.chartYValues.push(yValue);
plotValue['y' + j] = yValue;
if (type === 'Bubble') {
plotValue['size' + j] = yData[sizeProperty[this.keywordIndex]];
}
}
if (chart[chartTypeProperty[this.keywordIndex]] === 'Pie' || chart[chartTypeProperty[this.keywordIndex]] === 'Doughnut' || chart[chartTypeProperty[this.keywordIndex]] === 'Column_Stacked') {
let seriesData: any = series[parseInt(j.toString(), 10)];
let seriesDataPoints: any = seriesData[dataPointsProperty[this.keywordIndex]].find((obj: any) => {
return obj[idProperty[this.keywordIndex]] === count
});
if (!isNullOrUndefined(seriesDataPoints)) {
const color: any = this.chartFormat(seriesDataPoints, type);
if (chart[chartTypeProperty[this.keywordIndex]] !== 'Column_Stacked') {
plotValue.color = color;
}
else {
plotValue['color' + j] = color;
}
}
else {
if (seriesData[dataPointsProperty[this.keywordIndex]].length > 1 && seriesData[dataPointsProperty[this.keywordIndex]][parseInt(count.toString(), 10)][idProperty[this.keywordIndex]] === 0) {
seriesDataPoints = seriesData[dataPointsProperty[this.keywordIndex]][parseInt(count.toString(), 10)];
const color: any = this.chartFormat(seriesDataPoints, type);
if (chart[chartTypeProperty[this.keywordIndex]] !== 'Column_Stacked') {
plotValue.color = color;
} else {
plotValue['color' + j] = color;
}
}
else {
if (!isNullOrUndefined(seriesData[seriesFormatProperty[this.keywordIndex]]) && !isNullOrUndefined(seriesData[seriesFormatProperty[this.keywordIndex]][fillProperty[this.keywordIndex]])) {
if (seriesData[seriesFormatProperty[this.keywordIndex]][fillProperty[this.keywordIndex]][rgbProperty[this.keywordIndex]].length > 7) {
const color: any = this.getColor(seriesData[seriesFormatProperty[this.keywordIndex]][fillProperty[this.keywordIndex]][rgbProperty[this.keywordIndex]]);
if (chart[chartTypeProperty[this.keywordIndex]] !== 'Column_Stacked') {
plotValue.color = color;
} else {
plotValue['color' + j] = color;
}
}
}
}
}
}
}
return plotValue;
}
public getColor(color: string): string {
if (color.length > 0) {
if (color[0] === '#') {
if (color.length > 7) {
return color.substr(0, 7);
}
}
}
return color;
}
private parseChartLegend(data: any): any {
const legendSettings: any = {};
let position: string = data[positionProperty[this.keywordIndex]];
if (position === 'Corner') {
position = 'right';
}
if (position) {
legendSettings.visible = true;
legendSettings.position = position.charAt(0).toUpperCase() + position.slice(1);
} else {
legendSettings.visible = false;
}
return legendSettings;
}
private parseBoolValue(value: any): boolean {
if (typeof value === 'string' || value instanceof String) {
if (isNullOrUndefined(value) || value === 'f' || value === '0' || value === 'off' || value === 'false') {
return false;
} else {
return true;
}
} else {
if (value === 1 || value === true) {
return true;
} else {
return false;
}
}
}
/**
* Destroys the internal objects which is maintained.
*/
public destroy(): void {
if (this.chart) {
this.chart.destroy();
}
this.chart = undefined;
if (this.chartYValues) {
this.chartYValues = [];
}
this.chartYValues = undefined;
}
}
/**
* @private
*/
interface ChartImageInfo {
width: number;
height: number;
svg: Element;
}
/**
* export word-chart modules
*/
export * from './chart';
export * from './keywords';
/**
* export word-chart modules
*/
export * from './chart';
export * from './keywords';
export declare const widthProperty: string[];
export declare const heightProperty: string[];
export declare const chartDataProperty: string[];
export declare const chartCategoryProperty: string[];
export declare const chartSeriesProperty: string[];
export declare const chartLegendProperty: string[];
export declare const chartPrimaryCategoryAxisProperty: string[];
export declare const chartPrimaryValueAxisProperty: string[];
export declare const chartTitleProperty: string[];
export declare const chartTypeProperty: string[];
export declare const trendLinesProperty: string[];
export declare const dataPointsProperty: string[];
export declare const seriesNameProperty: string[];
export declare const dataLabelProperty: string[];
export declare const errorBarProperty: string[];
export declare const fillProperty: string[];
export declare const lineProperty: string[];
export declare const rgbProperty: string[];
export declare const idProperty: string[];
export declare const foreColorProperty: string[];
export declare const positionProperty: string[];
export declare const typeProperty: string[];
export declare const nameProperty: string[];
export declare const directionProperty: string[];
export declare const endStyleProperty: string[];
export declare const forwardProperty: string[];
export declare const backwardProperty: string[];
export declare const interceptProperty: string[];
export declare const categoryTypeProperty: string[];
export declare const hasMajorGridLinesProperty: string[];
export declare const hasMinorGridLinesProperty: string[];
export declare const majorUnitProperty: string[];
export declare const isAutoMajorProperty: string[];
export declare const maximumValueProperty: string[];
export declare const minimumValueProperty: string[];
export declare const categoryXNameProperty: string[];
export declare const numberFormatProperty: string[];
export declare const yValueProperty: string[];
export declare const sizeProperty: string[];
export declare const seriesFormatProperty: string[];
export const widthProperty: string[] = ['width', 'w'];
export const heightProperty: string[] = ['height', 'h'];
export const chartDataProperty: string[] = ['chartData', 'chd'];
export const chartCategoryProperty: string[] = ['chartCategory', 'c'];
export const chartSeriesProperty: string[] = ['chartSeries', 'cs'];
export const chartLegendProperty: string[] = ['chartLegend', 'cl'];
export const chartPrimaryCategoryAxisProperty: string[] = ['chartPrimaryCategoryAxis', 'cpca'];
export const chartPrimaryValueAxisProperty: string[] = ['chartPrimaryValueAxis', 'cpva'];
export const chartTitleProperty: string[] = ['chartTitle', 'ctt'];
export const chartTypeProperty: string[] = ['chartType', 'ct'];
export const trendLinesProperty: string[] = ['trendLines', 'tl'];
export const dataPointsProperty: string[] = ['dataPoints', 'dp'];
export const seriesNameProperty: string[] = ['seriesName', 'sn'];
export const dataLabelProperty: string[] = ['dataLabel', 'sl'];
export const errorBarProperty: string[] = ['errorBar', 'eb'];
export const fillProperty: string[] = ['fill', 'f'];
export const lineProperty: string[] = ['line', 'l'];
export const rgbProperty: string[] = ['rgb', 'rgb'];
export const idProperty: string[] = ['id', 'i'];
export const foreColorProperty: string[] = ['foreColor', 'fc'];
export const positionProperty: string[] = ['position', 'p'];
export const typeProperty: string[] = ['type', 't'];
export const nameProperty: string[] = ['name', 'n'];
export const directionProperty: string[] = ['direction', 'dir'];
export const endStyleProperty: string[] = ['endStyle', 'est'];
export const forwardProperty: string[] = ['forward', 'fw'];
export const backwardProperty: string[] = ['backward', 'bw'];
export const interceptProperty: string[] = ['intercept', 'itr'];
export const categoryTypeProperty: string[] = ['categoryType', 'ct'];
export const hasMajorGridLinesProperty: string[] = ['hasMajorGridLines', 'hmajgl'];
export const hasMinorGridLinesProperty: string[] = ['hasMinorGridLines', 'hmingl'];
export const majorUnitProperty: string[] = ['majorUnit', 'maju'];
export const isAutoMajorProperty: string[] = ['isAutoMajor', 'iam'];
export const maximumValueProperty: string[] = ['maximumValue', 'maxv'];
export const minimumValueProperty: string[] = ['minimumValue', 'minv'];
export const categoryXNameProperty: string[] = ['categoryXName', 'cx'];
export const numberFormatProperty: string[] = ['numberFormat', 'nf'];
export const yValueProperty: string[] = ['yValue', 'y'];
export const sizeProperty: string[] = ['size', 'sz'];
export const seriesFormatProperty: string[] = ['seriesFormat', 'sf'];