From 8afb8d071f4417ae24817669e41c950ab5139a3d Mon Sep 17 00:00:00 2001 From: Rohan Dey Date: Fri, 9 Aug 2019 11:38:43 +0530 Subject: [PATCH 1/2] TimeSeries Data update fix --- package-lock.json | 326 +++++++++--------- package.json | 2 +- .../src/fusioncharts.component.ts | 18 +- src/app/fusioncharts/ex32/ex32.ts | 31 +- src/app/fusiontime/fusiontime.html | 26 +- src/app/fusiontime/fusiontime.ts | 171 +++++---- 6 files changed, 316 insertions(+), 258 deletions(-) diff --git a/package-lock.json b/package-lock.json index b92fea6..1e5bde3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "angular-fusioncharts", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -188,6 +188,148 @@ "tsickle": "^0.21.0" } }, + "@babel/runtime": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.5.tgz", + "integrity": "sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", + "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", + "dev": true + } + } + }, + "@fusioncharts/charts": { + "version": "3.14.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/charts/-/charts-3.14.0-sr.1.tgz", + "integrity": "sha512-EPqSY8RSH2V/7/RWv+6IR+PkBakLusmu752dyM0IZQkmoCWBOZe3d8aIN38oMN3HAEwmAaanLaNtJOvyyXEQnA==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/core": "^1.0.0-sr.1", + "@fusioncharts/features": "^1.0.0-sr.1", + "@fusioncharts/utils": "^1.0.0-sr.1" + } + }, + "@fusioncharts/constructor": { + "version": "1.0.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/constructor/-/constructor-1.0.0-sr.1.tgz", + "integrity": "sha512-V/AevMfcWuD+n7JkyBHnB9Vqh9zqcbPBcQWxnxiZT4/iw4uWkajwuuDkr0BK+AuHSCW1yYtEhxnSQZCAJsSr2Q==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/core": "^1.0.0-sr.1", + "@fusioncharts/maps": "^3.14.0-sr.1" + } + }, + "@fusioncharts/core": { + "version": "1.0.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/core/-/core-1.0.0-sr.1.tgz", + "integrity": "sha512-XSAnyTDg3MdYnPMQ3r7C6lFR8nuKPsLdhicV3tIob2R1y+6xR0B0mK60vfmTEKc8oHAZMzQESub/cTGRTu8OHQ==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/utils": "^1.0.0-sr.1", + "core-js": "^3.0.1", + "ramda": "^0.25.0" + }, + "dependencies": { + "core-js": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.0.tgz", + "integrity": "sha512-gybgLzmr7SQRSF6UzGYXducx4eE10ONQlyEnQoqiGPbmbn7zLkb73tPfc4YbZN0lvcTQwoLNPjq4RuCaCumGyQ==", + "dev": true + } + } + }, + "@fusioncharts/datatable": { + "version": "1.0.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/datatable/-/datatable-1.0.0-sr.1.tgz", + "integrity": "sha512-C+iAsfHC1FoDUQBkmnvEcqXWLlPrguLyCb5MovYfmNH0AbAaQqBTwU2cY1vaXdJQh0+tupHZUxXtXuU3HC2aNA==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/utils": "^1.0.0-sr.1" + } + }, + "@fusioncharts/features": { + "version": "1.0.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/features/-/features-1.0.0-sr.1.tgz", + "integrity": "sha512-MJ8TKWUginb5gySGYnvBc/9gP6X/jYgmS1jS/Zd9nTRJU7h5QnCyoNl0Gywiw7H/wnNjIOlWXRCnnyONOvuGxw==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/core": "^1.0.0-sr.1" + } + }, + "@fusioncharts/fusiontime": { + "version": "1.2.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/fusiontime/-/fusiontime-1.2.0-sr.1.tgz", + "integrity": "sha512-2d6y6yAZQ/fcUzYY/L48XFR+3LZT4UpBWdXyyh6+fPMThJSos4Q/Mgey6/JarKAYEMf9gjkBCUq2Pr+8xZ7k0g==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/charts": "^3.14.0-sr.1", + "@fusioncharts/core": "^1.0.0-sr.1", + "@fusioncharts/datatable": "^1.0.0-sr.1", + "@fusioncharts/utils": "^1.0.0-sr.1", + "ramda": "^0.25.0" + } + }, + "@fusioncharts/maps": { + "version": "3.14.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/maps/-/maps-3.14.0-sr.1.tgz", + "integrity": "sha512-/OWlvAkmmbbiyCq2FUK8ym/Hf33YTqxP/SFFJlMmF4t955l7ElB2A/+nL7aUTP6e7WlEh9AZDlpNnXiDAmSgTw==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/charts": "^3.14.0-sr.1", + "@fusioncharts/core": "^1.0.0-sr.1", + "@fusioncharts/features": "^1.0.0-sr.1" + } + }, + "@fusioncharts/powercharts": { + "version": "3.14.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/powercharts/-/powercharts-3.14.0-sr.1.tgz", + "integrity": "sha512-/Dbou8Ony/Gy3PdlRnvQaVMZqOYLYt2uKB2cA6qkRjyWSZ0TJeFStU3WFgHGAgQKSTn2LzIEIml06W7ywY1iPA==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/charts": "^3.14.0-sr.1", + "@fusioncharts/core": "^1.0.0-sr.1", + "@fusioncharts/utils": "^1.0.0-sr.1" + } + }, + "@fusioncharts/utils": { + "version": "1.0.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/utils/-/utils-1.0.0-sr.1.tgz", + "integrity": "sha512-HDQNh7zZflTV6lm+PKwqVlGp7dp+BY5ZBrYvV7wFIu0yWjTHiXT26VeGEjuL9VpupLLR/Nid/QgCyDe85CFPlw==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "ramda": "^0.25.0" + } + }, + "@fusioncharts/widgets": { + "version": "3.14.0-sr.1", + "resolved": "https://registry.npmjs.org/@fusioncharts/widgets/-/widgets-3.14.0-sr.1.tgz", + "integrity": "sha512-/yBovVUsVWbvsaD1JbMb/WbP7j3YzXc6SW8ZNmyhJ0fF/Y8BkFSBihsiM/vUJEN3LZKAYX1cKzV2bceEjReKcQ==", + "dev": true, + "requires": { + "@babel/runtime": "7.4.5", + "@fusioncharts/charts": "^3.14.0-sr.1", + "@fusioncharts/constructor": "^1.0.0-sr.1", + "@fusioncharts/core": "^1.0.0-sr.1", + "@fusioncharts/features": "^1.0.0-sr.1", + "@fusioncharts/utils": "^1.0.0-sr.1" + } + }, "@ngtools/json-schema": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@ngtools/json-schema/-/json-schema-1.1.0.tgz", @@ -1963,15 +2105,6 @@ "regexpu-core": "^1.0.0" } }, - "css-vendor": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/css-vendor/-/css-vendor-0.3.8.tgz", - "integrity": "sha1-ZCHP0wNM5mT+dnOXL9ARn8KJQfo=", - "dev": true, - "requires": { - "is-in-browser": "^1.0.2" - } - }, "css-what": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz", @@ -3823,24 +3956,23 @@ "dev": true }, "fusioncharts": { - "version": "3.13.3-sr.1", - "resolved": "https://registry.npmjs.org/fusioncharts/-/fusioncharts-3.13.3-sr.1.tgz", - "integrity": "sha512-pkYjfyhacdSicjE/aB8hqMMB01IKvA0iDUzzdJ36crynyrrS1BPVnHF69AlYTPR/qZe9zhnAU6bGkE8h82LgEQ==", + "version": "3.14.0-sr.1", + "resolved": "https://registry.npmjs.org/fusioncharts/-/fusioncharts-3.14.0-sr.1.tgz", + "integrity": "sha512-kjMnxgNQA5M5wNy0E9U0HJa5X7QnfUTExd22o+1ObQAXMsXKMUyxq1syW1pLYqY1d94njTSBn6MyWb8uvufg7A==", "dev": true, "requires": { - "core-js": "2.5.6", - "jss": "9.8.7", - "jss-preset-default": "4.5.0", - "promise-polyfill": "7.1.2", - "ramda": "0.25.0" - }, - "dependencies": { - "core-js": { - "version": "2.5.6", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.6.tgz", - "integrity": "sha512-lQUVfQi0aLix2xpyjrrJEvfuYCqPc/HwmTKsC/VNf8q0zsjX7SQZtp4+oRONN5Tsur9GDETPjj+Ub2iDiGZfSQ==", - "dev": true - } + "@babel/runtime": "7.4.5", + "@fusioncharts/charts": "^3.14.0-sr.1", + "@fusioncharts/constructor": "^1.0.0-sr.1", + "@fusioncharts/core": "^1.0.0-sr.1", + "@fusioncharts/datatable": "^1.0.0-sr.1", + "@fusioncharts/features": "^1.0.0-sr.1", + "@fusioncharts/fusiontime": "^1.2.0-sr.1", + "@fusioncharts/maps": "^3.14.0-sr.1", + "@fusioncharts/powercharts": "^3.14.0-sr.1", + "@fusioncharts/utils": "^1.0.0-sr.1", + "@fusioncharts/widgets": "^3.14.0-sr.1", + "promise-polyfill": "^8.1.3" } }, "gauge": { @@ -4643,12 +4775,6 @@ } } }, - "hyphenate-style-name": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.2.tgz", - "integrity": "sha1-MRYKNpMK2vH8BMYHT360FGXU7Es=", - "dev": true - }, "iconv-lite": { "version": "0.4.23", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", @@ -5010,12 +5136,6 @@ "is-extglob": "^2.1.1" } }, - "is-in-browser": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/is-in-browser/-/is-in-browser-1.1.3.tgz", - "integrity": "sha1-Vv9NtoOgeMYILrldrX3GLh0E+DU=", - "dev": true - }, "is-my-ip-valid": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", @@ -5585,121 +5705,6 @@ } } }, - "jss": { - "version": "9.8.7", - "resolved": "https://registry.npmjs.org/jss/-/jss-9.8.7.tgz", - "integrity": "sha512-awj3XRZYxbrmmrx9LUSj5pXSUfm12m8xzi/VKeqI1ZwWBtQ0kVPTs3vYs32t4rFw83CgFDukA8wKzOE9sMQnoQ==", - "dev": true, - "requires": { - "is-in-browser": "^1.1.3", - "symbol-observable": "^1.1.0", - "warning": "^3.0.0" - }, - "dependencies": { - "symbol-observable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", - "dev": true - } - } - }, - "jss-camel-case": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jss-camel-case/-/jss-camel-case-6.1.0.tgz", - "integrity": "sha512-HPF2Q7wmNW1t79mCqSeU2vdd/vFFGpkazwvfHMOhPlMgXrJDzdj9viA2SaHk9ZbD5pfL63a8ylp4++irYbbzMQ==", - "dev": true, - "requires": { - "hyphenate-style-name": "^1.0.2" - } - }, - "jss-compose": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/jss-compose/-/jss-compose-5.0.0.tgz", - "integrity": "sha512-YofRYuiA0+VbeOw0VjgkyO380sA4+TWDrW52nSluD9n+1FWOlDzNbgpZ/Sb3Y46+DcAbOS21W5jo6SAqUEiuwA==", - "dev": true, - "requires": { - "warning": "^3.0.0" - } - }, - "jss-default-unit": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/jss-default-unit/-/jss-default-unit-8.0.2.tgz", - "integrity": "sha512-WxNHrF/18CdoAGw2H0FqOEvJdREXVXLazn7PQYU7V6/BWkCV0GkmWsppNiExdw8dP4TU1ma1dT9zBNJ95feLmg==", - "dev": true - }, - "jss-expand": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/jss-expand/-/jss-expand-5.3.0.tgz", - "integrity": "sha512-NiM4TbDVE0ykXSAw6dfFmB1LIqXP/jdd0ZMnlvlGgEMkMt+weJIl8Ynq1DsuBY9WwkNyzWktdqcEW2VN0RAtQg==", - "dev": true - }, - "jss-extend": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jss-extend/-/jss-extend-6.2.0.tgz", - "integrity": "sha512-YszrmcB6o9HOsKPszK7NeDBNNjVyiW864jfoiHoMlgMIg2qlxKw70axZHqgczXHDcoyi/0/ikP1XaHDPRvYtEA==", - "dev": true, - "requires": { - "warning": "^3.0.0" - } - }, - "jss-global": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/jss-global/-/jss-global-3.0.0.tgz", - "integrity": "sha512-wxYn7vL+TImyQYGAfdplg7yaxnPQ9RaXY/cIA8hawaVnmmWxDHzBK32u1y+RAvWboa3lW83ya3nVZ/C+jyjZ5Q==", - "dev": true - }, - "jss-nested": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/jss-nested/-/jss-nested-6.0.1.tgz", - "integrity": "sha512-rn964TralHOZxoyEgeq3hXY8hyuCElnvQoVrQwKHVmu55VRDd6IqExAx9be5HgK0yN/+hQdgAXQl/GUrBbbSTA==", - "dev": true, - "requires": { - "warning": "^3.0.0" - } - }, - "jss-preset-default": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/jss-preset-default/-/jss-preset-default-4.5.0.tgz", - "integrity": "sha512-qZbpRVtHT7hBPpZEBPFfafZKWmq3tA/An5RNqywDsZQGrlinIF/mGD9lmj6jGqu8GrED2SMHZ3pPKLmjCZoiaQ==", - "dev": true, - "requires": { - "jss-camel-case": "^6.1.0", - "jss-compose": "^5.0.0", - "jss-default-unit": "^8.0.2", - "jss-expand": "^5.3.0", - "jss-extend": "^6.2.0", - "jss-global": "^3.0.0", - "jss-nested": "^6.0.1", - "jss-props-sort": "^6.0.0", - "jss-template": "^1.0.1", - "jss-vendor-prefixer": "^7.0.0" - } - }, - "jss-props-sort": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/jss-props-sort/-/jss-props-sort-6.0.0.tgz", - "integrity": "sha512-E89UDcrphmI0LzmvYk25Hp4aE5ZBsXqMWlkFXS0EtPkunJkRr+WXdCNYbXbksIPnKlBenGB9OxzQY+mVc70S+g==", - "dev": true - }, - "jss-template": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/jss-template/-/jss-template-1.0.1.tgz", - "integrity": "sha512-m5BqEWha17fmIVXm1z8xbJhY6GFJxNB9H68GVnCWPyGYfxiAgY9WTQyvDAVj+pYRgrXSOfN5V1T4+SzN1sJTeg==", - "dev": true, - "requires": { - "warning": "^3.0.0" - } - }, - "jss-vendor-prefixer": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/jss-vendor-prefixer/-/jss-vendor-prefixer-7.0.0.tgz", - "integrity": "sha512-Agd+FKmvsI0HLcYXkvy8GYOw3AAASBUpsmIRvVQheps+JWaN892uFOInTr0DRydwaD91vSSUCU4NssschvF7MA==", - "dev": true, - "requires": { - "css-vendor": "^0.3.8" - } - }, "jszip": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz", @@ -7730,9 +7735,9 @@ } }, "promise-polyfill": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-7.1.2.tgz", - "integrity": "sha512-FuEc12/eKqqoRYIGBrUptCBRhobL19PS2U31vMNTfyck1FxPyMfgsXyW4Mav85y/ZN1hop3hOwRlUDok23oYfQ==", + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.1.3.tgz", + "integrity": "sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g==", "dev": true }, "protractor": { @@ -10259,15 +10264,6 @@ "matcher-collection": "^1.0.0" } }, - "warning": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", - "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", - "dev": true, - "requires": { - "loose-envify": "^1.0.0" - } - }, "watchpack": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", diff --git a/package.json b/package.json index d6b2b8e..7735bec 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "@types/node": "~6.0.60", "codelyzer": "~3.0.1", "codemirror": "^5.39.2", - "fusioncharts": "^3.13.3-sr.1", + "fusioncharts": "^3.14.0-sr.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "^3.0.0", diff --git a/src/angular-fusioncharts/src/fusioncharts.component.ts b/src/angular-fusioncharts/src/fusioncharts.component.ts index d50f363..bdbe5ab 100644 --- a/src/angular-fusioncharts/src/fusioncharts.component.ts +++ b/src/angular-fusioncharts/src/fusioncharts.component.ts @@ -19,6 +19,7 @@ import { FusionChartsConstructor } from './fusioncharts.constructor'; import FusionChartsEvent from '../interfaces/FusionChartsEvent'; import FusionChartInstance from '../interfaces/FusionChartInstance'; import EventsList from '../events/events'; +let count = 0; @Component({ selector: 'fusioncharts', template: ` @@ -237,6 +238,7 @@ class FusionChartsComponent containerId: string; private configObj: any; private oldDataSource: any = this.dataSource; + private oldDataTable: any; private constructerParams = { type: true, id: true, @@ -345,7 +347,7 @@ class FusionChartsComponent // Edge case handling for DataTable if (prop === 'data') { if (obj[prop]._dataStore) { - clonedObj[prop] = '-'; + clonedObj[prop] = `-${count}`; } else { clonedObj[prop] = this.cloneDataSource(obj[prop]); } @@ -386,15 +388,21 @@ class FusionChartsComponent } else { data = JSON.stringify(this.dataSource); } - if (this.oldDataSource === data) { - } else { - this.updateChartData(); + if ( + this.oldDataSource !== data || + this.oldDataTable !== this.dataSource.data + ) { + this.oldDataTable = this.dataSource && this.dataSource.data; this.oldDataSource = data; + this.updateChartData(); } } updateChartData() { - const dataFormat = this.configObj.dataFormat || 'json', + const dataFormat = + this.configObj && this.configObj.dataFormat + ? this.configObj.dataFormat + : 'json', data = this.dataSource; if (this.chartObj) { diff --git a/src/app/fusioncharts/ex32/ex32.ts b/src/app/fusioncharts/ex32/ex32.ts index 6ba1ad9..1e8c853 100644 --- a/src/app/fusioncharts/ex32/ex32.ts +++ b/src/app/fusioncharts/ex32/ex32.ts @@ -26,19 +26,30 @@ export class Ex32 { this.dataSource = { // Initially data is set as null data: null, + chart: {}, caption: { text: 'Apple Inc. Stock Price' }, - yAxis: { - plot: { - open: 'Open', - high: 'High', - low: 'Low', - close: 'Close', - type: 'candlestick' - }, - title: 'Value' - } + subcaption: { + text: 'Stock prices from January 1980 - November 2011' + }, + yaxis: [ + { + plot: { + value: { + open: 'Open', + high: 'High', + low: 'Low', + close: 'Close' + }, + type: 'candlestick' + }, + format: { + prefix: '$' + }, + title: 'Stock Value' + } + ] }; this.fetchData(); } diff --git a/src/app/fusiontime/fusiontime.html b/src/app/fusiontime/fusiontime.html index dd05c34..fa22e61 100644 --- a/src/app/fusiontime/fusiontime.html +++ b/src/app/fusiontime/fusiontime.html @@ -1,20 +1,10 @@
-
- -
-
- -
+
+ + diff --git a/src/app/fusiontime/fusiontime.ts b/src/app/fusiontime/fusiontime.ts index 1b533ea..dac46e4 100644 --- a/src/app/fusiontime/fusiontime.ts +++ b/src/app/fusiontime/fusiontime.ts @@ -1,5 +1,83 @@ import { Component } from '@angular/core'; import * as FusionCharts from 'fusioncharts'; +const dataUrl = + 'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/plotting-multiple-series-on-time-axis-data.json'; +const schema = [ + { + name: 'Time', + type: 'date', + format: '%d-%b-%y' + }, + { + name: 'Type', + type: 'string' + }, + { + name: 'Sales Value', + type: 'number' + } +]; +const updatedDataSource = [ + ['01-Feb-11', 'Grocery', 8866], + ['01-Feb-11', 'Footwear', 984], + ['02-Feb-11', 'Grocery', 2174], + ['02-Feb-11', 'Footwear', 1109], + ['03-Feb-11', 'Grocery', 2084], + ['03-Feb-11', 'Footwear', 6526], + ['04-Feb-11', 'Grocery', 1503], + ['04-Feb-11', 'Footwear', 1007], + ['05-Feb-11', 'Grocery', 4928], + ['05-Feb-11', 'Footwear', 4112], + ['06-Feb-11', 'Grocery', 4667], + ['06-Feb-11', 'Footwear', 7206], + ['07-Feb-11', 'Grocery', 1064], + ['07-Feb-11', 'Footwear', 7890], + ['08-Feb-11', 'Grocery', 851], + ['08-Feb-11', 'Footwear', 6002], + ['09-Feb-11', 'Grocery', 7326], + ['09-Feb-11', 'Footwear', 5168], + ['10-Feb-11', 'Grocery', 8399], + ['10-Feb-11', 'Footwear', 7992], + ['11-Feb-11', 'Grocery', 4084], + ['11-Feb-11', 'Footwear', 3001], + ['12-Feb-11', 'Grocery', 4012], + ['12-Feb-11', 'Footwear', 7891], + ['13-Feb-11', 'Grocery', 1673], + ['13-Feb-11', 'Footwear', 511], + ['14-Feb-11', 'Grocery', 6018], + ['14-Feb-11', 'Footwear', 1861], + ['15-Feb-11', 'Grocery', 9011], + ['15-Feb-11', 'Footwear', 1424], + ['16-Feb-11', 'Grocery', 5817], + ['16-Feb-11', 'Footwear', 6807], + ['17-Feb-11', 'Grocery', 5813], + ['17-Feb-11', 'Footwear', 4126], + ['18-Feb-11', 'Grocery', 566], + ['18-Feb-11', 'Footwear', 3482], + ['19-Feb-11', 'Grocery', 9065], + ['19-Feb-11', 'Footwear', 5649], + ['20-Feb-11', 'Grocery', 6734], + ['20-Feb-11', 'Footwear', 309], + ['21-Feb-11', 'Grocery', 6937], + ['21-Feb-11', 'Footwear', 6568], + ['22-Feb-11', 'Grocery', 3038], + ['22-Feb-11', 'Footwear', 2458], + ['23-Feb-11', 'Grocery', 4445], + ['23-Feb-11', 'Footwear', 356], + ['24-Feb-11', 'Grocery', 8782], + ['24-Feb-11', 'Footwear', 5883], + ['25-Feb-11', 'Grocery', 9489], + ['25-Feb-11', 'Footwear', 6556], + ['26-Feb-11', 'Grocery', 9624], + ['26-Feb-11', 'Footwear', 1601], + ['27-Feb-11', 'Grocery', 9033], + ['27-Feb-11', 'Footwear', 1359], + ['28-Feb-11', 'Grocery', 6932], + ['28-Feb-11', 'Footwear', 4361], + ['01-Mar-11', 'Grocery', 625], + ['01-Mar-11', 'Footwear', 3807], + ['02-Mar-11', 'Grocery', 904] +]; @Component({ selector: 'fusiontime', @@ -10,78 +88,53 @@ export class FusionTime { type: string; width: string; height: string; - chartNum = 'first'; + constructor() { - this.type = 'column2d'; - this.width = '400'; - this.height = '400'; + this.type = 'timeseries'; + this.width = '600'; + this.height = '500'; this.dataSource = { + data: null, chart: { - caption: 'Countries With Most Oil Reserves [2017-18]', - subCaption: 'In MMbbl = One Million barrels', - xAxisName: 'Country', - yAxisName: 'Reserves (MMbbl)', - numberSuffix: 'K', - theme: 'fusion' + // exportEnabled: 1 }, - data: [ - { - label: 'Venezuela', - value: '290' - }, - { - label: 'Saudi', - value: '260' - }, - { - label: 'Canada', - value: '180' - }, - { - label: 'Iran', - value: '140' - }, - { - label: 'Russia', - value: '115' - }, - { - label: 'UAE', - value: '100' - }, - { - label: 'US', - value: '30' - }, + caption: { + text: 'Online Sales of a SuperStore in India & the US' + }, + yAxis: [ { - label: 'China', - value: '30' + plot: { + value: 'Sales', + type: 'line' + } } ] }; - } - showChart(num) { - this.chartNum = num; + this.fetchData(); + // this.updateMyChartData(); } + fetchData() { + let jsonify = res => res.json(); + let dataFetch = fetch(dataUrl).then(jsonify); - showChart1: boolean; - showChart2: boolean; - - ngOnInit() { - this.showChart1 = true; - setInterval(() => { - this.showChart2 ? this.onShowChart1() : this.onShowChart2(); - }, 30); // Small timeout simulates quick charts switching and causes an error. - } + Promise.all([dataFetch]).then(res => { + let data = res[0]; + let fusionTable = new FusionCharts.DataStore().createDataTable( + data, + schema + ); // Instance of DataTable to be passed as data in dataSource - onShowChart1() { - this.showChart1 = true; - this.showChart2 = false; + this.dataSource.data = fusionTable; + }); } - onShowChart2() { - this.showChart1 = false; - this.showChart2 = true; + updateMyChartData() { + let updatedfusionTable = new FusionCharts.DataStore().createDataTable( + updatedDataSource, + schema + ); + this.dataSource.caption.text = 'HELLLOOO!!!!'; + this.dataSource.data = updatedfusionTable; } } From 698b23ff890395777e657a5af267173b298910f6 Mon Sep 17 00:00:00 2001 From: Rohan Dey Date: Fri, 9 Aug 2019 11:42:51 +0530 Subject: [PATCH 2/2] Removed unused variable --- src/angular-fusioncharts/src/fusioncharts.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/angular-fusioncharts/src/fusioncharts.component.ts b/src/angular-fusioncharts/src/fusioncharts.component.ts index bdbe5ab..a8f8048 100644 --- a/src/angular-fusioncharts/src/fusioncharts.component.ts +++ b/src/angular-fusioncharts/src/fusioncharts.component.ts @@ -19,7 +19,6 @@ import { FusionChartsConstructor } from './fusioncharts.constructor'; import FusionChartsEvent from '../interfaces/FusionChartsEvent'; import FusionChartInstance from '../interfaces/FusionChartInstance'; import EventsList from '../events/events'; -let count = 0; @Component({ selector: 'fusioncharts', template: ` @@ -347,7 +346,7 @@ class FusionChartsComponent // Edge case handling for DataTable if (prop === 'data') { if (obj[prop]._dataStore) { - clonedObj[prop] = `-${count}`; + clonedObj[prop] = `-`; } else { clonedObj[prop] = this.cloneDataSource(obj[prop]); }