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AOiD,oCAAsCjD,OAAOiD,oCAAsC,GACvIA,oCAAoCD,KAAKlC,GAElCA,CACX,CACJ,EAqEAd,OAAOkD,mBAAmB9E,KAAK+E,IACf,IAAIjD,gBAAgBiD,EAAYhD,mBAAoBgD,EAAYnB,aAAcmB,EAAY9C,UAChGE,SACN4C,EAAYC,UAAW,CAAI,IAI/BC,SAASC,iBAAiB,2BAA4BC,KAAS,KAC3DvD,OAAOkD,mBAAmB9E,KAAK+E,IACvBA,EAAYC,UACJ,IAAIlD,gBAAgBiD,EAAYhD,mBAAoBgD,EAAYnB,aAAcmB,EAAY9C,UAChGE,QAAQ,GAChB,GACH,K","sources":["webpack://vaneckweb/../Static/us/js/src/highcharts-block.js"],"sourcesContent":["import Highcharts from \"../../../../Webpack/node_modules/highcharts\";\r\nimport DataModule from '../../../../Webpack/node_modules/highcharts/modules/data.js';\r\nimport debounce from 'lodash/debounce';\r\nrequire(\"regenerator-runtime/runtime\"); //for async\r\n\r\n//window.Highcharts = Highcharts;\r\n\r\nDataModule(Highcharts);\r\n\r\n//window.Highcharts = Highcharts;\r\n\r\nwindow.highchartsList = [];\r\n\r\nwindow.HighchartsBlock = function (renderingContainer, blockData, override) {\r\n this.render = async function () {\r\n\r\n if (typeof blockData.vaneck != \"undefined\" && blockData.vaneck.categories.length > 0) {\r\n //If there are categories defined, then we need to consider this a 2D data set, with arrays and categories\r\n \r\n //see if the checklist to flip series and categories is enabled, we can now flip it in source.\r\n if (blockData.vaneck.FlipSeriesAndCategories) {\r\n var series = blockData.series;\r\n blockData.series = blockData.vaneck.categories;\r\n blockData.vaneck.categories = series;\r\n }\r\n\r\n //because we have Long X axis labels, we make space on the sides and makesure they are verticle on mobile.\r\n if (blockData.vaneck.LongXaxisLabels) {\r\n blockData.chart = {\r\n ...blockData.chart,\r\n spacingLeft: 110,\r\n spacingRight: 40,\r\n spacingBottom: 40,\r\n height: 550\r\n\r\n }\r\n blockData.xAxis = {\r\n ...blockData.xAxis,\r\n labels: {\r\n ...blockData.xAxis.labels,\r\n style: {\r\n fontFamily: \"Open Sans, Arial\",\r\n color: \"#666666\",\r\n fontSize: \"14px\",\r\n fontWeight: \"bold\",\r\n fontStyle: \"normal\",\r\n textOverflow: \"none\"\r\n },\r\n rotation: -60\r\n }\r\n }\r\n blockData.responsive.rules = [\r\n ...blockData.responsive.rules,\r\n {\r\n condition: {\r\n maxWidth: 768\r\n },\r\n chartOptions: {\r\n xAxis: {\r\n labels: {\r\n rotation: -90\r\n }\r\n },\r\n chart: {\r\n spacingLeft: undefined,\r\n spacingRight: undefined,\r\n height: 600,\r\n spacingBottom: 40\r\n }\r\n }\r\n }\r\n ]\r\n }\r\n \r\n // and now manually fetch the data to transform.\r\n blockData = await transformSeriesAsCategories(blockData);\r\n }\r\n\r\n override = override ?? {}\r\n;\r\n //use mergedeep to recursivly merge items...\r\n const chartOptions = mergeDeep(blockData, override);\r\n\r\n // debugger;\r\n console.log(chartOptions);\r\n Highcharts.setOptions({lang: blockData.vaneck.lang});\r\n var chart = Highcharts.chart(renderingContainer, chartOptions)\r\n highchartsList.push(chart);\r\n\r\n /**\r\n * In the EU landing pages, when switching tabs, there is a requirement to reflow the charts. All charts in this array will be reflown.\r\n * Chart needs to be added to this array so it will be included in the reflow.\r\n * */\r\n window.PerformanceChartUcitsBlockChartList = window.PerformanceChartUcitsBlockChartList ? window.PerformanceChartUcitsBlockChartList : [];\r\n PerformanceChartUcitsBlockChartList.push(chart);\r\n\r\n return chart\r\n }\r\n}\r\n\r\n\r\nasync function transformSeriesAsCategories(blockData) {\r\n try {\r\n const res = await $.get(blockData.vaneck.link);\r\n\r\n const override = {\r\n colors: blockData.chart.type == \"pie\" ? getColorFromSeries(blockData.vaneck.categories) : getColorFromSeries(blockData.series),\r\n series: blockData.series.map((series, i) => {\r\n //i = which series\r\n var Newseries = {data: getSeriesDataForAllCategories(res, blockData.vaneck.categories, i, series.name)}\r\n return {...series, ...Newseries};\r\n }),\r\n data: undefined\r\n }\r\n\r\n return {\r\n ...blockData,\r\n ...override\r\n }\r\n\r\n }\r\n catch (err) {\r\n console.error(\"Failed transformSeriesAsCategories: \", err);\r\n return blockData;\r\n }\r\n}\r\n\r\nfunction getSeriesDataForAllCategories(stringValues, categoryObject, i, seriesName) {\r\n //Series here means category now....\r\n //i meand the series id, which series\r\n if (typeof stringValues != \"string\" || stringValues == \"\") return null;\r\n const valuesbyCategory = stringValues.split(\"\\n\"); //split by rows == every category\r\n return categoryObject.map((cat, index) => {\r\n if(typeof valuesbyCategory[index]=== \"undefined\") return false;\r\n var currentCat = valuesbyCategory[index].split(\",\");\r\n return {\r\n name: cat.name,\r\n y: parseFloat(currentCat[i]) ?? null\r\n }\r\n });\r\n}\r\n\r\nfunction getColorFromSeries(seriesObject, chartType) {\r\n return seriesObject.map(series => series.color);\r\n}\r\n\r\nfunction isObject(item) {\r\n return (item && typeof item === 'object' && !Array.isArray(item));\r\n}\r\n\r\nfunction mergeDeep(target, source) {\r\n let output = Object.assign({}, target);\r\n if (isObject(target) && isObject(source)) {\r\n Object.keys(source).forEach(key => {\r\n if (isObject(source[key])) {\r\n if (!(key in target))\r\n Object.assign(output, { [key]: source[key] });\r\n else\r\n output[key] = mergeDeep(target[key], source[key]);\r\n } else {\r\n Object.assign(output, { [key]: source[key] });\r\n }\r\n });\r\n }\r\n return output;\r\n}\r\n\r\nwindow.HighchartDataList?.map((chartObject) => {\r\n var chart = new HighchartsBlock(chartObject.renderingContainer, chartObject.chartOptions, chartObject.override)\r\n chart.render();\r\n chartObject.rendered = true;\r\n})\r\n\r\n// To render charts in pop ups that are loaded through React\r\ndocument.addEventListener(\"chartOptionsScriptLoaded\", debounce(() => {\r\n window.HighchartDataList?.map((chartObject) => {\r\n if (chartObject.rendered) return;\r\n var chart = new HighchartsBlock(chartObject.renderingContainer, chartObject.chartOptions, chartObject.override)\r\n chart.render();\r\n })\r\n}, 300))"],"names":["getSeriesDataForAllCategories","stringValues","categoryObject","i","seriesName","valuesbyCategory","split","map","cat","index","currentCat","name","y","parseFloat","getColorFromSeries","seriesObject","chartType","series","color","isObject","item","Array","isArray","mergeDeep","target","source","output","Object","assign","keys","forEach","key","require","DataModule","Highcharts","window","highchartsList","HighchartsBlock","renderingContainer","blockData","override","this","render","async","vaneck","categories","length","FlipSeriesAndCategories","LongXaxisLabels","chart","spacingLeft","spacingRight","spacingBottom","height","xAxis","labels","style","fontFamily","fontSize","fontWeight","fontStyle","textOverflow","rotation","responsive","rules","condition","maxWidth","chartOptions","undefined","res","$","get","link","colors","type","Newseries","data","err","console","error","transformSeriesAsCategories","log","lang","push","PerformanceChartUcitsBlockChartList","HighchartDataList","chartObject","rendered","document","addEventListener","debounce"],"sourceRoot":""}