- component: `// In app.component.ts\nimport {\n Component,\n NgZone\n} from '@angular/core';\n\n@Component({\n selector: 'app',\n templateUrl: './app.component.html'\n})\nexport class AppComponent {\n dataSource: any;\n datasetname: any;\n startvalue: any;\n finalvalue: any;\n message: any;\n\n // Format message\n getMessage(datasetname, startvalue, finalvalue, label){\n return \`<b style='font-weight:bold';>\${datasetname}</b> dataset, its previous value was <b style='font-weight:bold'>\${startvalue}</b> and its current value is <b style='font-weight:bold'>\${finalvalue}</b> for year \${label}\`;\n }\n\n constructor(private zone: NgZone) {\n this.dataSource = {\n "chart": {\n "caption": "Android and iOS Devices Sales Projections",\n "subCaption": "Drag the top of columns to adjust projections for 2017 & 2018",\n "numberPrefix": "$",\n "numberSuffix": "M",\n "yaxismaxvalue": "200",\n "theme": "fusion",\n "plotToolText": "<b>$label</b><br>$seriesName: <b>$dataValue</b>"\n },\n "categories": [{\n "category": [{\n "label": "2014",\n "fontItalic": "0"\n }, {\n "label": "2015",\n "fontItalic": "0"\n }, {\n "label": "2016",\n "fontItalic": "0"\n }, {\n "label": "2017 (Projected)"\n }, {\n "label": "2018 (Projected)"\n }]\n }],\n "dataset": [{\n "seriesname": "Android Devices",\n "data": [{\n "value": "73",\n "alpha": "100",\n "allowDrag": "0"\n }, {\n "value": "80",\n "alpha": "100",\n "allowDrag": "0"\n }, {\n "value": "97",\n "alpha": "100",\n "allowDrag": "0"\n }, {\n "value": "110",\n "toolText": "<b>$label</b><br>$seriesName: <b>$dataValue</b>"\n }, {\n "value": "180",\n "toolText": "<b>$label</b><br>$seriesName: <b>$dataValue</b>"\n }]\n }, {\n "seriesname": "iOS Devices",\n "data": [{\n "value": "63.2",\n "alpha": "100",\n "allowDrag": "0"\n }, {\n "value": "68",\n "alpha": "100",\n "allowDrag": "0"\n }, {\n "value": "82",\n "alpha": "100",\n "allowDrag": "0"\n }, {\n "value": "99",\n "toolText": "<b>$label</b><br>$seriesName: <b>$dataValue</b>"\n }, {\n "value": "150",\n "toolText": "<b>$label</b><br>$seriesName: <b>$dataValue</b>"\n }]\n }]\n };\n\n this.message = "Drag any column for years 2017 or 2018 to see updated value along with the label";\n }\n\n dragStart($event){\n let dataObj = $event.dataObj;\n this.datasetname = dataObj.datasetName;\n this.startvalue = dataObj.startValue;\n }\n\n dragEnd($event){\n let dataObj = $event.dataObj;\n this.finalvalue = dataObj.endValue;\n let label = this.dataSource.categories[0].category[dataObj.dataIndex].label;\n this.zone.run(() => {\n this.message = this.getMessage(this.datasetname, this.startvalue.toFixed(2), this.finalvalue.toFixed(2), label);\n })\n }\n}\n`,
0 commit comments