From 9d2b48c156d9beeefc924b5ddf357232abcf2440 Mon Sep 17 00:00:00 2001 From: Orlando <57908549+OrlandoP97@users.noreply.github.com> Date: Thu, 2 May 2024 16:49:49 -0300 Subject: [PATCH 01/16] make some experimental changes --- .vscode/settings.json | 2 +- package-lock.json | 58 ++ package.json | 1 + .../query-viewer-card-controller.tsx | 4 +- .../controller/highcharts-options.ts | 18 +- .../controller/processDataAndMetadata.ts | 3 +- src/index.html | 547 +++++++++--------- src/utils/general.ts | 86 ++- 8 files changed, 411 insertions(+), 308 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 724f076..242f622 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,6 @@ "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" } } diff --git a/package-lock.json b/package-lock.json index f7e6878..92f58fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@genexus/reporting-api": "~3.1.0", "@genexus/web-controls-library": "2.3.0", + "@genexus/web-standard-functions": "file:///C:/PROJECTS/genexus/web-standard-functions/dist/lib-esm", "date-fns": "^2.30.0", "highcharts": "^11.1.0", "jquery": "^3.7.1", @@ -47,6 +48,56 @@ "typescript": "^4.9.0" } }, + "../web-standard-functions": { + "name": "@genexus/web-standard-functions", + "version": "0.60.0", + "license": "MIT", + "dependencies": { + "@types/websocket": "^1.0.4", + "full-icu": "^1.3.0", + "jdu": "^1.0.0", + "jstz": "^2.1.1", + "loglevel": "^1.6.7", + "luxon": "^1.22.0", + "pubsub-js": "^1.8.0", + "tidy-html5": "^0.1.1", + "unicode-substring": "^1.0.0", + "uuid": "^8.3.2", + "xslt-processor": "^0.11.5" + }, + "devDependencies": { + "@types/jest": "^27.0.2", + "@types/pubsub-js": "^1.5.18", + "@typescript-eslint/eslint-plugin": "^5.25.0", + "@typescript-eslint/parser": "^5.25.0", + "atob": "^2.1.2", + "btoa": "^1.2.1", + "env-cmd": "^8.0.2", + "eslint": "^8.15.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-jsdoc": "^39.3.0", + "eslint-plugin-react": "^7.30.0", + "husky": "^2.7.0", + "jest": "^27.0.5", + "jest-websocket-mock": "^1.5.1", + "mock-socket": "~8.0", + "prettier": "^1.19.1", + "pretty-quick": "^1.11.1", + "shx": "^0.3.2", + "standard-api-generator": "git+https://github.com/genexuslabs/standard-api-generator.git", + "ts-jest": "^27.0.5", + "typescript": "^4.4", + "wait-for-expect": "^3.0.2" + }, + "engines": { + "node": ">=8.1.0" + } + }, + "../web-standard-functions/dist": {}, + "../web-standard-functions/dist/lib-esm": {}, + "../web-standard-functions/lib-esm": { + "extraneous": true + }, "node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -2755,6 +2806,10 @@ "swiper": "^8.4.7" } }, + "node_modules/@genexus/web-standard-functions": { + "resolved": "../web-standard-functions/dist/lib-esm", + "link": true + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", @@ -18284,6 +18339,9 @@ "swiper": "^8.4.7" } }, + "@genexus/web-standard-functions": { + "version": "file:../web-standard-functions/dist/lib-esm" + }, "@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", diff --git a/package.json b/package.json index d0fb607..61b30dc 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "dependencies": { "@genexus/reporting-api": "~3.1.0", "@genexus/web-controls-library": "2.3.0", + "@genexus/web-standard-functions": "file:///C:/PROJECTS/genexus/web-standard-functions/dist/lib-esm", "date-fns": "^2.30.0", "highcharts": "^11.1.0", "jquery": "^3.7.1", diff --git a/src/components/query-viewer-card/controller/query-viewer-card-controller.tsx b/src/components/query-viewer-card/controller/query-viewer-card-controller.tsx index 207e0fe..48c9bb1 100644 --- a/src/components/query-viewer-card/controller/query-viewer-card-controller.tsx +++ b/src/components/query-viewer-card/controller/query-viewer-card-controller.tsx @@ -78,6 +78,8 @@ export class QueryViewerCard { @Prop() readonly serviceResponse: QueryViewerServiceResponse; @Watch("serviceResponse") handleServiceResponseChange(newResponse: QueryViewerServiceResponse) { + console.log(newResponse); + this.updateCards(newResponse); } @@ -190,7 +192,7 @@ export class QueryViewerCard { ); } }); - + console.log("cardsToRender", cardsToRender); return cardsToRender; } diff --git a/src/components/query-viewer-chart/controller/highcharts-options.ts b/src/components/query-viewer-chart/controller/highcharts-options.ts index 8297d8d..770c8a5 100644 --- a/src/components/query-viewer-chart/controller/highcharts-options.ts +++ b/src/components/query-viewer-chart/controller/highcharts-options.ts @@ -16,10 +16,9 @@ import { PaneOptions, PlotOptions, PointMarkerOptionsObject, - SeriesLineOptions + SeriesLineOptions, // ExtremesObject, // SeriesLineOptions - , SeriesOptionsType, SubtitleOptions, TooltipFormatterContextObject, @@ -53,6 +52,7 @@ import { getChartGroup } from "./chart-utils"; import { ChartMetadataAndData, XAxisDataType } from "./processDataAndMetadata"; +import { GxBigNumber } from "@genexus/web-standard-functions/types/gxbignumber"; const DEFAULT_CHART_SPACING = 10; export const HOURS_PER_DAY = 24; @@ -1524,7 +1524,7 @@ function groupPoints( dateStr: null, name: null }; - let pointAdd: { x: string; y: number; name: string }; + let pointAdd: { x: string; y: GxBigNumber; name: string }; let currentYValues: number[] = []; let currentYQuantities: number[] = []; const points = []; @@ -1566,7 +1566,11 @@ function groupPoints( } else { pointAdd = { x: lastStartPoint.dateStr, - y: aggregate(aggregation, currentYValues, currentYQuantities), + y: aggregate( + aggregation, + currentYValues.map(value => new GxBigNumber(value)), + currentYQuantities + ), name: lastStartPoint.name }; points.push(pointAdd); @@ -1578,7 +1582,11 @@ function groupPoints( if (currentYValues.length > 0 && currentYQuantities.length > 0) { pointAdd = { x: lastStartPoint.dateStr, - y: aggregate(aggregation, currentYValues, currentYQuantities), + y: aggregate( + aggregation, + currentYValues.map(value => new GxBigNumber(value)), + currentYQuantities + ), name: lastStartPoint.name }; points.push(pointAdd); diff --git a/src/components/query-viewer-chart/controller/processDataAndMetadata.ts b/src/components/query-viewer-chart/controller/processDataAndMetadata.ts index 46ab3fd..64a6132 100644 --- a/src/components/query-viewer-chart/controller/processDataAndMetadata.ts +++ b/src/components/query-viewer-chart/controller/processDataAndMetadata.ts @@ -28,6 +28,7 @@ import { parseNumericPicture } from "../../../utils/general"; import { ChartTypes, IS_CHART_TYPE, isDatetimeXAxis } from "./chart-types"; +import { GxBigNumber } from "@genexus/web-standard-functions/types/gxbignumber"; export type ChartMetadataAndData = { Categories: QueryViewerChartCategories; @@ -512,7 +513,7 @@ function aggregatePoints(chartSerie: QueryViewerChartSerie) { }); const value = aggregate( chartSerie.Aggregation, - currentYValues, + currentYValues.map(val => new GxBigNumber(val)), currentYQuantities ).toString(); chartSerie.Points = [{ Value: value, Value_N: value, Value_D: "1" }]; diff --git a/src/index.html b/src/index.html index 399976b..91d4ab2 100644 --- a/src/index.html +++ b/src/index.html @@ -644,68 +644,68 @@ const serviceResponseCardMock = { MetaData: { - "textForNullValues": "", - "axes": [], - "data": [ - { - "name": "Element1", - "title": "Average of Country Life Expectancy", - "dataField": "F1", - "aggregation": "Average", - "dataType": "real", - "visible": "Yes", - "picture": "ZZZZZZZZZZZZZZ9", - "raiseItemClick": true, - "isComponent": false, - "targetValue": 100, - "maximumValue": 100, - "style": "", - "conditionalStyles": [], - "isFormula": false, - "formula": "" - }, - { - "name": "F1_N", - "title": "F1_N", - "dataField": "F1_N", - "aggregation": "Sum", - "dataType": "real", - "visible": "Never", - "picture": "ZZZZZZZZZZZZZZ9.99", - "raiseItemClick": false, - "isComponent": true, - "targetValue": 100, - "maximumValue": 100, - "style": "", - "conditionalStyles": [], - "isFormula": false, - "formula": "" - }, - { - "name": "F1_D", - "title": "F1_D", - "dataField": "F1_D", - "aggregation": "Count", - "dataType": "integer", - "visible": "Never", - "picture": "ZZZZZZZZZZZZZZ9", - "raiseItemClick": false, - "isComponent": true, - "targetValue": 100, - "maximumValue": 100, - "style": "", - "conditionalStyles": [], - "isFormula": false, - "formula": "" + textForNullValues: "", + axes: [], + data: [ + { + name: "Element1", + title: "Average of Country Life Expectancy", + dataField: "F1", + aggregation: "Average", + dataType: "real", + visible: "Yes", + picture: "ZZZZZZZZZZZZZZ9", + raiseItemClick: true, + isComponent: false, + targetValue: 100, + maximumValue: 100, + style: "", + conditionalStyles: [], + isFormula: false, + formula: "" + }, + { + name: "F1_N", + title: "F1_N", + dataField: "F1_N", + aggregation: "Sum", + dataType: "real", + visible: "Never", + picture: "ZZZZZZZZZZZZZZ9.99", + raiseItemClick: false, + isComponent: true, + targetValue: 100, + maximumValue: 100, + style: "", + conditionalStyles: [], + isFormula: false, + formula: "" + }, + { + name: "F1_D", + title: "F1_D", + dataField: "F1_D", + aggregation: "Count", + dataType: "integer", + visible: "Never", + picture: "ZZZZZZZZZZZZZZ9", + raiseItemClick: false, + isComponent: true, + targetValue: 100, + maximumValue: 100, + style: "", + conditionalStyles: [], + isFormula: false, + formula: "" } ] }, Data: { - "rows": [ + rows: [ { - "F1": "72.3845", - "F1_N": "14476.9", - "F1_D": "200" + F1: "72.3845", + F1_N: "202400000000123.797", + F1_D: "200" } ] } @@ -715,364 +715,364 @@ const serviceResponseChartMock = { MetaData: { - "textForNullValues": "", - "axes": [ - { - "name": "Element4", - "title": "Name", - "dataField": "F1", - "dataType": "character", - "visible": "Yes", - "axis": "Rows", - "canDragToPages": true, - "raiseItemClick": true, - "isComponent": false, - "style": "", - "subtotals": "Yes", - "filter": { - "type": "ShowAllValues", - "values": [] - }, - "expandCollapse": { - "type": "ExpandAllValues", - "values": [] - }, - "order": { - "type": "None", - "values": [] - }, - "valuesStyles": [] - } + textForNullValues: "", + axes: [ + { + name: "Element4", + title: "Name", + dataField: "F1", + dataType: "character", + visible: "Yes", + axis: "Rows", + canDragToPages: true, + raiseItemClick: true, + isComponent: false, + style: "", + subtotals: "Yes", + filter: { + type: "ShowAllValues", + values: [] + }, + expandCollapse: { + type: "ExpandAllValues", + values: [] + }, + order: { + type: "None", + values: [] + }, + valuesStyles: [] + } ], - "data": [ - { - "name": "Element5", - "title": "Population", - "dataField": "F2", - "aggregation": "", - "dataType": "integer", - "visible": "Yes", - "picture": "ZZZZZZZZZZZZZZ9", - "raiseItemClick": true, - "isComponent": false, - "targetValue": 100, - "maximumValue": 100, - "style": "", - "conditionalStyles": [], - "isFormula": false, - "formula": "" - } + data: [ + { + name: "Element5", + title: "Population", + dataField: "F2", + aggregation: "", + dataType: "integer", + visible: "Yes", + picture: "ZZZZZZZZZZZZZZ9", + raiseItemClick: true, + isComponent: false, + targetValue: 100, + maximumValue: 100, + style: "", + conditionalStyles: [], + isFormula: false, + formula: "" + } ] - }, + }, Data: { - "rows": [ + rows: [ { - "F1": "Rio de Janeiro ", - "F2": "11748000" + F1: "Rio de Janeiro ", + F2: "11748000" }, { - "F1": "Lima ", - "F2": "8012000" + F1: "Lima ", + F2: "8012000" }, { - "F1": "Belo Horizonte ", - "F2": "5575000" + F1: "Belo Horizonte ", + F2: "5575000" }, { - "F1": "Porto Alegre ", - "F2": "3917000" + F1: "Porto Alegre ", + F2: "3917000" }, { - "F1": "Brasilia ", - "F2": "3716996" + F1: "Brasilia ", + F2: "3716996" }, { - "F1": "Recife ", - "F2": "3651000" + F1: "Recife ", + F2: "3651000" }, { - "F1": "Salvador ", - "F2": "3484000" + F1: "Salvador ", + F2: "3484000" }, { - "F1": "Medellin ", - "F2": "3297000" + F1: "Medellin ", + F2: "3297000" }, { - "F1": "Caracas ", - "F2": "2985000" + F1: "Caracas ", + F2: "2985000" }, { - "F1": "Guayaquil ", - "F2": "2514000" + F1: "Guayaquil ", + F2: "2514000" }, { - "F1": "Cali ", - "F2": "2254000" + F1: "Cali ", + F2: "2254000" }, { - "F1": "Santa Cruz ", - "F2": "2102998" + F1: "Santa Cruz ", + F2: "2102998" }, { - "F1": "Maracaibo ", - "F2": "2072000" + F1: "Maracaibo ", + F2: "2072000" }, { - "F1": "Valencia ", - "F2": "1770000" + F1: "Valencia ", + F2: "1770000" }, { - "F1": "Manaus ", - "F2": "1753000" + F1: "Manaus ", + F2: "1753000" }, { - "F1": "Quito ", - "F2": "1701000" + F1: "Quito ", + F2: "1701000" }, { - "F1": "La Paz ", - "F2": "1590000" + F1: "La Paz ", + F2: "1590000" }, { - "F1": "Montevideo ", - "F2": "1513000" + F1: "Montevideo ", + F2: "1513000" }, { - "F1": "Rosario ", - "F2": "1203000" + F1: "Rosario ", + F2: "1203000" }, { - "F1": "Maceio ", - "F2": "1186000" + F1: "Maceio ", + F2: "1186000" }, { - "F1": "Natal ", - "F2": "1088000" + F1: "Natal ", + F2: "1088000" }, { - "F1": "Florianopolis ", - "F2": "1023000" + F1: "Florianopolis ", + F2: "1023000" }, { - "F1": "Mendoza ", - "F2": "893000" + F1: "Mendoza ", + F2: "893000" }, { - "F1": "Arequipa ", - "F2": "815000" + F1: "Arequipa ", + F2: "815000" }, { - "F1": "Cuiaba ", - "F2": "806000" + F1: "Cuiaba ", + F2: "806000" }, { - "F1": "Campo Grande ", - "F2": "778000" + F1: "Campo Grande ", + F2: "778000" }, { - "F1": "Trujillo ", - "F2": "765171" + F1: "Trujillo ", + F2: "765171" }, { - "F1": "Uberlandia ", - "F2": "563536" + F1: "Uberlandia ", + F2: "563536" }, { - "F1": "Salta ", - "F2": "512686" + F1: "Salta ", + F2: "512686" }, { - "F1": "Santa Fe ", - "F2": "489505" + F1: "Santa Fe ", + F2: "489505" }, { - "F1": "Feira de Santana ", - "F2": "481911" + F1: "Feira de Santana ", + F2: "481911" }, { - "F1": "Iquitos ", - "F2": "458729" + F1: "Iquitos ", + F2: "458729" }, { - "F1": "San Juan ", - "F2": "447048" + F1: "San Juan ", + F2: "447048" }, { - "F1": "Piura ", - "F2": "396932" + F1: "Piura ", + F2: "396932" }, { - "F1": "Caxias do Sul ", - "F2": "381270" + F1: "Caxias do Sul ", + F2: "381270" }, { - "F1": "Manizales ", - "F2": "375848" + F1: "Manizales ", + F2: "375848" }, { - "F1": "Cusco ", - "F2": "361182" + F1: "Cusco ", + F2: "361182" }, { - "F1": "Posadas ", - "F2": "357119" + F1: "Posadas ", + F2: "357119" }, { - "F1": "Chimbote ", - "F2": "349846" + F1: "Chimbote ", + F2: "349846" }, { - "F1": "Montes Claros ", - "F2": "332379" + F1: "Montes Claros ", + F2: "332379" }, { - "F1": "Pelotas ", - "F2": "320674" + F1: "Pelotas ", + F2: "320674" }, { - "F1": "Pucallpa ", - "F2": "310750" + F1: "Pucallpa ", + F2: "310750" }, { - "F1": "Antofagasta ", - "F2": "309832" + F1: "Antofagasta ", + F2: "309832" }, { - "F1": "Vitoria da Conquista ", - "F2": "308204" + F1: "Vitoria da Conquista ", + F2: "308204" }, { - "F1": "Cuenca ", - "F2": "286878" + F1: "Cuenca ", + F2: "286878" }, { - "F1": "Tacna ", - "F2": "280098" + F1: "Tacna ", + F2: "280098" }, { - "F1": "Ica ", - "F2": "279420" + F1: "Ica ", + F2: "279420" }, { - "F1": "Georgetown ", - "F2": "264350" + F1: "Georgetown ", + F2: "264350" }, { - "F1": "Petrolina ", - "F2": "260985" + F1: "Petrolina ", + F2: "260985" }, { - "F1": "Rio Branco ", - "F2": "257642" + F1: "Rio Branco ", + F2: "257642" }, { - "F1": "Paramaribo ", - "F2": "254169" + F1: "Paramaribo ", + F2: "254169" }, { - "F1": "Boa Vista ", - "F2": "235150" + F1: "Boa Vista ", + F2: "235150" }, { - "F1": "Sucre ", - "F2": "224838" + F1: "Sucre ", + F2: "224838" }, { - "F1": "Formosa ", - "F2": "221383" + F1: "Formosa ", + F2: "221383" }, { - "F1": "Arica ", - "F2": "185999" + F1: "Arica ", + F2: "185999" }, { - "F1": "Puerto Montt ", - "F2": "174629" + F1: "Puerto Montt ", + F2: "174629" }, { - "F1": "Tarija ", - "F2": "159269" + F1: "Tarija ", + F2: "159269" }, { - "F1": "Barreiras ", - "F2": "158292" + F1: "Barreiras ", + F2: "158292" }, { - "F1": "La Serena ", - "F2": "154521" + F1: "La Serena ", + F2: "154521" }, { - "F1": "Comodoro Rivadavia ", - "F2": "140850" + F1: "Comodoro Rivadavia ", + F2: "140850" }, { - "F1": "Copiapo ", - "F2": "129280" + F1: "Copiapo ", + F2: "129280" }, { - "F1": "Santa Rosa ", - "F2": "111424" + F1: "Santa Rosa ", + F2: "111424" }, { - "F1": "Corumba ", - "F2": "96520" + F1: "Corumba ", + F2: "96520" }, { - "F1": "Rio Gallegos ", - "F2": "85700" + F1: "Rio Gallegos ", + F2: "85700" }, { - "F1": "Trinidad ", - "F2": "84259" + F1: "Trinidad ", + F2: "84259" }, { - "F1": "Riberalta ", - "F2": "74014" + F1: "Riberalta ", + F2: "74014" }, { - "F1": "Leticia ", - "F2": "59575" + F1: "Leticia ", + F2: "59575" }, { - "F1": "Cruzeiro do Sul ", - "F2": "56862" + F1: "Cruzeiro do Sul ", + F2: "56862" }, { - "F1": "Puerto Ayacucho ", - "F2": "52526" + F1: "Puerto Ayacucho ", + F2: "52526" }, { - "F1": "Alta Floresta ", - "F2": "40466" + F1: "Alta Floresta ", + F2: "40466" }, { - "F1": "Durazno ", - "F2": "34037" + F1: "Durazno ", + F2: "34037" }, { - "F1": "Cottica ", - "F2": "29210" + F1: "Cottica ", + F2: "29210" }, { - "F1": "Colider ", - "F2": "27139" + F1: "Colider ", + F2: "27139" }, { - "F1": "Rawson ", - "F2": "26335" + F1: "Rawson ", + F2: "26335" }, { - "F1": "Alvorada ", - "F2": "10232" + F1: "Alvorada ", + F2: "10232" }, { - "F1": "El Calafate ", - "F2": "8000" + F1: "El Calafate ", + F2: "8000" }, { - "F1": "Puerto Deseado ", - "F2": "3305" + F1: "Puerto Deseado ", + F2: "3305" } ] } @@ -1080,25 +1080,23 @@ const queryViewers = document.querySelectorAll("gx-query-viewer"); + // Card + queryViewers[0].serviceResponse = serviceResponseCardMock; - // Card - queryViewers[0].serviceResponse = serviceResponseCardMock; - - // Chart - queryViewers[1].serviceResponse = serviceResponseChartMock; - queryViewers[2].serviceResponse = serviceResponseChartMock; - queryViewers[3].serviceResponse = serviceResponseChartMock; + // Chart + queryViewers[1].serviceResponse = serviceResponseChartMock; + queryViewers[2].serviceResponse = serviceResponseChartMock; + queryViewers[3].serviceResponse = serviceResponseChartMock; - document - .querySelector("gx-query-viewer-slider") - .addEventListener("change", event => { - console.log("Slider new value:", event.detail); - }); + document + .querySelector("gx-query-viewer-slider") + .addEventListener("change", event => { + console.log("Slider new value:", event.detail); + }); });
-