Stacked Line with LineMarker

The sample shows stacked line chart with symbols and line marker

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as chart from '@grapecity/wijmo.chart'; import * as animation from '@grapecity/wijmo.chart.animation'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let linechart = new chart.FlexChart('#chart', { legend: { position: chart.Position.Bottom }, stacking: chart.Stacking.Stacked, chartType: chart.ChartType.LineSymbols, bindingX: 'year', tooltip: { content: '' }, series: [ { binding: 'africa', name: 'Africa' }, { binding: 'asia', name: 'Asia' }, { binding: 'europe', name: 'Europe' }, { binding: 'southAmerica', name: 'South America' }, { binding: 'northAmerica', name: 'North America' }, { binding: 'oceania', name: 'Oceania' } ], axisY: { title: 'Populations(in millions)' }, itemsSource: getData(), palette: getRandomPalette() }); // let ani = new animation.ChartAnimation(linechart); // // add a LineMarker var lm = new chart.LineMarker(linechart, { isVisible: false, lines: 'Both', interaction: 'Move', content: (ht) => { if (ht.item) { let s = `<b>Poplations(in millions)</b></br>Year: ${ht.item.year}`; for (let key in ht.item) { if (key !== 'year') { s += `</br> ${key}: ${ht.item[key]}`; } } return s; } else { return 'No items here...'; } } }); // // show the marker when the mouse is over the chart linechart.addEventListener(linechart.hostElement, 'mouseenter', function () { lm.isVisible = true; }); // linechart.addEventListener(linechart.hostElement, 'mouseleave', function () { lm.isVisible = false; }); } // function getRandomPalette() { let palettes = Object.getOwnPropertyNames(chart.Palettes) .filter(prop => typeof chart.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return chart.Palettes[palettes[rand]]; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Stacked Line with LineMarker</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <div id="chart"></div> </div> </body> </html> // World Population // https://en.wikipedia.org/wiki/World_population export function getData() { return [ { year: '1950', africa: 229, asia: 1394, europe: 549, southAmerica: 169, northAmerica: 172, oceania: 12.7 }, { year: '1955', africa: 254, asia: 1534, europe: 577, southAmerica: 193, northAmerica: 187, oceania: 14.2 }, { year: '1960', africa: 285, asia: 1687, europe: 606, southAmerica: 221, northAmerica: 204, oceania: 15.8 }, { year: '1965', africa: 322, asia: 1875, europe: 635, southAmerica: 254, northAmerica: 219, oceania: 17.5 }, { year: '1970', africa: 366, asia: 2120, europe: 657, southAmerica: 288, northAmerica: 231, oceania: 19.7 }, { year: '1975', africa: 416, asia: 2378, europe: 677, southAmerica: 326, northAmerica: 242, oceania: 21.5 }, { year: '1980', africa: 478, asia: 2626, europe: 694, southAmerica: 365, northAmerica: 254, oceania: 23 }, { year: '1985', africa: 550, asia: 2897, europe: 708, southAmerica: 406, northAmerica: 267, oceania: 24.9 }, { year: '1990', africa: 632, asia: 3202, europe: 721, southAmerica: 447, northAmerica: 281, oceania: 27 }, { year: '1995', africa: 720, asia: 3475, europe: 728, southAmerica: 487, northAmerica: 296, oceania: 29.1 }, { year: '2000', africa: 814, asia: 3714, europe: 726, southAmerica: 527, northAmerica: 314, oceania: 31.1 }, { year: '2005', africa: 920, asia: 3945, europe: 729, southAmerica: 564, northAmerica: 329, oceania: 33.4 }, { year: '2010', africa: 1044, asia: 4170, europe: 735, southAmerica: 600, northAmerica: 344, oceania: 36.4 }, { year: '2015', africa: 1196, asia: 4393, europe: 738, southAmerica: 634, northAmerica: 358, oceania: 39.3 } ]; } body { margin-bottom: 24px; } .wj-flexchart .wj-chart-linemarker { background: transparent; } .wj-chart-linemarker-content { padding: 12px; margin: 6px; background: white; border-radius: 3px; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); } .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-hline, .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-vline { height: 1px; width: 1px; opacity: .5; background: navy; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as chart from '@grapecity/wijmo.chart'; import { Component, Inject, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjChartModule } from '@grapecity/wijmo.angular2.chart'; import { WjChartAnimationModule } from '@grapecity/wijmo.angular2.chart.animation'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any; palette: string[]; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); this.palette = this._getRandomPalette(); } // getMarkerContent(ht: chart.HitTestInfo) { if (ht.item) { let s = `<b>Poplations(in millions)</b></br>Year: ${ht.item.year}`; for (let key in ht.item) { if (key !== 'year') { s += `</br> ${key}: ${ht.item[key]}`; } } return s; } else { return 'No items here...'; } } // private _getRandomPalette() { let palettes = Object.getOwnPropertyNames(chart.Palettes) .filter(prop => typeof chart.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return chart.Palettes[palettes[rand]]; } } // @NgModule({ imports: [WjChartModule, WjChartAnimationModule, BrowserModule], declarations: [AppComponent], providers: [DataService], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Line with LineMarker</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <wj-flex-chart [itemsSource]="data" [tooltipContent]="''" [bindingX]="'year'" [palette]="palette" [chartType]="'LineSymbols'" [stacking]="'Stacked'" (mouseenter)="lineMarker.isVisible = true" (mouseleave)="lineMarker.isVisible = false"> <wj-flex-chart-legend [position]="'Bottom'"></wj-flex-chart-legend> <wj-flex-chart-axis [wjProperty]="'axisY'" [title]="'Populations(in millions)'"></wj-flex-chart-axis> <wj-flex-chart-series [binding]="'africa'" [name]="'Africa'"></wj-flex-chart-series> <wj-flex-chart-series [binding]="'asia'" [name]="'Asia'"></wj-flex-chart-series> <wj-flex-chart-series [binding]="'europe'" [name]="'Europe'"></wj-flex-chart-series> <wj-flex-chart-series [binding]="'southAmerica'" [name]="'South America'"></wj-flex-chart-series> <wj-flex-chart-series [binding]="'northAmerica'" [name]="'North America'"></wj-flex-chart-series> <wj-flex-chart-series [binding]="'oceania'" [name]="'Oceania'"></wj-flex-chart-series> <wj-flex-line-marker #lineMarker [isVisible]="false" [lines]="'Both'" [interaction]="'Move'" [content]="getMarkerContent"> </wj-flex-line-marker> <wj-flex-chart-animation></wj-flex-chart-animation> </wj-flex-chart> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { getData() { return [ { year: '1950', africa: 229, asia: 1394, europe: 549, southAmerica: 169, northAmerica: 172, oceania: 12.7 }, { year: '1955', africa: 254, asia: 1534, europe: 577, southAmerica: 193, northAmerica: 187, oceania: 14.2 }, { year: '1960', africa: 285, asia: 1687, europe: 606, southAmerica: 221, northAmerica: 204, oceania: 15.8 }, { year: '1965', africa: 322, asia: 1875, europe: 635, southAmerica: 254, northAmerica: 219, oceania: 17.5 }, { year: '1970', africa: 366, asia: 2120, europe: 657, southAmerica: 288, northAmerica: 231, oceania: 19.7 }, { year: '1975', africa: 416, asia: 2378, europe: 677, southAmerica: 326, northAmerica: 242, oceania: 21.5 }, { year: '1980', africa: 478, asia: 2626, europe: 694, southAmerica: 365, northAmerica: 254, oceania: 23 }, { year: '1985', africa: 550, asia: 2897, europe: 708, southAmerica: 406, northAmerica: 267, oceania: 24.9 }, { year: '1990', africa: 632, asia: 3202, europe: 721, southAmerica: 447, northAmerica: 281, oceania: 27 }, { year: '1995', africa: 720, asia: 3475, europe: 728, southAmerica: 487, northAmerica: 296, oceania: 29.1 }, { year: '2000', africa: 814, asia: 3714, europe: 726, southAmerica: 527, northAmerica: 314, oceania: 31.1 }, { year: '2005', africa: 920, asia: 3945, europe: 729, southAmerica: 564, northAmerica: 329, oceania: 33.4 }, { year: '2010', africa: 1044, asia: 4170, europe: 735, southAmerica: 600, northAmerica: 344, oceania: 36.4 }, { year: '2015', africa: 1196, asia: 4393, europe: 738, southAmerica: 634, northAmerica: 358, oceania: 39.3 } ]; } } body { margin-bottom: 24px; } .wj-flexchart .wj-chart-linemarker { background: transparent; } .wj-chart-linemarker-content { padding: 12px; margin: 6px; background: white; border-radius: 3px; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); } .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-hline, .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-vline { height: 1px; width: 1px; opacity: .5; background: navy; } <template> <div class="container-fluid"> <wj-flex-chart :itemsSource="data" tooltipContent="" bindingX="year" :palette="palette" chartType="LineSymbols" stacking="Stacked" :initialized="onChartInitialized"> <wj-flex-chart-legend position="Bottom"></wj-flex-chart-legend> <wj-flex-chart-axis wjProperty="axisY" title="Populations(in millions)"></wj-flex-chart-axis> <wj-flex-chart-series binding="africa" name="Africa"></wj-flex-chart-series> <wj-flex-chart-series binding="asia" name="Asia"></wj-flex-chart-series> <wj-flex-chart-series binding="europe" name="Europe"></wj-flex-chart-series> <wj-flex-chart-series binding="southAmerica" name="South America"></wj-flex-chart-series> <wj-flex-chart-series binding="northAmerica" name="North America"></wj-flex-chart-series> <wj-flex-chart-series binding="oceania" name="Oceania"></wj-flex-chart-series> <wj-flex-chart-line-marker :isVisible="showMarker" lines="Both" interaction="Move" :content="getMarkerContent"> </wj-flex-chart-line-marker> <wj-flex-chart-animation></wj-flex-chart-animation> </wj-flex-chart> </div> </template> <script> import '@grapecity/wijmo.styles/wijmo.css'; import 'bootstrap.css'; import Vue from 'vue'; import * as wjChart from '@grapecity/wijmo.chart'; import '@grapecity/wijmo.vue2.chart'; import '@grapecity/wijmo.vue2.chart.animation'; import { getData } from './data'; // new Vue({ el: '#app', data: { data: getData(), showMarker: false, // Get random palette palette: this.palette = (() => { let palettes = Object.getOwnPropertyNames(wjChart.Palettes) .filter(prop => typeof wjChart.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return wjChart.Palettes[palettes[rand]]; })() }, methods: { onChartInitialized(sender) { sender.hostElement.addEventListener('mouseenter', () => this.showMarker = true); sender.hostElement.addEventListener('mouseleave', () => this.showMarker = false); }, getMarkerContent(ht) { if (ht.item) { let s = `<b>Poplations(in millions)</b></br>Year: ${ht.item.year}`; for (let key in ht.item) { if (key !== 'year') { s += `</br> ${key}: ${ht.item[key]}`; } } return s; } else { return 'No items here...'; } } } }); </script> <style> body { margin-bottom: 24px; } .container-fluid .wj-flexchart .wj-chart-linemarker { background: transparent; } .container-fluid .wj-chart-linemarker-content { padding: 12px; margin: 6px; background: white; border-radius: 3px; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); } .container-fluid .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-hline, .container-fluid .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-vline { height: 1px; width: 1px; opacity: .5; background: navy; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Stacked Line with LineMarker</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"></div> </body> </html> // World Population // https://en.wikipedia.org/wiki/World_population export function getData() { return [ { year: '1950', africa: 229, asia: 1394, europe: 549, southAmerica: 169, northAmerica: 172, oceania: 12.7 }, { year: '1955', africa: 254, asia: 1534, europe: 577, southAmerica: 193, northAmerica: 187, oceania: 14.2 }, { year: '1960', africa: 285, asia: 1687, europe: 606, southAmerica: 221, northAmerica: 204, oceania: 15.8 }, { year: '1965', africa: 322, asia: 1875, europe: 635, southAmerica: 254, northAmerica: 219, oceania: 17.5 }, { year: '1970', africa: 366, asia: 2120, europe: 657, southAmerica: 288, northAmerica: 231, oceania: 19.7 }, { year: '1975', africa: 416, asia: 2378, europe: 677, southAmerica: 326, northAmerica: 242, oceania: 21.5 }, { year: '1980', africa: 478, asia: 2626, europe: 694, southAmerica: 365, northAmerica: 254, oceania: 23 }, { year: '1985', africa: 550, asia: 2897, europe: 708, southAmerica: 406, northAmerica: 267, oceania: 24.9 }, { year: '1990', africa: 632, asia: 3202, europe: 721, southAmerica: 447, northAmerica: 281, oceania: 27 }, { year: '1995', africa: 720, asia: 3475, europe: 728, southAmerica: 487, northAmerica: 296, oceania: 29.1 }, { year: '2000', africa: 814, asia: 3714, europe: 726, southAmerica: 527, northAmerica: 314, oceania: 31.1 }, { year: '2005', africa: 920, asia: 3945, europe: 729, southAmerica: 564, northAmerica: 329, oceania: 33.4 }, { year: '2010', africa: 1044, asia: 4170, europe: 735, southAmerica: 600, northAmerica: 344, oceania: 36.4 }, { year: '2015', africa: 1196, asia: 4393, europe: 738, southAmerica: 634, northAmerica: 358, oceania: 39.3 } ]; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './app.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as wjChart from '@grapecity/wijmo.react.chart'; import * as wjCharts from '@grapecity/wijmo.chart'; import * as wjChartAnimate from '@grapecity/wijmo.react.chart.animation'; import { getData } from './data'; // class App extends React.Component { constructor(props) { super(props); this._getRandomPalette = () => { let palettes = Object.getOwnPropertyNames(wjCharts.Palettes) .filter(prop => typeof wjCharts.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return wjCharts.Palettes[palettes[rand]]; }; this.onChartInitialized = (sender) => { sender.hostElement.addEventListener('mouseenter', () => this.setState({ showMarker: true })); sender.hostElement.addEventListener('mouseleave', () => this.setState({ showMarker: false })); }; this.getMarkerContent = (ht) => { if (ht.item) { let s = `<b>Poplations(in millions)</b></br>Year: ${ht.item.year}`; for (let key in ht.item) { if (key !== 'year') { s += `</br> ${key}: ${ht.item[key]}`; } } return s; } else { return 'No items here...'; } }; this.state = { data: getData(), showMarker: false, // Get random palette palette: this._getRandomPalette() }; } render() { return <div className="container-fluid"> <wjChart.FlexChart itemsSource={this.state.data} tooltipContent="" bindingX="year" palette={this.state.palette} chartType="LineSymbols" stacking="Stacked" initialized={this.onChartInitialized}> <wjChart.FlexChartLegend position="Bottom"></wjChart.FlexChartLegend> <wjChart.FlexChartAxis wjProperty="axisY" title="Populations(in millions)"></wjChart.FlexChartAxis> <wjChart.FlexChartSeries binding="africa" name="Africa"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries binding="asia" name="Asia"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries binding="europe" name="Europe"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries binding="southAmerica" name="South America"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries binding="northAmerica" name="North America"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries binding="oceania" name="Oceania"></wjChart.FlexChartSeries> <wjChart.FlexChartLineMarker isVisible={this.state.showMarker} lines="Both" interaction="Move" content={this.getMarkerContent}> </wjChart.FlexChartLineMarker> <wjChartAnimate.FlexChartAnimation></wjChartAnimate.FlexChartAnimation> </wjChart.FlexChart> </div>; } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AutoComplete</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> body { margin-bottom: 24px; } .wj-flexchart .wj-chart-linemarker { background: transparent; } .wj-chart-linemarker-content { padding: 12px; margin: 6px; background: white; border-radius: 3px; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); } .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-hline, .wj-flexchart .wj-chart-linemarker .wj-chart-linemarker-vline { height: 1px; width: 1px; opacity: .5; background: navy; } export function getData() { return [ { year: '1950', africa: 229, asia: 1394, europe: 549, southAmerica: 169, northAmerica: 172, oceania: 12.7 }, { year: '1955', africa: 254, asia: 1534, europe: 577, southAmerica: 193, northAmerica: 187, oceania: 14.2 }, { year: '1960', africa: 285, asia: 1687, europe: 606, southAmerica: 221, northAmerica: 204, oceania: 15.8 }, { year: '1965', africa: 322, asia: 1875, europe: 635, southAmerica: 254, northAmerica: 219, oceania: 17.5 }, { year: '1970', africa: 366, asia: 2120, europe: 657, southAmerica: 288, northAmerica: 231, oceania: 19.7 }, { year: '1975', africa: 416, asia: 2378, europe: 677, southAmerica: 326, northAmerica: 242, oceania: 21.5 }, { year: '1980', africa: 478, asia: 2626, europe: 694, southAmerica: 365, northAmerica: 254, oceania: 23 }, { year: '1985', africa: 550, asia: 2897, europe: 708, southAmerica: 406, northAmerica: 267, oceania: 24.9 }, { year: '1990', africa: 632, asia: 3202, europe: 721, southAmerica: 447, northAmerica: 281, oceania: 27 }, { year: '1995', africa: 720, asia: 3475, europe: 728, southAmerica: 487, northAmerica: 296, oceania: 29.1 }, { year: '2000', africa: 814, asia: 3714, europe: 726, southAmerica: 527, northAmerica: 314, oceania: 31.1 }, { year: '2005', africa: 920, asia: 3945, europe: 729, southAmerica: 564, northAmerica: 329, oceania: 33.4 }, { year: '2010', africa: 1044, asia: 4170, europe: 735, southAmerica: 600, northAmerica: 344, oceania: 36.4 }, { year: '2015', africa: 1196, asia: 4393, europe: 738, southAmerica: 634, northAmerica: 358, oceania: 39.3 } ]; }