<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">angular.module('ngPriceApp', ['ngSanitize'])
	.controller("PriceDataCtrl", ['$compile', '$scope', '$http', '$q', '$timeout', '$filter', function ($compile, $scope, $http, $q, $timeout, $filter) {
    $scope.DownloadedFile = '';

    $scope.priceVars={
      SelectedCompany: "ALL",
        SelectedMarket : "1"
    }
    $scope.auth = undefined;
    $scope.$watchCollection('priceVars', (n, o)=&gt;{
      $scope.DownloadedFile = undefined;
    });



		function LoadData() {
      blockUI('priceDataDiv');
			$http({
				method: 'GET',
				url: siteRoot + 'Download/LoadPriceData',
        params: { ticker: $scope.priceVars.SelectedCompany, period: $scope.priceVars.SelectPeriods, sID: $scope.priceVars.SelectedMarket },
			}).then(function (res) {
				$scope.DownloadedFile = res.data;
        }, (error) =&gt; { unblockUI('priceDataDiv'); console.log(error.data); })
				.then(function () {
          unblockUI('priceDataDiv');
				});
		}

		function GetSymbolFile(PSM) {
      blockUI('priceDataDiv');
			$http({
				method: 'GET',
        url: siteRoot + 'Common/GetSymbolFile',
        params: { SM: $scope.priceVars.SelectedMarket },
			}).then(function (res) {
				$scope.SymbolFile = res.data.file;
        $scope.Companies = [];
        debugger;
        $scope.Companies.push({ 'Name': res.data.companies[0].StockMarket, 'Ticker': res.data.companies[0].StockMarket, 'Type': "sector" });
				var sectors = $filter('unique')(res.data.companies.map(function (v) { return v.SectorID; }));
				angular.forEach(sectors, function (value, key) {
					var arr =  $filter('filter')(res.data.companies, { SectorID: value },true);
          //var arr = $.grep(res.data.companies, (el) =&gt; { if (el.SectorID === value) return el; }).clean();
					$scope.Companies.push({ 'Name': arr[0].Sector, 'Ticker': arr[0].SectorAbbr, 'Type': "sector" });
					angular.forEach(arr, function (v, i) {
						$scope.Companies.push({ 'Name': v.Company, 'Ticker': v.Ticker, 'Type': "company" });
					});
				});
        }, (error) =&gt; { unblockUI('priceDataDiv'); console.log(error.data); }).then(function () {
        unblockUI('priceDataDiv');
			});
      $scope.priceVars.SelectedCompany = "ALL";
		}

		function BindTimePeriods(MID) {
			$http({
				method: 'GET',
				url: siteRoot + 'Common/Timeperiods',
        params: { sId: $scope.priceVars.SelectedMarket },
			}).then(function (res) {
				$scope.TimePeriods = res.data;
        $scope.priceVars.SelectPeriods = $scope.TimePeriods[0].Value;
			}, (error) =&gt; { console.log(error.data); });
		}

		$scope.MarketBind = function (data, auth) {
			$scope.auth = Number(auth);
			$scope.StockMarkets = data;
		}

		$scope.UpdateStocks = function (SMID) {
			GetSymbolFile(SMID);
      BindTimePeriods(SMID);      
		}

    $scope.LoadFile = function () {
			$scope.DownloadedFile ='';
      if ($scope.priceVars.SelectPeriods === "AllHistorical" &amp;&amp; $scope.auth &lt; 2) {
				var url = $filter('getURL')('/authuser/' + $scope.auth);
				$scope.DownloadedFile = "&lt;p class='bold'&gt; &lt;a  title='" + $filter('getLabel')('lblPremiumOnly') + "' href='" + $filter('getURL')('/authuser/' + $scope.auth) + "'&gt;&lt;img src=\"/Content/Theme/images/lockimages/dpd.png\" /&gt;&lt;/a&gt; &lt;/p&gt;";

			} else {
				LoadData();
			}

			$timeout(() =&gt; {
				$compile(angular.element(document.getElementById('downloadFileBody')))($scope);
			}, 200);
		}

		$timeout(function () {
      $scope.UpdateStocks($scope.priceVars.SelectedMarket)
		});
	}])
	.controller("periodicReportCtrl", ['$compile', '$scope', '$http', '$q', '$timeout', '$filter', function ($compile, $scope, $http, $q, $timeout, $filter) {
		let self = this;
		$scope.reportDates = {};
		$scope.stockMarketID = "0";
		$scope.reportTyeps = {};
		$scope.reportTypeID = "0";
		$scope.reportType = undefined;
		$scope.reportDate = "";
		$scope.loadingDates = false;
		let reportExists = undefined;
		let chartData = [];
		$scope.periodicReportModel = {};
		$scope.reportPath = undefined;
		$scope.noDataFound = undefined;

		$scope.init = ((model) =&gt; {
			let d = model.ReportDateString;
			$scope.reportTypes = model.ReprotTypes;
			$scope.stockMarketID = model.StockMarketID.toString();
			$scope.reportTypeID = model.ReportTypeID.toString();
			//$scope.ReportPath = model.ReportPath;
			reportExists = parseInt(model.ReportExists);

			$scope.$watchGroup(['stockMarketID', 'reportTypeID'], function (newValue, oldValue) {
				$scope.noDataFound = undefined;
				if ($scope.reportTypeID) {
					$scope.reportType = $.grep($scope.reportTypes, (r) =&gt; { if (r.ReportTypeID === parseInt($scope.reportTypeID)) return r; }).firstOrDefault().ReportTypeT;
				}

				if (newValue[0] === "0" || newValue[1] !== oldValue[1]) {
					$scope.reportDates = {};
					$scope.reportDate = "";
				}
				if (oldValue[0] &amp;&amp; newValue[0] !== "0") {
					loadDates(d);
					d = undefined;
				}
			});
			if (!model.ReportDateString) return;
			if (reportExists &gt; 0) {
				loadReportData(model);
			} else {
				loadReportHtml(model);
			}
		});

		$scope.viewReport = (($event) =&gt; {
			window.location.href = siteRoot + "Download/PeriodicalReport?pageID=126&amp;m=" + $scope.stockMarketID + "&amp;t=" + $scope.reportTypeID + "&amp;d=" + $scope.reportDate.substring(0, 10);
		});

		function loadDates(reportDate) {
			$scope.loadingDates = true;
			$http({
				url: '/download/getreportdate',
				method: 'post',
				data: { sid: $scope.stockMarketID, rid: $scope.reportTypeID }
			}).then((res) =&gt; {
				$timeout(() =&gt; {
					$scope.reportDates = res.data;
				});
				if (reportDate)
					$scope.reportDate = reportDate;
			}, (error) =&gt; { console.log(error.data); })
				.then(() =&gt; {
					$scope.loadingDates = false;
				});
		}

		function loadReportData(model) {
			blockUI('collapseOne');
			$http({
				url: siteRoot + 'download/loadperiodicreport',
				method: 'post',
				data: { smid: model.StockMarketID, rtid: model.ReportTypeID, d: model.ReportDateString }
			}).then((res) =&gt; {
				$scope.periodicReportModel = res.data;
			}, (error) =&gt; { console.log(error.data); })

				.finally(() =&gt; {
					$scope.periodicReportModel.chart !== undefined &amp;&amp; $scope.periodicReportModel.chart.map((elem) =&gt; {
						chartData.push([
							parseInt(elem.Date.slice(6, -2)),
							elem.Close
						]);
						$timeout(() =&gt; { createChart(chartData); });
					});
					unblockUI('collapseOne');
				});
		}
		function loadReportHtml(model) {
			$http({
				url: model.ReportPath,
				method: 'get',
				dataType: 'application/html'
			})
				.then((res) =&gt; {
					$scope.reportHtml = res.data;
				}, (data) =&gt; {
					$scope.noDataFound = $filter('getLabel')('lblNoDataFound');
				});
		}
		function createChart(chartData) {

			new Highcharts.stockChart('marketChart', {
				chart: {
					borderColor: '#777',
					borderWidth: 1,
					borderRadius: 0,
					plotBackgroundColor: '',
					padding: 5,
					panning: false
				},
				yAxis: [{
					gridLineColor: '#ececec',
					lineColor: '#ccc',
					lineWidth: 1,
					className: 'ltr',
					labels: {
						align: 'left',
						formatter: function () {
							return $filter('WNOrDec')(this.value, 0);
						},
						x: 5,
						style: {
							color: '#eee',
						}
					}
				}],
				legend: {
					enabled: false
				},
				xAxis: {
					range: 12 * 30 * 24 * 3600 * 1000,
					labels: {
						formatter: function () {
							return Highcharts.dateFormat('%d/%m %y', this.value);
						},
						style: {
							color: '#eee'
						}
					}
				},
				title: {
					text: ''
				},
				scrollbar: {
					enabled: false
				},
				rangeSelector: {
					enabled: false
				},
				navigator: {
					enabled: false
				},
				exporting: {
					enabled: false
				},
				tooltip: {
					style: {
						opacity: '1.0'
					},
					formatter: function () {
						var tooltipHtml = '';
						tooltipHtml = '&lt;div class="col-md-12 padding-5 custom-tooltip ltr"&gt;&lt;p&gt;&lt;b&gt;' + $filter('getLabel')('lblDate') + ': &lt;/b&gt; ' + Highcharts.dateFormat('%b %e, %Y', new Date(this.points[0].x)) + ' &lt;/p&gt;';
						var primary = $.grep(this.points, function (elem) { return elem.series.name === 'primary'; }).firstOrDefault();
						if (!angular.isFunction(primary)) {
							tooltipHtml += '&lt;p style="color:' + primary.series.color + '"&gt;&lt;b&gt;' + $filter('getLabel')('lblClosing') + ': &lt;/b&gt;' + $filter('AbbrOrWNOrDec')(primary.y, 2) + "&lt;/p&gt;";
						}
						return tooltipHtml;
					}
				},
				series: [{
					name: 'primary',
					id: 'primary',
					data: chartData,
					color: '#52658f',
					type: 'line',
					lineWidth: 1,
					threshold: null,
					dataGrouping: {
						forced: true,
						units: [['day', [1]]]
					}
				}]
			});

		}
	}])
	.controller("specialReportIndicesCtrl", ['$compile', '$scope', '$http', '$q', '$timeout', '$filter', function ($compile, $scope, $http, $q, $timeout, $filter) {
		let self = this;
		let marketInfoData = [], maretCapCompanies = [], tradingDistribution = [];
		$scope.init = ((marketInfo, marketCapCompanies, tDistribution) =&gt; {
			marketInfoData = marketInfo;
			marketCapIndices();
			marketIndices();
			/// market cap companies
			maretCapCompanies = marketCapCompanies;
			createCapCompanies();
			///trading distribution
			tradingDistribution = tDistribution;
			createDistribution();
		});

		function marketCapIndices() {
			let chartData = [], chartCats = [];
			let marketCapSet = $.grep(marketInfoData, (elem) =&gt; {
				if (elem.CapSizeID !== 0 || elem.SortOrder === 0) {
					return elem;
				}
			}).clean().sort(sortBy('Change', true));
			marketCapSet.map((elem) =&gt; {
				chartCats.push(elem.StockMarket);
			});
			chartCats.map((cat) =&gt; {
				let mObj = $.grep(marketCapSet, (elem) =&gt; { if (elem.StockMarket === cat) return elem; }).firstOrDefault();
				let color = mObj.Change &gt; 0 ? '#35b121' : '#ef4c36';
				chartData.push({ y: parseFloat(mObj.Change), color: color });
			});
			Highcharts.chart('marketCapIndicesChart', {
				chart: {
					type: 'column',
					borderColor: "#3a3a3a",
					borderRadius: 1,
					borderWidth: 1,
					backgroundColor: "#000",
					panning: false,
					marginBottom: 60,
					events: {
						load: function (event) {
							//$timeout(() =&gt; { exportChart(event.target); });
						}
					}
				},
				exporting: {
					enabled: false
				},
				title: {
					align: 'center',
					floating: false,
					margin: 15,
					style: {},
					text: $filter('getLabel')('lblMarketCapIndices'),
					useHTML: true
				},
				watermark: {
					yAxis: 285,
					xAxis:2
				},
				subtitle: {
					align: 'center',
					floating: false,
					style: { "color": "#eee" },
					text: $filter('getLabel')('lblDailyPerformance'),
					useHTML: true,
				},
				yAxis: [{
					gridLineColor: '#3a3a3a',
					lineColor: '#3a3a3a',
					lineWidth: 1,
					title: '',
					className: 'ltr',
					labels: {
						formatter: function () {
							let factor = parseInt(this.value) === parseFloat(this.value) ? 0 : 2;
							return $filter('WNOrDec')(this.value, factor) + '%';
						},
						style: {
							color: '#eee',
						}
					}
				}],

				legend: {
					enabled: false
				},
				xAxis: {
					labels: {
						formatter: function () {
							return this.value;
						},
						style: {
							color: '#eee'
						}
					},
					categories: chartCats
				},
				credits: {
					enabled: false
				},
				tooltip: {
					formatter: function () {
						return `&lt;div class="col-md-12 padding-5 custom-tooltip ltr defualt-color"&gt;&lt;strong&gt;${this.x}&lt;/strong&gt;
                    &lt;p&gt;&lt;b&gt;${$filter("getLabel")("lblClosing")}: &lt;/b&gt;&lt;label&gt;${$filter("AbbrOrWNOrDec")(this.y, 2)}%&lt;/label&gt;&lt;/p&gt;
                    &lt;/div&gt;`;
					}
				},
				series: [{
					name: 'cap indices',
					data: chartData,
					dataLabels: {
						enabled: true,
						formatter: function () {
							return `&lt;span  style="color:#ADADAD;"&gt;${$filter('number')(this.y, 2)}%&lt;/span&gt;`;
						},
						useHTML: true
					}
				}]
			}, function (chart) {

			});
		}
		function exportChart(chart) {

			html2canvas(document.getElementById('marketCapIndicesChart'), {
				onrendered: function (canvas) {
					document.body.appendChild(canvas);
					var img = canvas.toDataURL().replace(/^data[:]image\/(png|jpg|jpeg)[;]base64,/i, "");
					$.ajax({
						"type": "POST",
						"url": "image/uploadchart",
						"data": {
							"imageData": img
						}
					}).done(function (res) {
						console.log(res);
					});



				},
				width: chart.chartWidth,
				height: chart.chartHeight
			});
		}



		function marketIndices() {
			let chartData = [], chartCats = [];
			let marketInfoSet = $.grep(marketInfoData, (elem) =&gt; {
				if (elem.CapSizeID === 0) {
					return elem;
				}
			}).clean().sort(sortBy('Change',true));
			marketInfoSet.map((elem) =&gt; {
				chartCats.push(elem.StockMarket);
			});
			chartCats.map((cat) =&gt; {
				let mObj = $.grep(marketInfoSet, (elem) =&gt; { if (elem.StockMarket === cat) return elem; }).firstOrDefault();
				let color = mObj.Change &gt; 0 ? '#35b121' : '#ef4c36';
				chartData.push({ y: parseFloat(mObj.Change), color: color });
			});


			Highcharts.chart('marketIndicesChart', {
				chart: {
					type: 'column',
					borderColor: "#3a3a3a",
					borderRadius: 1,
					borderWidth: 1,
					backgroundColor: "#ADADAD",
					panning: false
				},
				exporting: {
					enabled: false
				},
				watermark: {
					yAxis: 335,
					xAxis:2
				},
				title: {
					align: 'center',
					floating: false,
					margin: 15,
					style: {},
					text: $filter('getLabel')('lbSectorIndices'),
					useHTML: true
				},
				subtitle: {
					align: 'center',
					floating: false,
					style: { "color": "#eee" },
					text: $filter('getLabel')('lblDailyPerformance'),
					useHTML: true,
				},
				yAxis: [{
					gridLineColor: '#3a3a3a',
					lineColor: '#3a3a3a',
					lineWidth: 1,
					title: '',
					className: 'ltr',
					labels: {
						formatter: function () {
							let factor = parseInt(this.value) === parseFloat(this.value) ? 0 : 2;
							return $filter('WNOrDec')(this.value, factor) + '%';
						},
						style: {
							color: '#eee',
						}
					}
				}],
				legend: {
					enabled: false
				},
				xAxis: {
					labels: {
						formatter: function () {
							return this.value;
						},
						style: {
							color: '#eee'
						}
					},
					categories: chartCats
				},
				credits: {
					enabled: false
				},
				tooltip: {
					style: {
						opacity: '1.0'
					},
					formatter: function () {
						return `&lt;div class="col-md-12 padding-5 custom-tooltip ltr defualt-color"&gt;&lt;strong&gt;${this.x}&lt;/strong&gt;
                    &lt;p style="color:${this.color};"&gt;&lt;b&gt;${$filter("getLabel")("lblClosing")}: &lt;/b&gt;&lt;span class="text-color"&gt;${$filter("AbbrOrWNOrDec")(this.y, 2)}%&lt;/span&gt;&lt;/p&gt;
                    &lt;/div&gt;`;
					}
				},
				series: [{
					name: 'Market Indices',
					data: chartData,
					dataLabels: {
						enabled: true,
						formatter: function () {
							let factor = parseInt(this.y) === parseFloat(this.y) ? 0 : 2;
							return `&lt;p style="color:#ADADAD;"&gt;&lt;b&gt;${$filter('number')(this.y, factor)}%`;
						},
						useHTML: true
					}
				}]
			});
		}

		function createCapCompanies() {
			let candleStick = [], volume = [];
			maretCapCompanies.map((elem) =&gt; {
				let color = (parseFloat(elem.Opening) - parseFloat(elem.Closing)) &lt; 0 ? '#42f450' : '#f41c04';
				candleStick.push({ x: parseInt(elem.Date.slice(6, -2)), open: elem.Opening, high: elem.Highest, low: elem.Lowest, close: elem.Closing, color: color })
				volume.push([parseInt(elem.Date.slice(6, -2)), elem.Volume]);
			});
			var groupingUnits = [['week', [1]], ['month', [1, 2, 3, 4, 6]]];


			Highcharts.stockChart('topMarketCapChart', {
				chart: {
					borderColor: "#ccc",
					borderRadius: 1,
					borderWidth: 1,
					backgroundColor: null,
					panning: false,
					marginBottom: 50
				},
				watermark: {
					yAxis: 335,
					xAxis:2
				},
				scrollbar: {
					enabled: false
				},
				rangeSelector: {
					enabled: false
				},
				navigator: {
					enabled: false
				},
				exporting: {
					enabled: false
				},
				rangeSelector: {
					enabled: false,
					selected: 1
				},
				title: {
					text: maretCapCompanies.firstOrDefault().StockMarket
				},
				xAxis: {
					type: 'datetime',
					labels: {
						formatter: function () {
							return Highcharts.dateFormat('%d/%m/%y', this.value);
						},
						style: {
							color: '#eee'
						}
					}
				},
				tooltip: {
					shared: true,
					formatter: function () {
						var tooltipHtml = '&lt;div class="col-md-12 padding-5 custom-tooltip ltr"&gt;';
						var volume = $.grep(this.points, function (elem) { return elem.series.name === "Volume" }).firstOrDefault();
						tooltipHtml += `&lt;div class="display-table"&gt;&lt;div class="col-md-12 tooltip-body"&gt;&lt;p&gt;&lt;b&gt;${$filter('getLabel')('lblDate')}&lt;b&gt;: ${$filter('date')(volume.x, 'dd/MM/yyyy')}&lt;/p&gt;`;

						var cS = $.grep(this.points, function (elem) { return elem.series.name === "candlestick" }).firstOrDefault();
						if (!angular.isFunction(cS)) {
							tooltipHtml += `&lt;p&gt;${$filter('getLabel')('lblOpen')}: &lt;/label&gt;&lt;span style="color:${cS.series.options.color}"&gt;${$filter('number')(cS.point.open, 2)}&lt;/p&gt;`;
							tooltipHtml += `&lt;p&gt;${$filter('getLabel')('lblHigh')}: &lt;/label&gt;&lt;span style="color:${cS.series.options.color}"&gt;${$filter('number')(cS.point.high, 2)}&lt;/p&gt;`;
							tooltipHtml += `&lt;p&gt;${$filter('getLabel')('lblLow')}: &lt;/label&gt;&lt;span style="color:${cS.series.options.color}"&gt;${$filter('number')(cS.point.low, 2)}&lt;/p&gt;`;
							tooltipHtml += `&lt;p&gt;${$filter('getLabel')('lblClose')}: &lt;/label&gt;&lt;span style="color:${cS.series.options.color}"&gt;${$filter('number')(cS.point.close, 2)}&lt;/p&gt;`;
						}

						if (!angular.isFunction(volume)) {
							tooltipHtml += `&lt;p&gt;&lt;b&gt; ${$filter('getLabel')('lblVolume')}: &lt;/b&gt;&lt;b style="color:${volume.series.color}"&gt;${$filter('AbbrOrWNOrDec')(volume.y, 2)}&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;`;
						}
						tooltipHtml += '&lt;/div&gt;';
						return tooltipHtml;
					}
				},
				yAxis: [{
					labels: {
						align: 'right',
						x: -3
					},
					title: {
						text: $filter('getLabel')('lblIndex'),
					},
					height: '55%',
					lineWidth: 2,
					resize: {
						enabled: true
					}
				}, {
					labels: {
						align: 'right',
						x: -3
					},
					title: {
						text: $filter('getLabel')('lblVolume'),
					},
					top: '60%',
					height: '40%',
					offset: 0,
					lineWidth: 2,
					labels: {
						formatter: function () {
							let factor = parseInt(this.value) === parseFloat(this.value) ? 0 : 2;
							return $filter('AbbrOrWNOrDec')(this.value, factor);
						},
						style: {
							color: '#eee'
						}
					},
					tickPositioner: function () {
						var positions = [],
							tick = Math.floor(this.dataMin) - (Math.floor(this.dataMin) / 10),
							increment = Math.ceil((this.dataMax - this.dataMin) / 2);
						if (this.dataMax !== null &amp;&amp; this.dataMin !== null) {
							for (tick; tick - increment &lt;= this.dataMax; tick += increment) {
								positions.push(tick);
							}
						}
						return positions;
					}
				}],
				series: [{
					type: 'column',
					name: 'Volume',
					data: volume,
					yAxis: 1,
					color: Highcharts.getOptions().colors[9],
					dataGrouping: {
						units: groupingUnits
					}
				}, {
					type: 'candlestick',
					name: 'candlestick',
					color: Highcharts.getOptions().colors[5],
					data: candleStick,
					dataGrouping: {
						units: groupingUnits
					}
				}]
			});
		}

		function createDistribution() {
			let cats = [];
			let chartSeries = [];
			cats = tradingDistribution.map((elem) =&gt; { return elem.Sector; }).uniqueArray();

			chartSeries.push({
				name: 'Volume',
				options: {
					name: $filter('getLabel')('lblVolume')
				},
				data: $.map(tradingDistribution, (el) =&gt; { return el.Volme; })
			});
			chartSeries.push({
				name: 'Value',
				options: {
					name: $filter('getLabel')('lblValue')
				},
				data: $.map(tradingDistribution, (el) =&gt; { return el.Value; })
			});
			chartSeries.push({
				name: 'Transaction',
				options: {
					name: $filter('getLabel')('lblTransaction')
				},
				data: $.map(tradingDistribution, (el) =&gt; { return el.Transaction; })
			});


			Highcharts.chart('dailyTradingDistribution', {
				chart: {
					type: 'column',
					borderColor: "#3a3a3a",
					borderRadius: 1,
					borderWidth: 1,
					backgroundColor: "#000",
					panning: false
				},
				watermark: {
					yAxis: 335,
					xAxis:2
				},
				title: {
					text: $filter('getLabel')('lblDailyTradingActvity')
				},
				subtitle: {
					text: ''
				},
				xAxis: {
					categories: cats,
					crosshair: true
				},
				yAxis: {
					lineColor: '#3a3a3a',
					lineWidth: 1,
					title: {
						text: ''
					},
					labels: {
						formatter: function () {
							let factor = parseInt(this.value) === parseFloat(this.value) ? 0 : 2;
							return `${$filter('number')(this.value, factor)}%`;
						},
						style: {
							color: '#eee'
                        }

					},
					tickPositioner: function () {
						var positions = [],
							tick = Math.floor(this.dataMin),
							increment = Math.ceil((this.dataMax - this.dataMin) / 5);

						if (this.dataMax !== null &amp;&amp; this.dataMin !== null) {
							for (tick; tick - increment &lt;= this.dataMax; tick += increment) {
								positions.push(tick);
							}
						}
						return positions;
					}
				},
				legend: {
					layout: 'vertical',
					align: 'right',
					verticalAlign: 'top',
					floating: true,
					backgroundColor: '#FFFFFF',
					labelFormatter: function () {
						return this.userOptions.options.name
					}
				},
				tooltip: {
					headerFormat: `&lt;div class="col-md-12 padding-5 custom-tooltip ltr"&gt;&lt;strong&gt;{point.key}&lt;/strong&gt;&lt;table class="display-table"&gt;`,
					pointFormat: `&lt;tr&gt;&lt;td style="color:{series.color};padding:0"&gt;{series.name}: &lt;/td&gt;
					              &lt;td style="padding:0"&gt;&lt;b&gt;{point.y:.1f}%&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;`,
					footerFormat: `&lt;/table&gt;&lt;/div&gt;`,
					shared: true,
					useHTML: true
				},
				plotOptions: {
					column: {
						pointPadding: 0.2,
						borderWidth: 0
					}
				},
				series: chartSeries
			});


		}

	}])
	.controller("specialReportGCCCtrl", ['$compile', '$scope', '$http', '$q', '$timeout', '$filter', function ($compile, $scope, $http, $q, $timeout, $filter) {
		$scope.init = ((marketCapDist, volumDist, dailyGCCMarketPerf, marketsPerf) =&gt; {
			marketCapDistributionFunc(marketCapDist);
			volumeDistributionFunc(volumDist);
			dailyGCCStockMarketPerformanceFunc(dailyGCCMarketPerf);

			dailyGCCStockMarketsPerformanceFunc(marketsPerf);
		});

		function marketCapDistributionFunc(marketCapDistribution) {
			let chartData = [];
			marketCapDistribution.map((elem) =&gt; {
				chartData.push([elem.Abbr, elem.MarketCap]);
			});

			Highcharts.chart('dailyMarketCapReviewChart', {
				chart: {
					type: 'pie',
					options3d: {
						enabled: true,
						alpha: 45,
						beta: 0
					}
				},
				watermark: {
					yAxis:240
				},
				title: {
					text: $filter('getLabel')('lblDailyMarketCapDistribution')
				},
				tooltip: {
					formatter: function () {
						let factor = parseInt(this.point.percentage) === parseFloat(this.point.percentage) ? 0 : 2;
						return `&lt;b&gt;${this.point.name}&lt;/b&gt; &lt;span style="color:${this.point.color}"&gt; ${$filter('WNOrDec')(this.point.percentage, factor)}%&lt;/span&gt;`;
					}
				},
				plotOptions: {
					pie: {
						allowPointSelect: true,
						cursor: 'pointer',
						depth: 40,
						dataLabels: {
							enabled: true,
							useHTML: true,
							formatter: function () {
								let factor = parseInt(this.point.percentage) === parseFloat(this.point.percentage) ? 0 : 2;
								return `&lt;div&gt;&lt;div class="col-md-6"&gt;&lt;strong&gt;${this.point.name}&lt;/strong&gt;&lt;/div&gt;&lt;div class="col-md-6"&gt; ${$filter('WNOrDec')(this.point.percentage, factor)}%&lt;/div&gt;&lt;/div&gt;`;
							}
						}
					}
				},
				series: [{
					type: 'pie',
					name: 'Market Cap Review',
					data: chartData
				}]
			});
		}

		function volumeDistributionFunc(volumeDistribution) {
			let chartData = [];
			volumeDistribution.map((elem) =&gt; {
				chartData.push([elem.Abbr, elem.Volume]);
			});

			Highcharts.chart('dailyVolumeDistributionChart', {
				chart: {
					type: 'pie',
					options3d: {
						enabled: true,
						alpha: 45,
						beta: 0
					}
				},
				watermark: {
					yAxis: 240
				},
				title: {
					text: $filter('getLabel')('lblDailyVolumeDistribution')
				},
				tooltip: {
					formatter: function () {
						let factor = parseInt(this.point.percentage) === parseFloat(this.point.percentage) ? 0 : 2;
						return `${this.point.name} &lt;span style="color:${this.point.color}"&gt; ${$filter('WNOrDec')(this.point.percentage, factor)}%&lt;/span&gt;`;
					}
				},
				plotOptions: {
					pie: {
						allowPointSelect: true,
						cursor: 'pointer',
						depth: 40,
						dataLabels: {
							enabled: true,
							useHTML: true,
							formatter: function () {
								let factor = parseInt(this.point.percentage) === parseFloat(this.point.percentage) ? 0 : 2;
								return `&lt;div&gt;&lt;div class="col-md-6 no-margin"&gt;&lt;strong&gt;${this.point.name}&lt;/strong&gt;&lt;/div&gt;&lt;div class="col-md-6 no-margin"&gt; ${$filter('WNOrDec')(this.point.percentage, factor)}%&lt;/div&gt;&lt;/div&gt;`;
							}
						}
					}
				},
				series: [{
					type: 'pie',
					name: 'Volume Distribution',
					data: chartData
				}]
			});
		}

		function dailyGCCStockMarketPerformanceFunc(gccDailyStockMarketPerf) {
			let chartData = [], chartCats = [];
			let marketInfoSet = gccDailyStockMarketPerf.sort(sortBy('ChangePer',true));
			gccDailyStockMarketPerf.map((elem) =&gt; {
				chartCats.push(elem.Abbr);
			});
			chartCats.map((cat) =&gt; {
				let mObj = $.grep(gccDailyStockMarketPerf, (elem) =&gt; { if (elem.Abbr === cat) return elem; }).firstOrDefault();
				let color = mObj.ChangePer &gt; 0 ? '#35b121' : '#ef4c36';
				chartData.push({ y: parseFloat(mObj.ChangePer), color: color });
			});
			Highcharts.chart('dailyMarketPerformanceChart', {
				chart: {
					type: 'column',
					borderColor: "#3a3a3a",
					borderRadius: 1,
					borderWidth: 1,
					backgroundColor: "#000",
					panning: false
				},
				watermark: {
					yAxis: 275,
					xAxis:2
				},
				title: {
					align: 'center',
					floating: false,
					margin: 15,
					style: {},
					text: $filter('getLabel')('lblGCCDailyStockMarketsPerformance'),
					useHTML: true
				},
				subtitle: {
					align: 'center',
					floating: false,
					style: { "color": "#eee" },
					text: '',
					useHTML: true,
				},
				yAxis: [{
					gridLineColor: '#3a3a3a',
					lineColor: '#3a3a3a',
					lineWidth: 1,
					title: '',
					className: 'ltr',
					labels: {
						formatter: function () {
							return $filter('WNOrDec')(this.value, 2) + '%';
						},
						style: {
							color: '#eee',
						}
					}
				}],
				legend: {
					enabled: false
				},
				xAxis: {
					labels: {
						formatter: function () {
							return this.value;
						},
						style: {
							color: '#eee'
						}
					},
					categories: chartCats
				},
				credits: {
					enabled: false
				},
				tooltip: {
					style: {
						opacity: '1.0'
					},
					formatter: function () {
						return `&lt;div class="col-md-12 padding-5 custom-tooltip ltr defualt-color"&gt;&lt;strong&gt;${this.x}&lt;/strong&gt;
                    &lt;p style="color:${this.color};"&gt;&lt;b&gt;${$filter("getLabel")("lblClosing")}: &lt;/b&gt;&lt;span class="text-color"&gt;${$filter("AbbrOrWNOrDec")(this.y, 2)}%&lt;/span&gt;&lt;/p&gt;
                    &lt;/div&gt;`;
					}
				},
				plotOptions: {
					series: {
						labels: {
							style: {
								color: '#eee'
							}
						}
					}
				},
				series: [{
					name: 'Market Indices',
					data: chartData,
					dataLabels: {
						enabled: true,
						formatter: function () {
							let factor = parseInt(this.y) === parseFloat(this.y) ? 0 : 2;
							return `&lt;span  class="${$filter('successclass')(this.y)}"&gt;${$filter('number')(this.y, factor)}%&lt;/span&gt;`;
						},
						useHTML: true
					}
				}]
			});
		}

		function dailyGCCStockMarketsPerformanceFunc(performanceData) {
			let chartData = [], markets = [], perfChartSeries = [];
			performanceData.map((el) =&gt; { markets.push(el.StockMarket); });


			angular.forEach(markets.uniqueArray(), function (market) {
				let tempData = [];
				performanceData.map((m) =&gt; { if (m.StockMarket === market) tempData.push([parseInt(m.Date.slice(6, -2)), m.Closing]); })

				perfChartSeries.push({
					id: market,
					name: market,
					aname: market,
					data: tempData,
					turboThreshold: 0,
					compare: 'percent',
					showInNavigator: true,
					dataGrouping: {
						forced: true,
						units: [['day', [1]]]
					}
				});
			});

			let perfChart = Highcharts.stockChart('gccStockMarketsPerfChart', {
				chart: {
					borderColor: '#ccc',
					borderWidth: 1,
					plotBackgroundColor: ''
				},
				watermark: {
					yAxis: 290,
					xAxis:2
				},
				title: {
					text: $filter('getLabel')('lblGCCStockMarketsPerformance')
				},
				legend: {
					align: 'right',
					verticalAlign: 'top',
					layout: 'vertical',
					x: 0,
					y: 25,
					enabled: true
				},
				scrollbar: {
					enabled: false
				},
				navigator: {
					enabled: false
				},
				rangeSelector: {
					enabled: false,
				},
				scrollbar: {
					enabled: false
				},
				xAxis: {
					type: 'datetime',
					labels: {
						formatter: function () {
							return Highcharts.dateFormat('%d %b %y', this.value);
						}
					}
				},
				yAxis: {
					lineWidth: 1,
					labels: {
						x: -5,
						y: -7,
						formatter: function () {
							return $filter('WNOrDec')(this.value, 2) + '%';
						}
					},
					opposite: false
				},
				tooltip: {
					formatter: function () {
						var tooltipHtml = '&lt;ul class="highcharts-gb-tooltip"&gt;&lt;li class="text-bold text-capitalize"&gt;' + $filter('getLabel')('lblDate') + ': &lt;/li&gt;&lt;li&gt;' + $filter('date')(this.points[0].x, 'dd/MM/yyyy') + "&lt;/li&gt;&lt;/ul&gt;";
						for (var i = 0; i &lt; this.points.length; i++) {
							var point = this.points[i];
							if (point.series.options.cname === undefined)
								tooltipHtml += "&lt;ul class=\"highcharts-gb-tooltip\"&gt;&lt;li style='color:" + point.color + ";'  class=\"text-bold text-capitalize\"&gt;" + point.series.options.aname + ":&lt;/li&gt;&lt;li&gt;" + $filter('WNOrDec')(point.y, 2) + "&lt;/li&gt;&lt;li class='" + $filter('successclass')(point.point.change) + "'&gt; (" + $filter("WNOrDec")(point.point.change, 2) + " %)&lt;/li&gt;&lt;/ul&gt;";
							else
								tooltipHtml += "&lt;ul class=\"highcharts-gb-tooltip\"&gt;&lt;li style='color:" + point.color + ";'  class=\"text-bold text-capitalize\"&gt;" + point.series.options.cname + ":&lt;/li&gt;&lt;li class='" + $filter('successclass')(point.y) + "'&gt;" + $filter("WNOrDec")(point.y, 2) + " %&lt;/li&gt;&lt;/ul&gt;";
						}
						return tooltipHtml;
					},
					borderWidth: 0,
					shadow: false,
					useHTML: true
				},
				plotOptions: {
					series: {
						labels: {
							style: {
								color: '#eee'
							}
						}
					}
				},
				series: perfChartSeries
			});

		}
	}])
	;</pre></body></html>