UNPKG

prodap-chatbot-domain

Version:

Classes utilizadas na resposta de todas as Intents do Assistente Virtual

108 lines 5.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("../types"); const BarChart_1 = require("./BarChart"); const ChartAbstract_1 = require("./ChartAbstract"); const ChartTypes_1 = require("./ChartTypes"); const legends_1 = require("./legends"); const LineChart_1 = require("./LineChart"); class BarLineChart extends ChartAbstract_1.default { constructor(props) { super(props, ChartTypes_1.default.BAR_LINE_CHART, ''); this.legendData = []; if (!props.isAppConstructor) { this.rules = props.rules; this.list = props.list; } else { this.list = []; this.rules = []; const rules = props.rules; const list = props.list; if (rules) { rules.map((rule) => { if (!Array.isArray(rule)) { const newRule = rule; if (props.dataType === types_1.DataTypes.PERCENT) { const decimal = 2; const valMax = newRule.valMax * 100; const valMin = newRule.valMin * 100; newRule.valMax = Number(Math.round(Number(`${valMax}e${decimal}`)) + `e-${decimal}`); newRule.valMin = Number(Math.round(Number(`${valMin}e${decimal}`)) + `e-${decimal}`); } this.rules.push(newRule); rule.subtitle = rule.label; this.legendData.push(new legends_1.default(rule)); } else { const items = []; rule.map((item) => { const newRule = item; if (props.dataType === types_1.DataTypes.PERCENT) { const decimal = 2; const valMax = newRule.valMax * 100; const valMin = newRule.valMin * 100; newRule.valMax = Number(Math.round(Number(`${valMax}e${decimal}`)) + `e-${decimal}`); newRule.valMin = Number(Math.round(Number(`${valMin}e${decimal}`)) + `e-${decimal}`); } items.push(newRule); item.subtitle = item.label; const legend = this.legendData.find((obj) => obj.description === item.subtitle); if (!legend) { return this.legendData.push(new legends_1.default(item)); } return; }); this.rules.push(items); } return; }); } if (list) { list.map(({ barChart, lineChart }) => { const listItem = {}; const barData = []; const lineData = []; barChart === null || barChart === void 0 ? void 0 : barChart.map((bar) => { if (bar) { const assembleBarChart = new BarChart_1.default({ chartProps: bar, barWidth: bar.barWidth, titleAxisX: bar.titleAxisX, titleAxisY: bar.titleAxisY, minimumBars: bar.minimumBars, rules: bar.rules, data: bar.data, }); assembleBarChart.addData(bar.data); barData.push(assembleBarChart); } }); listItem.barChart = barData; lineChart === null || lineChart === void 0 ? void 0 : lineChart.map((line) => { if (line) { const assembleLineChart = new LineChart_1.default({ chartProps: line, titleAxisX: line.titleAxisX, titleAxisY: line.titleAxisY, yMax: line.yMax, yMin: line.yMin, xAxisBolders: line.xAxisBolders, interpolation: line.interpolation, showTooltipLabels: line.showTooltipLabels, data: line.data, legendList: line.legendList, }); assembleLineChart.addData(line.data); lineData.push(assembleLineChart); } }); listItem.lineChart = lineData; return this.list.push(listItem); }); } } } } exports.default = BarLineChart; //# sourceMappingURL=BarLineChart.js.map