import { Injectable } from '@angular/core'; @Injectable() export class ChartsConfigService { CALLS_COLOR = { PLAN: '#058DC7', FAKT: '#50B432' } constructor() { } getPieConfig(titleName, titleValue, dataValue, overdue, inRows) { return { chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: titleName + ' ' + titleValue, align: 'left', verticalAlign: 'top', style: { fontWeight: "bold", fontFamily: "Open Sans", fontSize: '13px' }, y: 16, x: 30, useHTML: true }, tooltip: { pointFormat: '{series.name}: {point.percentage:.1f}%' }, plotOptions: { pie: { center: ['50%', '55%'] } }, legend: { align: 'right', layout: 'vertical', verticalAlign: 'top', x: 0, y: 0, margin: 0, floating: true, itemStyle: { fontWeight: 'normal' } }, credits: { enabled: false }, series: [ { type: 'pie', name: 'Аварійні ситуації', innerSize: '70%', data: dataValue, dataLabels: { enabled: false }, showInLegend: false }, { type: 'pie', name: 'Аварійні ситуації', dataLabels: { enabled: true, style: { fontWeight: 'bold', color: 'white', textShadow: '0px 0px 0px black' }, distance: -22, formatter: function () { if (this.percentage != 0) return Math.round(this.percentage) + '%'; } }, size: '70%', data: [ ["Прострочені", overdue], ["У строк", inRows] ], colors: ["red", "green"], showInLegend: true } ] } } getBarConfig(dataCategories, dataSeries1, dataSeries2) { return { chart : { type : 'bar', }, title: { text: 'Загально по Києву (за тиждень)' }, xAxis: { categories: dataCategories }, yAxis: { title: { text: 'Кількість дзвінків' } }, tooltip: { shared: true, valueSuffix: ' дзвінків' }, credits: { enabled: false }, series: [{ name: 'Факт', data: dataSeries1 }, { name: 'План', data: dataSeries2 }] }; } getAreaConfig(dataCategories, dataSeries1, dataSeries2) { return { chart : { type : 'area', }, title: { text: 'Загально по Києву (за тиждень)' }, xAxis: { categories: dataCategories }, yAxis: { title: { text: 'Кількість дзвінків' } }, tooltip: { shared: true, valueSuffix: ' дзвінків' }, credits: { enabled: false }, series: [{ name: 'Факт', data: dataSeries1 }, { name: 'План', data: dataSeries2 }] }; } getBarLineConfig(dataCategories, dataSeries1, dataSeries2) { return { chart : { type : 'column', }, title: { text: 'Загально по Києву (за тиждень)' }, xAxis: { categories: dataCategories }, yAxis: { title: { text: 'Кількість дзвінків' } }, tooltip: { shared: true, valueSuffix: ' дзвінків' }, credits: { enabled: false }, series: [{ name: 'Факт', data: dataSeries1 }, { name: 'План', data: dataSeries2 }] }; } getBaseLineConfig(title, dataCategories, dataSeries1, dataSeries2) { return { chart: { type: 'line', animation: true }, title: { text: title + ' за тиждень', x: -20 }, xAxis: { categories: dataCategories }, yAxis: { title: { text: 'Кількість звернень' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, credits: { enabled: false }, tooltip: { valueSuffix: 'звернень' }, series: [{ name: 'Факт', color: this.CALLS_COLOR.FAKT, data: dataSeries1 }, { name: 'План', color: this.CALLS_COLOR.PLAN, data: dataSeries2 }] }; } }