Volume Charts

The sample demonstrates ColumnVolume, CandleVolume and EquiVolume charts as 3 stacked plot areas, to demonstrate difference between each.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as core from '@grapecity/wijmo'; import * as chart from '@grapecity/wijmo.chart'; import * as finance from '@grapecity/wijmo.chart.finance'; import * as interaction from '@grapecity/wijmo.chart.interaction'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // create the chart let data = getData(); let theChart = new finance.FinancialChart('#theChart', { itemsSource: data, bindingX: 'date', chartType: 'ColumnVolume', series: [ { binding: 'close,volume', name: 'Column Volume', chartType: 'ColumnVolume' }, { binding: 'high,low,open,close,volume', name: 'Equi Volume', chartType: 'EquiVolume' }, { binding: 'high,low,open,close,volume', name: 'Candle Volume', chartType: 'CandleVolume' }, { binding: 'high,low,open,close,volume', name: 'Arms CandleVolume', chartType: 'ArmsCandleVolume' } ], legend: { position: 'None' }, tooltip: { content: function (ht) { var date = ht.item && ht.item.date ? ht.item.date : null, content = ''; if (core.isDate(date)) { date = core.Globalize.formatDate(date, 'MM/dd/yy'); } if (ht && ht.item) { content = '<b>' + ht.name + '</b><br/>' + 'Date: ' + date + '<br/>' + 'Open: ' + core.Globalize.format(ht.item.open, 'n2') + '<br/>' + 'High: ' + core.Globalize.format(ht.item.high, 'n2') + '<br/>' + 'Low: ' + core.Globalize.format(ht.item.low, 'n2') + '<br/>' + 'Close: ' + core.Globalize.format(ht.item.close, 'n2') + '<br/>' + 'Volume: ' + core.Globalize.format(ht.item.volume, 'n0'); } return content; } } }); theChart.palette = getRandomPalette(); //add plot areas let p0 = new chart.PlotArea(); p0.row = theChart.plotAreas.length; p0.height = 100; theChart.plotAreas.push(p0); let p1 = new chart.PlotArea(); p1.row = theChart.plotAreas.length; p1.height = 100; let axisY1 = new chart.Axis(chart.Position.Left); axisY1.plotArea = p1; theChart.series[1].axisY = axisY1; theChart.plotAreas.push(p1); let p2 = new chart.PlotArea(); p2.row = theChart.plotAreas.length; p2.height = 100; let axisY2 = new chart.Axis(chart.Position.Left); axisY2.plotArea = p2; theChart.series[2].axisY = axisY2; theChart.plotAreas.push(p2); let p3 = new chart.PlotArea(); p3.row = theChart.plotAreas.length; p3.height = 100; let axisY3 = new chart.Axis(chart.Position.Left); axisY3.plotArea = p3; theChart.series[3].axisY = axisY3; theChart.plotAreas.push(p3); // let rsChart = new finance.FinancialChart('#rsChart', { itemsSource: data, bindingX: 'date', chartType: 'ColumnVolume', series: [ { binding: 'close,volume', name: 'Box Inc' } ], axisX: { labels: false }, axisY: { labels: false, majorGrid: false }, tooltip: { content: '' }, legend: { position: 'None' }, rendered: function () { // set range if (rs) { var range = findRange(rsChart.axisX.actualMin, rsChart.axisX.actualMax); rs.min = range.min; rs.max = range.max; } } }); let rs = new interaction.RangeSelector(rsChart, { seamless: true, rangeChanged: function () { // find visible y-range var yRange = findYRange(data, rs.min, rs.max); // update main chart's x & y range theChart.axisX.min = rs.min; theChart.axisX.max = rs.max; [theChart.axisY, axisY1, axisY2, axisY3].forEach(axis => { axis.min = yRange.min; axis.max = yRange.max; }); theChart.invalidate(); } }); } // 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]]; } // helper method to calculate (upper) percentage of total range // the default will show the top 20% of the available range function findRange(min, max, percent) { var pctToShow = core.isNumber(percent) && 0 < percent && percent < 1 ? percent : 0.2, range = { min: NaN, max: NaN }; if (core.isDate(min) && core.isDate(max)) { range.max = max.valueOf(); range.min = (max.valueOf() - min.valueOf()) * (1 - pctToShow) + min.valueOf(); } else if (core.isNumber(min) && core.isNumber(max)) { range.max = max; range.min = (max - min) * (1 - pctToShow) + min; } return range; } // assumes High, Low, Open, Close, and Volume data // also assumes category axis function findYRange(data, xmin, xmax) { var item, i, ymin = null, ymax = null; for (i = 0; i < data.length; i++) { item = data[i]; if (xmin > i || i > xmax) { continue; } if (ymax === null || item.high > ymax) { ymax = item.high; } if (ymin === null || item.low < ymin) { ymin = item.low; } } return { min: ymin, max: ymax }; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Volume Charts</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="theChart"></div> <div id="rsChart"></div> </div> </body> </html> // some stock data from Google Finance export function getData() { return [ { "date": "01/23/15", "open": 20.2, "high": 24.73, "low": 20.16, "close": 23.23, "volume": 42593223 }, { "date": "01/26/15", "open": 23.67, "high": 24.39, "low": 22.5, "close": 22.6, "volume": 8677164 }, { "date": "01/27/15", "open": 22, "high": 22.47, "low": 21.17, "close": 21.3, "volume": 3272512 }, { "date": "01/28/15", "open": 21.62, "high": 21.84, "low": 19.6, "close": 19.78, "volume": 5047364 }, { "date": "01/29/15", "open": 19.9, "high": 19.95, "low": 18.51, "close": 18.8, "volume": 3419482 }, { "date": "01/30/15", "open": 18.47, "high": 19.48, "low": 18.22, "close": 18.81, "volume": 2266439 }, { "date": "02/02/15", "open": 19.18, "high": 19.3, "low": 18.01, "close": 18.02, "volume": 2071168 }, { "date": "02/03/15", "open": 18.22, "high": 18.64, "low": 18.12, "close": 18.24, "volume": 1587435 }, { "date": "02/04/15", "open": 18.2, "high": 18.35, "low": 17, "close": 17.1, "volume": 2912224 }, { "date": "02/05/15", "open": 17.3, "high": 17.31, "low": 16.41, "close": 16.66, "volume": 2682187 }, { "date": "02/06/15", "open": 17.39, "high": 18.88, "low": 17.21, "close": 18.12, "volume": 3929164 }, { "date": "02/09/15", "open": 18.86, "high": 19.95, "low": 18.45, "close": 19.6, "volume": 3226650 }, { "date": "02/10/15", "open": 20.5, "high": 21, "low": 19.63, "close": 20.99, "volume": 2804409 }, { "date": "02/11/15", "open": 20.89, "high": 21, "low": 20.2, "close": 20.96, "volume": 1698365 }, { "date": "02/12/15", "open": 20.66, "high": 20.85, "low": 19.75, "close": 20.17, "volume": 1370320 }, { "date": "02/13/15", "open": 20.19, "high": 20.68, "low": 20, "close": 20.18, "volume": 711951 }, { "date": "02/17/15", "open": 19.5, "high": 20.1, "low": 18.8, "close": 19.05, "volume": 2093602 }, { "date": "02/18/15", "open": 18.31, "high": 18.5, "low": 17.96, "close": 18, "volume": 1849490 }, { "date": "02/19/15", "open": 18.33, "high": 19.25, "low": 17.91, "close": 18.96, "volume": 1311518 }, { "date": "02/20/15", "open": 18.68, "high": 19.3, "low": 18.65, "close": 18.85, "volume": 1001692 }, { "date": "02/23/15", "open": 18.8, "high": 18.89, "low": 18.11, "close": 18.21, "volume": 670087 }, { "date": "02/24/15", "open": 18.46, "high": 19, "low": 18.27, "close": 18.83, "volume": 759263 }, { "date": "02/25/15", "open": 18.83, "high": 19.48, "low": 18.47, "close": 18.67, "volume": 915580 }, { "date": "02/26/15", "open": 18.64, "high": 19.2, "low": 18.64, "close": 18.94, "volume": 461283 }, { "date": "02/27/15", "open": 18.8, "high": 19.12, "low": 18.55, "close": 18.66, "volume": 617199 }, { "date": "03/02/15", "open": 18.66, "high": 19.09, "low": 18.65, "close": 18.79, "volume": 519605 }, { "date": "03/03/15", "open": 18.79, "high": 19.21, "low": 18.45, "close": 18.59, "volume": 832415 }, { "date": "03/04/15", "open": 18.64, "high": 19.05, "low": 18.32, "close": 19, "volume": 539688 }, { "date": "03/05/15", "open": 19.2, "high": 19.2, "low": 18.8, "close": 19.14, "volume": 486149 }, { "date": "03/06/15", "open": 19.03, "high": 19.1, "low": 18.7, "close": 18.91, "volume": 685659 }, { "date": "03/09/15", "open": 18.98, "high": 20.15, "low": 18.96, "close": 19.4, "volume": 1321363 }, { "date": "03/10/15", "open": 19.3, "high": 19.8, "low": 18.85, "close": 19.64, "volume": 615743 }, { "date": "03/11/15", "open": 20.08, "high": 20.65, "low": 19.24, "close": 20.53, "volume": 2167167 }, { "date": "03/12/15", "open": 17.17, "high": 18.2, "low": 16.76, "close": 18.2, "volume": 6837638 }, { "date": "03/13/15", "open": 18.05, "high": 18.05, "low": 17.3, "close": 17.88, "volume": 1715629 }, { "date": "03/16/15", "open": 17.91, "high": 18, "low": 17.01, "close": 17.13, "volume": 1321313 }, { "date": "03/17/15", "open": 17.28, "high": 17.37, "low": 16.6, "close": 17.12, "volume": 1272242 }, { "date": "03/18/15", "open": 17.1, "high": 17.27, "low": 16.91, "close": 17.01, "volume": 530063 }, { "date": "03/19/15", "open": 17, "high": 17.28, "low": 17, "close": 17.06, "volume": 536427 }, { "date": "03/20/15", "open": 17.13, "high": 17.24, "low": 16.88, "close": 17.21, "volume": 1320237 }, { "date": "03/23/15", "open": 17.21, "high": 17.23, "low": 17.01, "close": 17.11, "volume": 509798 }, { "date": "03/24/15", "open": 17.02, "high": 17.18, "low": 16.82, "close": 17, "volume": 962149 }, { "date": "03/25/15", "open": 16.92, "high": 16.99, "low": 16.82, "close": 16.97, "volume": 565673 }, { "date": "03/26/15", "open": 16.83, "high": 17.56, "low": 16.83, "close": 17.54, "volume": 884523 }, { "date": "03/27/15", "open": 17.58, "high": 18.3, "low": 17.11, "close": 18.3, "volume": 705626 }, { "date": "03/30/15", "open": 18.5, "high": 19.4, "low": 18.4, "close": 19.05, "volume": 1151620 }, { "date": "03/31/15", "open": 19.08, "high": 20.58, "low": 18.4, "close": 19.75, "volume": 2020679 }, { "date": "04/01/15", "open": 19.69, "high": 19.69, "low": 18.55, "close": 18.65, "volume": 961078 }, { "date": "04/02/15", "open": 18.56, "high": 18.66, "low": 17.85, "close": 17.9, "volume": 884233 }, { "date": "04/06/15", "open": 17.78, "high": 17.94, "low": 17.51, "close": 17.66, "volume": 605252 }, { "date": "04/07/15", "open": 17.62, "high": 17.9, "low": 17.53, "close": 17.61, "volume": 591988 }, { "date": "04/08/15", "open": 17.64, "high": 17.85, "low": 17.32, "close": 17.36, "volume": 618855 }, { "date": "04/09/15", "open": 17.33, "high": 17.54, "low": 17.1, "close": 17.1, "volume": 761855 }, { "date": "04/10/15", "open": 17.08, "high": 17.36, "low": 17, "close": 17.05, "volume": 568373 }, { "date": "04/13/15", "open": 17.24, "high": 17.26, "low": 16.81, "close": 17.1, "volume": 667142 }, { "date": "04/14/15", "open": 17.1, "high": 17.89, "low": 17.02, "close": 17.52, "volume": 870138 }, { "date": "04/15/15", "open": 17.6, "high": 17.99, "low": 17.5, "close": 17.69, "volume": 530456 }, { "date": "04/16/15", "open": 17.95, "high": 18, "low": 17.6, "close": 17.82, "volume": 548730 }, { "date": "04/17/15", "open": 17.75, "high": 17.79, "low": 17.5, "close": 17.79, "volume": 446373 }, { "date": "04/20/15", "open": 17.63, "high": 17.98, "low": 17.52, "close": 17.93, "volume": 487017 }, { "date": "04/21/15", "open": 17.96, "high": 17.98, "low": 17.71, "close": 17.92, "volume": 320302 }, { "date": "04/22/15", "open": 17.88, "high": 18.33, "low": 17.57, "close": 18.29, "volume": 644812 }, { "date": "04/23/15", "open": 18.29, "high": 18.61, "low": 18.18, "close": 18.28, "volume": 563879 }, { "date": "04/24/15", "open": 18.5, "high": 18.5, "low": 17.61, "close": 17.75, "volume": 650762 }, { "date": "04/27/15", "open": 17.97, "high": 18.05, "low": 17.45, "close": 17.57, "volume": 437294 }, { "date": "04/28/15", "open": 17.65, "high": 17.79, "low": 17.39, "close": 17.5, "volume": 224519 }, { "date": "04/29/15", "open": 17.68, "high": 17.68, "low": 17.1, "close": 17.21, "volume": 495706 }, { "date": "04/30/15", "open": 17.22, "high": 17.3, "low": 17, "close": 17.11, "volume": 391040 }, { "date": "05/01/15", "open": 17.11, "high": 17.55, "low": 16.85, "close": 17.5, "volume": 563075 }, { "date": "05/04/15", "open": 17.56, "high": 17.85, "low": 17.3, "close": 17.4, "volume": 253138 }, { "date": "05/05/15", "open": 17.68, "high": 17.68, "low": 17.09, "close": 17.43, "volume": 290935 }, { "date": "05/06/15", "open": 17.48, "high": 17.48, "low": 17, "close": 17.04, "volume": 313662 }, { "date": "05/07/15", "open": 17.05, "high": 17.19, "low": 16.92, "close": 17.04, "volume": 360284 }, { "date": "05/08/15", "open": 17.13, "high": 17.21, "low": 16.91, "close": 17.1, "volume": 297653 }, { "date": "05/11/15", "open": 17.16, "high": 17.44, "low": 17.13, "close": 17.31, "volume": 268504 }, { "date": "05/12/15", "open": 17.28, "high": 17.44, "low": 16.99, "close": 17.24, "volume": 376961 }, { "date": "05/13/15", "open": 17.24, "high": 17.3, "low": 17.06, "close": 17.2, "volume": 244617 }, { "date": "05/14/15", "open": 17.24, "high": 17.25, "low": 17.02, "close": 17.08, "volume": 252526 }, { "date": "05/15/15", "open": 17.06, "high": 17.16, "low": 16.95, "close": 16.95, "volume": 274783 }, { "date": "05/18/15", "open": 16.95, "high": 17.01, "low": 16.76, "close": 16.87, "volume": 418513 }, { "date": "05/19/15", "open": 16.93, "high": 16.94, "low": 16.6, "close": 16.83, "volume": 367660 }, { "date": "05/20/15", "open": 16.8, "high": 16.9, "low": 16.65, "close": 16.86, "volume": 297914 }, { "date": "05/21/15", "open": 16.9, "high": 17.08, "low": 16.79, "close": 16.88, "volume": 229346 }, { "date": "05/22/15", "open": 16.9, "high": 17.05, "low": 16.85, "close": 17, "volume": 253279 }, { "date": "05/26/15", "open": 17.03, "high": 17.08, "low": 16.86, "close": 17.01, "volume": 212640 }, { "date": "05/27/15", "open": 17.01, "high": 17.99, "low": 16.87, "close": 17.75, "volume": 857109 }, { "date": "05/28/15", "open": 17.77, "high": 17.77, "low": 17.44, "close": 17.62, "volume": 338482 } ]; } .wj-flexchart { height: 500px; } body { margin-bottom: 24pt; } #rsChart { height: 100px; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // 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 { WjChartFinanceModule } from '@grapecity/wijmo.angular2.chart.finance'; import { WjChartInteractionModule } from '@grapecity/wijmo.angular2.chart.interaction'; import { DataService } from './app.data'; import * as core from '@grapecity/wijmo'; import * as wjChart from '@grapecity/wijmo.chart'; import * as wjFinanceChart from '@grapecity/wijmo.chart.finance'; import * as wjChartInteraction from '@grapecity/wijmo.chart.interaction'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any[]; palette: any; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); } // tooltip(ht: wjChart.HitTestInfo) { var date = ht.item && ht.item.date ? ht.item.date : null, content = ''; if (core.isDate(date)) { date = core.Globalize.formatDate(date, 'MM/dd/yy'); } if (ht && ht.item) { content = '<b>' + ht.name + '</b><br/>' + 'Date: ' + date + '<br/>' + 'Open: ' + core.Globalize.format(ht.item.open, 'n2') + '<br/>' + 'High: ' + core.Globalize.format(ht.item.high, 'n2') + '<br/>' + 'Low: ' + core.Globalize.format(ht.item.low, 'n2') + '<br/>' + 'Close: ' + core.Globalize.format(ht.item.close, 'n2') + '<br/>' + 'Volume: ' + core.Globalize.format(ht.item.volume, 'n0'); } return content; } // rsRendered(rs: wjChartInteraction.RangeSelector, rsChart: wjFinanceChart.FinancialChart) { // set range if (rs) { var range = this.findRange(rsChart.axisX.actualMin, rsChart.axisX.actualMax); rs.min = range.min; rs.max = range.max; } } // rangeChanged(rs: wjChartInteraction.RangeSelector, theChart: wjFinanceChart.FinancialChart, axisY1: wjChart.Axis, axisY2: wjChart.Axis, axisY3: wjChart.Axis) { // find visible y-range var yRange = this.findYRange(this.data, rs.min, rs.max); // update main chart's x & y range theChart.axisX.min = rs.min; theChart.axisX.max = rs.max; [theChart.axisY, axisY1, axisY2, axisY3].forEach(axis => { axis.min = yRange.min; axis.max = yRange.max; }); theChart.invalidate(); } // getRandomPalette() { 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]]; } // helper method to calculate (upper) percentage of total range // the default will show the top 20% of the available range findRange(min: number, max: number, percent?: number) { var pctToShow = core.isNumber(percent) && 0 < percent && percent < 1 ? percent : 0.2, range = { min: NaN, max: NaN }; if (core.isDate(min) && core.isDate(max)) { range.max = max.valueOf(); range.min = (max.valueOf() - min.valueOf()) * (1 - pctToShow) + min.valueOf(); } else if (core.isNumber(min) && core.isNumber(max)) { range.max = max; range.min = (max - min) * (1 - pctToShow) + min; } return range; } // assumes High, Low, Open, Close, and Volume data // also assumes category axis findYRange(data: any[], xmin: number, xmax: number) { var item, i, ymin = null, ymax = null; // for (i = 0; i < data.length; i++) { item = data[i]; if (xmin > i || i > xmax) { continue; } if (ymax === null || item.high > ymax) { ymax = item.high; } if (ymin === null || item.low < ymin) { ymin = item.low; } } return { min: ymin, max: ymax }; } } // @NgModule({ imports: [WjChartModule, WjChartFinanceModule, WjChartInteractionModule, 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 FlexChart Volume Charts</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-financial-chart #theChart [itemsSource]="data" bindingX="date" chartType="ColumnVolume" [palette]="palette" [tooltipContent]="tooltip"> <wj-financial-chart-series binding="close,volume" name="Column Volume" chartType="ColumnVolume"></wj-financial-chart-series> <wj-financial-chart-series binding="high,low,open,close,volume" name="Equi Volume" chartType="EquiVolume"> <wj-flex-chart-axis #axis1 wjProperty="axisY" position="Left" [plotArea]="plot1"></wj-flex-chart-axis> </wj-financial-chart-series> <wj-financial-chart-series binding="high,low,open,close,volume" name="Candle Volume" chartType="CandleVolume"> <wj-flex-chart-axis #axis2 wjProperty="axisY" position="Left" [plotArea]="plot2"></wj-flex-chart-axis> </wj-financial-chart-series> <wj-financial-chart-series binding="high,low,open,close,volume" name="Arms CandleVolume" chartType="ArmsCandleVolume"> <wj-flex-chart-axis #axis3 wjProperty="axisY" position="Left" [plotArea]="plot3"></wj-flex-chart-axis> </wj-financial-chart-series> <wj-flex-chart-legend position="None"></wj-flex-chart-legend> <wj-flex-chart-plot-area [row]="0" [height]="100"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area #plot1 [row]="1" [height]="100"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area #plot2 [row]="2" [height]="100"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area #plot3 [row]="3" [height]="100"></wj-flex-chart-plot-area> </wj-financial-chart> <wj-financial-chart id="rsChart" #rsChart [itemsSource]="data" bindingX="date" chartType="ColumnVolume" tooltipContent="" (rendered)="rsRendered(selector, rsChart)"> <wj-financial-chart-series binding="close,volume" name="Box Inc" chartType="ColumnVolume"></wj-financial-chart-series> <wj-flex-chart-legend position="None"></wj-flex-chart-legend> <wj-flex-chart-axis wjProperty="axisX" [labels]="false"></wj-flex-chart-axis> <wj-flex-chart-axis wjProperty="axisY" [labels]="false" [majorGrid]="false"></wj-flex-chart-axis> <wj-flex-chart-range-selector #selector [seamless]="true" (rangeChanged)="rangeChanged(selector, theChart, axis1, axis2, axis3)"> </wj-flex-chart-range-selector> </wj-financial-chart> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { getData() { return [ { "date": "01/23/15", "open": 20.2, "high": 24.73, "low": 20.16, "close": 23.23, "volume": 42593223 }, { "date": "01/26/15", "open": 23.67, "high": 24.39, "low": 22.5, "close": 22.6, "volume": 8677164 }, { "date": "01/27/15", "open": 22, "high": 22.47, "low": 21.17, "close": 21.3, "volume": 3272512 }, { "date": "01/28/15", "open": 21.62, "high": 21.84, "low": 19.6, "close": 19.78, "volume": 5047364 }, { "date": "01/29/15", "open": 19.9, "high": 19.95, "low": 18.51, "close": 18.8, "volume": 3419482 }, { "date": "01/30/15", "open": 18.47, "high": 19.48, "low": 18.22, "close": 18.81, "volume": 2266439 }, { "date": "02/02/15", "open": 19.18, "high": 19.3, "low": 18.01, "close": 18.02, "volume": 2071168 }, { "date": "02/03/15", "open": 18.22, "high": 18.64, "low": 18.12, "close": 18.24, "volume": 1587435 }, { "date": "02/04/15", "open": 18.2, "high": 18.35, "low": 17, "close": 17.1, "volume": 2912224 }, { "date": "02/05/15", "open": 17.3, "high": 17.31, "low": 16.41, "close": 16.66, "volume": 2682187 }, { "date": "02/06/15", "open": 17.39, "high": 18.88, "low": 17.21, "close": 18.12, "volume": 3929164 }, { "date": "02/09/15", "open": 18.86, "high": 19.95, "low": 18.45, "close": 19.6, "volume": 3226650 }, { "date": "02/10/15", "open": 20.5, "high": 21, "low": 19.63, "close": 20.99, "volume": 2804409 }, { "date": "02/11/15", "open": 20.89, "high": 21, "low": 20.2, "close": 20.96, "volume": 1698365 }, { "date": "02/12/15", "open": 20.66, "high": 20.85, "low": 19.75, "close": 20.17, "volume": 1370320 }, { "date": "02/13/15", "open": 20.19, "high": 20.68, "low": 20, "close": 20.18, "volume": 711951 }, { "date": "02/17/15", "open": 19.5, "high": 20.1, "low": 18.8, "close": 19.05, "volume": 2093602 }, { "date": "02/18/15", "open": 18.31, "high": 18.5, "low": 17.96, "close": 18, "volume": 1849490 }, { "date": "02/19/15", "open": 18.33, "high": 19.25, "low": 17.91, "close": 18.96, "volume": 1311518 }, { "date": "02/20/15", "open": 18.68, "high": 19.3, "low": 18.65, "close": 18.85, "volume": 1001692 }, { "date": "02/23/15", "open": 18.8, "high": 18.89, "low": 18.11, "close": 18.21, "volume": 670087 }, { "date": "02/24/15", "open": 18.46, "high": 19, "low": 18.27, "close": 18.83, "volume": 759263 }, { "date": "02/25/15", "open": 18.83, "high": 19.48, "low": 18.47, "close": 18.67, "volume": 915580 }, { "date": "02/26/15", "open": 18.64, "high": 19.2, "low": 18.64, "close": 18.94, "volume": 461283 }, { "date": "02/27/15", "open": 18.8, "high": 19.12, "low": 18.55, "close": 18.66, "volume": 617199 }, { "date": "03/02/15", "open": 18.66, "high": 19.09, "low": 18.65, "close": 18.79, "volume": 519605 }, { "date": "03/03/15", "open": 18.79, "high": 19.21, "low": 18.45, "close": 18.59, "volume": 832415 }, { "date": "03/04/15", "open": 18.64, "high": 19.05, "low": 18.32, "close": 19, "volume": 539688 }, { "date": "03/05/15", "open": 19.2, "high": 19.2, "low": 18.8, "close": 19.14, "volume": 486149 }, { "date": "03/06/15", "open": 19.03, "high": 19.1, "low": 18.7, "close": 18.91, "volume": 685659 }, { "date": "03/09/15", "open": 18.98, "high": 20.15, "low": 18.96, "close": 19.4, "volume": 1321363 }, { "date": "03/10/15", "open": 19.3, "high": 19.8, "low": 18.85, "close": 19.64, "volume": 615743 }, { "date": "03/11/15", "open": 20.08, "high": 20.65, "low": 19.24, "close": 20.53, "volume": 2167167 }, { "date": "03/12/15", "open": 17.17, "high": 18.2, "low": 16.76, "close": 18.2, "volume": 6837638 }, { "date": "03/13/15", "open": 18.05, "high": 18.05, "low": 17.3, "close": 17.88, "volume": 1715629 }, { "date": "03/16/15", "open": 17.91, "high": 18, "low": 17.01, "close": 17.13, "volume": 1321313 }, { "date": "03/17/15", "open": 17.28, "high": 17.37, "low": 16.6, "close": 17.12, "volume": 1272242 }, { "date": "03/18/15", "open": 17.1, "high": 17.27, "low": 16.91, "close": 17.01, "volume": 530063 }, { "date": "03/19/15", "open": 17, "high": 17.28, "low": 17, "close": 17.06, "volume": 536427 }, { "date": "03/20/15", "open": 17.13, "high": 17.24, "low": 16.88, "close": 17.21, "volume": 1320237 }, { "date": "03/23/15", "open": 17.21, "high": 17.23, "low": 17.01, "close": 17.11, "volume": 509798 }, { "date": "03/24/15", "open": 17.02, "high": 17.18, "low": 16.82, "close": 17, "volume": 962149 }, { "date": "03/25/15", "open": 16.92, "high": 16.99, "low": 16.82, "close": 16.97, "volume": 565673 }, { "date": "03/26/15", "open": 16.83, "high": 17.56, "low": 16.83, "close": 17.54, "volume": 884523 }, { "date": "03/27/15", "open": 17.58, "high": 18.3, "low": 17.11, "close": 18.3, "volume": 705626 }, { "date": "03/30/15", "open": 18.5, "high": 19.4, "low": 18.4, "close": 19.05, "volume": 1151620 }, { "date": "03/31/15", "open": 19.08, "high": 20.58, "low": 18.4, "close": 19.75, "volume": 2020679 }, { "date": "04/01/15", "open": 19.69, "high": 19.69, "low": 18.55, "close": 18.65, "volume": 961078 }, { "date": "04/02/15", "open": 18.56, "high": 18.66, "low": 17.85, "close": 17.9, "volume": 884233 }, { "date": "04/06/15", "open": 17.78, "high": 17.94, "low": 17.51, "close": 17.66, "volume": 605252 }, { "date": "04/07/15", "open": 17.62, "high": 17.9, "low": 17.53, "close": 17.61, "volume": 591988 }, { "date": "04/08/15", "open": 17.64, "high": 17.85, "low": 17.32, "close": 17.36, "volume": 618855 }, { "date": "04/09/15", "open": 17.33, "high": 17.54, "low": 17.1, "close": 17.1, "volume": 761855 }, { "date": "04/10/15", "open": 17.08, "high": 17.36, "low": 17, "close": 17.05, "volume": 568373 }, { "date": "04/13/15", "open": 17.24, "high": 17.26, "low": 16.81, "close": 17.1, "volume": 667142 }, { "date": "04/14/15", "open": 17.1, "high": 17.89, "low": 17.02, "close": 17.52, "volume": 870138 }, { "date": "04/15/15", "open": 17.6, "high": 17.99, "low": 17.5, "close": 17.69, "volume": 530456 }, { "date": "04/16/15", "open": 17.95, "high": 18, "low": 17.6, "close": 17.82, "volume": 548730 }, { "date": "04/17/15", "open": 17.75, "high": 17.79, "low": 17.5, "close": 17.79, "volume": 446373 }, { "date": "04/20/15", "open": 17.63, "high": 17.98, "low": 17.52, "close": 17.93, "volume": 487017 }, { "date": "04/21/15", "open": 17.96, "high": 17.98, "low": 17.71, "close": 17.92, "volume": 320302 }, { "date": "04/22/15", "open": 17.88, "high": 18.33, "low": 17.57, "close": 18.29, "volume": 644812 }, { "date": "04/23/15", "open": 18.29, "high": 18.61, "low": 18.18, "close": 18.28, "volume": 563879 }, { "date": "04/24/15", "open": 18.5, "high": 18.5, "low": 17.61, "close": 17.75, "volume": 650762 }, { "date": "04/27/15", "open": 17.97, "high": 18.05, "low": 17.45, "close": 17.57, "volume": 437294 }, { "date": "04/28/15", "open": 17.65, "high": 17.79, "low": 17.39, "close": 17.5, "volume": 224519 }, { "date": "04/29/15", "open": 17.68, "high": 17.68, "low": 17.1, "close": 17.21, "volume": 495706 }, { "date": "04/30/15", "open": 17.22, "high": 17.3, "low": 17, "close": 17.11, "volume": 391040 }, { "date": "05/01/15", "open": 17.11, "high": 17.55, "low": 16.85, "close": 17.5, "volume": 563075 }, { "date": "05/04/15", "open": 17.56, "high": 17.85, "low": 17.3, "close": 17.4, "volume": 253138 }, { "date": "05/05/15", "open": 17.68, "high": 17.68, "low": 17.09, "close": 17.43, "volume": 290935 }, { "date": "05/06/15", "open": 17.48, "high": 17.48, "low": 17, "close": 17.04, "volume": 313662 }, { "date": "05/07/15", "open": 17.05, "high": 17.19, "low": 16.92, "close": 17.04, "volume": 360284 }, { "date": "05/08/15", "open": 17.13, "high": 17.21, "low": 16.91, "close": 17.1, "volume": 297653 }, { "date": "05/11/15", "open": 17.16, "high": 17.44, "low": 17.13, "close": 17.31, "volume": 268504 }, { "date": "05/12/15", "open": 17.28, "high": 17.44, "low": 16.99, "close": 17.24, "volume": 376961 }, { "date": "05/13/15", "open": 17.24, "high": 17.3, "low": 17.06, "close": 17.2, "volume": 244617 }, { "date": "05/14/15", "open": 17.24, "high": 17.25, "low": 17.02, "close": 17.08, "volume": 252526 }, { "date": "05/15/15", "open": 17.06, "high": 17.16, "low": 16.95, "close": 16.95, "volume": 274783 }, { "date": "05/18/15", "open": 16.95, "high": 17.01, "low": 16.76, "close": 16.87, "volume": 418513 }, { "date": "05/19/15", "open": 16.93, "high": 16.94, "low": 16.6, "close": 16.83, "volume": 367660 }, { "date": "05/20/15", "open": 16.8, "high": 16.9, "low": 16.65, "close": 16.86, "volume": 297914 }, { "date": "05/21/15", "open": 16.9, "high": 17.08, "low": 16.79, "close": 16.88, "volume": 229346 }, { "date": "05/22/15", "open": 16.9, "high": 17.05, "low": 16.85, "close": 17, "volume": 253279 }, { "date": "05/26/15", "open": 17.03, "high": 17.08, "low": 16.86, "close": 17.01, "volume": 212640 }, { "date": "05/27/15", "open": 17.01, "high": 17.99, "low": 16.87, "close": 17.75, "volume": 857109 }, { "date": "05/28/15", "open": 17.77, "high": 17.77, "low": 17.44, "close": 17.62, "volume": 338482 } ]; } } .wj-flexchart { height: 500px; } body { margin-bottom: 24pt; } #rsChart { height: 100px; } <template> <div class="container-fluid"> <wj-financial-chart :initialized="initChart" :itemsSource="data" bindingX="date" chartType="ColumnVolume" :tooltipContent="tooltip"> <wj-financial-chart-series binding="close,volume" name="Column Volume" chartType="ColumnVolume"></wj-financial-chart-series> <wj-financial-chart-series binding="high,low,open,close,volume" name="Equi Volume" chartType="EquiVolume"> <wj-flex-chart-axis wjProperty="axisY" position="Left"></wj-flex-chart-axis> </wj-financial-chart-series> <wj-financial-chart-series binding="high,low,open,close,volume" name="Candle Volume" chartType="CandleVolume"> <wj-flex-chart-axis wjProperty="axisY" position="Left"></wj-flex-chart-axis> </wj-financial-chart-series> <wj-financial-chart-series binding="high,low,open,close,volume" name="Arms CandleVolume" chartType="ArmsCandleVolume"> <wj-flex-chart-axis wjProperty="axisY" position="Left"></wj-flex-chart-axis> </wj-financial-chart-series> <wj-flex-chart-legend position="None"></wj-flex-chart-legend> <wj-flex-chart-plot-area :row="0" :height="100"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area :row="1" :height="100"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area :row="2" :height="100"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area :row="3" :height="100"></wj-flex-chart-plot-area> </wj-financial-chart> <wj-financial-chart :initialized="initRSChart" id="rsChart" :itemsSource="data" bindingX="date" chartType="ColumnVolume" tooltipContent="" :rendered="rsRendered"> <wj-financial-chart-series binding="close,volume" name="Box Inc" chartType="ColumnVolume"></wj-financial-chart-series> <wj-flex-chart-legend position="None"></wj-flex-chart-legend> <wj-flex-chart-axis wjProperty="axisX" :labels="false"></wj-flex-chart-axis> <wj-flex-chart-axis wjProperty="axisY" :labels="false" :majorGrid="false"></wj-flex-chart-axis> <wj-flex-chart-range-selector :seamless="true" :rangeChanged="rangeChanged"> </wj-flex-chart-range-selector> </wj-financial-chart> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import 'bootstrap.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.core'; import '@grapecity/wijmo.vue2.chart'; import '@grapecity/wijmo.vue2.chart.interaction'; import '@grapecity/wijmo.vue2.chart.finance'; import { getData } from './data'; import * as core from '@grapecity/wijmo'; let App = Vue.extend({ name: 'app', data: function () { return { data: getData() } }, methods: { initChart: function(flex) { this.theChart = flex; let ser = flex.series[1]; this.axisY1 = ser.axisY; this.axisY1.plotArea = flex.plotAreas[1]; ser = flex.series[2]; this.axisY2 = ser.axisY; this.axisY2.plotArea = flex.plotAreas[2]; ser = flex.series[3]; this.axisY3 = ser.axisY; this.axisY3.plotArea = flex.plotAreas[3]; }, initRSChart: function(flex) { this.rsChart = flex; }, tooltip: function(ht) { var date = ht.item && ht.item.date ? ht.item.date : null, content = ''; if (core.isDate(date)) { date = core.Globalize.formatDate(date, 'MM/dd/yy'); } if (ht && ht.item) { content = '<b>' + ht.name + '</b><br/>' + 'Date: ' + date + '<br/>' + 'Open: ' + core.Globalize.format(ht.item.open, 'n2') + '<br/>' + 'High: ' + core.Globalize.format(ht.item.high, 'n2') + '<br/>' + 'Low: ' + core.Globalize.format(ht.item.low, 'n2') + '<br/>' + 'Close: ' + core.Globalize.format(ht.item.close, 'n2') + '<br/>' + 'Volume: ' + core.Globalize.format(ht.item.volume, 'n0'); } return content; }, rsRendered: function() { let rsChart = this.rsChart; let rs = this.selector; // set range if (rs) { var range = this.findRange(rsChart.axisX.actualMin, rsChart.axisX.actualMax); rs.min = range.min; rs.max = range.max; } }, rangeChanged: function(rs) { if(this.selector) { this.selector = rs; } let theChart = this.theChart; // find visible y-range var yRange = this.findYRange(this.data, rs.min, rs.max); // update main chart's x & y range theChart.axisX.min = rs.min; theChart.axisX.max = rs.max; [theChart.axisY, this.axisY1, this.axisY2, this.axisY3].forEach(axis => { axis.min = yRange.min; axis.max = yRange.max; }); theChart.invalidate(); }, // helper method to calculate (upper) percentage of total range // the default will show the top 20% of the available range findRange: function(min, max, percent) { var pctToShow = core.isNumber(percent) && 0 < percent && percent < 1 ? percent : 0.2, range = { min: NaN, max: NaN }; if (core.isDate(min) && core.isDate(max)) { range.max = max.valueOf(); range.min = (max.valueOf() - min.valueOf()) * (1 - pctToShow) + min.valueOf(); } else if (core.isNumber(min) && core.isNumber(max)) { range.max = max; range.min = (max - min) * (1 - pctToShow) + min; } return range; }, // assumes High, Low, Open, Close, and Volume data // also assumes category axis findYRange: function(data, xmin, xmax) { var item, i, ymin = null, ymax = null; // for (i = 0; i < data.length; i++) { item = data[i]; if (xmin > i || i > xmax) { continue; } if (ymax === null || item.high > ymax) { ymax = item.high; } if (ymin === null || item.low < ymin) { ymin = item.low; } } return { min: ymin, max: ymax }; } } }) new Vue({ render: h => h(App) }).$mount('#app'); </script> <style> body { margin-bottom: 24px; } label { margin-right: 3px; } #rsChart { height: 100px; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Volume Charts</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> export function getData() { return [ { "date": "01/23/15", "open": 20.2, "high": 24.73, "low": 20.16, "close": 23.23, "volume": 42593223 }, { "date": "01/26/15", "open": 23.67, "high": 24.39, "low": 22.5, "close": 22.6, "volume": 8677164 }, { "date": "01/27/15", "open": 22, "high": 22.47, "low": 21.17, "close": 21.3, "volume": 3272512 }, { "date": "01/28/15", "open": 21.62, "high": 21.84, "low": 19.6, "close": 19.78, "volume": 5047364 }, { "date": "01/29/15", "open": 19.9, "high": 19.95, "low": 18.51, "close": 18.8, "volume": 3419482 }, { "date": "01/30/15", "open": 18.47, "high": 19.48, "low": 18.22, "close": 18.81, "volume": 2266439 }, { "date": "02/02/15", "open": 19.18, "high": 19.3, "low": 18.01, "close": 18.02, "volume": 2071168 }, { "date": "02/03/15", "open": 18.22, "high": 18.64, "low": 18.12, "close": 18.24, "volume": 1587435 }, { "date": "02/04/15", "open": 18.2, "high": 18.35, "low": 17, "close": 17.1, "volume": 2912224 }, { "date": "02/05/15", "open": 17.3, "high": 17.31, "low": 16.41, "close": 16.66, "volume": 2682187 }, { "date": "02/06/15", "open": 17.39, "high": 18.88, "low": 17.21, "close": 18.12, "volume": 3929164 }, { "date": "02/09/15", "open": 18.86, "high": 19.95, "low": 18.45, "close": 19.6, "volume": 3226650 }, { "date": "02/10/15", "open": 20.5, "high": 21, "low": 19.63, "close": 20.99, "volume": 2804409 }, { "date": "02/11/15", "open": 20.89, "high": 21, "low": 20.2, "close": 20.96, "volume": 1698365 }, { "date": "02/12/15", "open": 20.66, "high": 20.85, "low": 19.75, "close": 20.17, "volume": 1370320 }, { "date": "02/13/15", "open": 20.19, "high": 20.68, "low": 20, "close": 20.18, "volume": 711951 }, { "date": "02/17/15", "open": 19.5, "high": 20.1, "low": 18.8, "close": 19.05, "volume": 2093602 }, { "date": "02/18/15", "open": 18.31, "high": 18.5, "low": 17.96, "close": 18, "volume": 1849490 }, { "date": "02/19/15", "open": 18.33, "high": 19.25, "low": 17.91, "close": 18.96, "volume": 1311518 }, { "date": "02/20/15", "open": 18.68, "high": 19.3, "low": 18.65, "close": 18.85, "volume": 1001692 }, { "date": "02/23/15", "open": 18.8, "high": 18.89, "low": 18.11, "close": 18.21, "volume": 670087 }, { "date": "02/24/15", "open": 18.46, "high": 19, "low": 18.27, "close": 18.83, "volume": 759263 }, { "date": "02/25/15", "open": 18.83, "high": 19.48, "low": 18.47, "close": 18.67, "volume": 915580 }, { "date": "02/26/15", "open": 18.64, "high": 19.2, "low": 18.64, "close": 18.94, "volume": 461283 }, { "date": "02/27/15", "open": 18.8, "high": 19.12, "low": 18.55, "close": 18.66, "volume": 617199 }, { "date": "03/02/15", "open": 18.66, "high": 19.09, "low": 18.65, "close": 18.79, "volume": 519605 }, { "date": "03/03/15", "open": 18.79, "high": 19.21, "low": 18.45, "close": 18.59, "volume": 832415 }, { "date": "03/04/15", "open": 18.64, "high": 19.05, "low": 18.32, "close": 19, "volume": 539688 }, { "date": "03/05/15", "open": 19.2, "high": 19.2, "low": 18.8, "close": 19.14, "volume": 486149 }, { "date": "03/06/15", "open": 19.03, "high": 19.1, "low": 18.7, "close": 18.91, "volume": 685659 }, { "date": "03/09/15", "open": 18.98, "high": 20.15, "low": 18.96, "close": 19.4, "volume": 1321363 }, { "date": "03/10/15", "open": 19.3, "high": 19.8, "low": 18.85, "close": 19.64, "volume": 615743 }, { "date": "03/11/15", "open": 20.08, "high": 20.65, "low": 19.24, "close": 20.53, "volume": 2167167 }, { "date": "03/12/15", "open": 17.17, "high": 18.2, "low": 16.76, "close": 18.2, "volume": 6837638 }, { "date": "03/13/15", "open": 18.05, "high": 18.05, "low": 17.3, "close": 17.88, "volume": 1715629 }, { "date": "03/16/15", "open": 17.91, "high": 18, "low": 17.01, "close": 17.13, "volume": 1321313 }, { "date": "03/17/15", "open": 17.28, "high": 17.37, "low": 16.6, "close": 17.12, "volume": 1272242 }, { "date": "03/18/15", "open": 17.1, "high": 17.27, "low": 16.91, "close": 17.01, "volume": 530063 }, { "date": "03/19/15", "open": 17, "high": 17.28, "low": 17, "close": 17.06, "volume": 536427 }, { "date": "03/20/15", "open": 17.13, "high": 17.24, "low": 16.88, "close": 17.21, "volume": 1320237 }, { "date": "03/23/15", "open": 17.21, "high": 17.23, "low": 17.01, "close": 17.11, "volume": 509798 }, { "date": "03/24/15", "open": 17.02, "high": 17.18, "low": 16.82, "close": 17, "volume": 962149 }, { "date": "03/25/15", "open": 16.92, "high": 16.99, "low": 16.82, "close": 16.97, "volume": 565673 }, { "date": "03/26/15", "open": 16.83, "high": 17.56, "low": 16.83, "close": 17.54, "volume": 884523 }, { "date": "03/27/15", "open": 17.58, "high": 18.3, "low": 17.11, "close": 18.3, "volume": 705626 }, { "date": "03/30/15", "open": 18.5, "high": 19.4, "low": 18.4, "close": 19.05, "volume": 1151620 }, { "date": "03/31/15", "open": 19.08, "high": 20.58, "low": 18.4, "close": 19.75, "volume": 2020679 }, { "date": "04/01/15", "open": 19.69, "high": 19.69, "low": 18.55, "close": 18.65, "volume": 961078 }, { "date": "04/02/15", "open": 18.56, "high": 18.66, "low": 17.85, "close": 17.9, "volume": 884233 }, { "date": "04/06/15", "open": 17.78, "high": 17.94, "low": 17.51, "close": 17.66, "volume": 605252 }, { "date": "04/07/15", "open": 17.62, "high": 17.9, "low": 17.53, "close": 17.61, "volume": 591988 }, { "date": "04/08/15", "open": 17.64, "high": 17.85, "low": 17.32, "close": 17.36, "volume": 618855 }, { "date": "04/09/15", "open": 17.33, "high": 17.54, "low": 17.1, "close": 17.1, "volume": 761855 }, { "date": "04/10/15", "open": 17.08, "high": 17.36, "low": 17, "close": 17.05, "volume": 568373 }, { "date": "04/13/15", "open": 17.24, "high": 17.26, "low": 16.81, "close": 17.1, "volume": 667142 }, { "date": "04/14/15", "open": 17.1, "high": 17.89, "low": 17.02, "close": 17.52, "volume": 870138 }, { "date": "04/15/15", "open": 17.6, "high": 17.99, "low": 17.5, "close": 17.69, "volume": 530456 }, { "date": "04/16/15", "open": 17.95, "high": 18, "low": 17.6, "close": 17.82, "volume": 548730 }, { "date": "04/17/15", "open": 17.75, "high": 17.79, "low": 17.5, "close": 17.79, "volume": 446373 }, { "date": "04/20/15", "open": 17.63, "high": 17.98, "low": 17.52, "close": 17.93, "volume": 487017 }, { "date": "04/21/15", "open": 17.96, "high": 17.98, "low": 17.71, "close": 17.92, "volume": 320302 }, { "date": "04/22/15", "open": 17.88, "high": 18.33, "low": 17.57, "close": 18.29, "volume": 644812 }, { "date": "04/23/15", "open": 18.29, "high": 18.61, "low": 18.18, "close": 18.28, "volume": 563879 }, { "date": "04/24/15", "open": 18.5, "high": 18.5, "low": 17.61, "close": 17.75, "volume": 650762 }, { "date": "04/27/15", "open": 17.97, "high": 18.05, "low": 17.45, "close": 17.57, "volume": 437294 }, { "date": "04/28/15", "open": 17.65, "high": 17.79, "low": 17.39, "close": 17.5, "volume": 224519 }, { "date": "04/29/15", "open": 17.68, "high": 17.68, "low": 17.1, "close": 17.21, "volume": 495706 }, { "date": "04/30/15", "open": 17.22, "high": 17.3, "low": 17, "close": 17.11, "volume": 391040 }, { "date": "05/01/15", "open": 17.11, "high": 17.55, "low": 16.85, "close": 17.5, "volume": 563075 }, { "date": "05/04/15", "open": 17.56, "high": 17.85, "low": 17.3, "close": 17.4, "volume": 253138 }, { "date": "05/05/15", "open": 17.68, "high": 17.68, "low": 17.09, "close": 17.43, "volume": 290935 }, { "date": "05/06/15", "open": 17.48, "high": 17.48, "low": 17, "close": 17.04, "volume": 313662 }, { "date": "05/07/15", "open": 17.05, "high": 17.19, "low": 16.92, "close": 17.04, "volume": 360284 }, { "date": "05/08/15", "open": 17.13, "high": 17.21, "low": 16.91, "close": 17.1, "volume": 297653 }, { "date": "05/11/15", "open": 17.16, "high": 17.44, "low": 17.13, "close": 17.31, "volume": 268504 }, { "date": "05/12/15", "open": 17.28, "high": 17.44, "low": 16.99, "close": 17.24, "volume": 376961 }, { "date": "05/13/15", "open": 17.24, "high": 17.3, "low": 17.06, "close": 17.2, "volume": 244617 }, { "date": "05/14/15", "open": 17.24, "high": 17.25, "low": 17.02, "close": 17.08, "volume": 252526 }, { "date": "05/15/15", "open": 17.06, "high": 17.16, "low": 16.95, "close": 16.95, "volume": 274783 }, { "date": "05/18/15", "open": 16.95, "high": 17.01, "low": 16.76, "close": 16.87, "volume": 418513 }, { "date": "05/19/15", "open": 16.93, "high": 16.94, "low": 16.6, "close": 16.83, "volume": 367660 }, { "date": "05/20/15", "open": 16.8, "high": 16.9, "low": 16.65, "close": 16.86, "volume": 297914 }, { "date": "05/21/15", "open": 16.9, "high": 17.08, "low": 16.79, "close": 16.88, "volume": 229346 }, { "date": "05/22/15", "open": 16.9, "high": 17.05, "low": 16.85, "close": 17, "volume": 253279 }, { "date": "05/26/15", "open": 17.03, "high": 17.08, "low": 16.86, "close": 17.01, "volume": 212640 }, { "date": "05/27/15", "open": 17.01, "high": 17.99, "low": 16.87, "close": 17.75, "volume": 857109 }, { "date": "05/28/15", "open": 17.77, "high": 17.77, "low": 17.44, "close": 17.62, "volume": 338482 } ]; } import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import "./app.css"; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as wjCore from "@grapecity/wijmo"; import * as wjChart from "@grapecity/wijmo.react.chart"; import * as wjChartInteraction from "@grapecity/wijmo.react.chart.interaction"; import * as wjFinance from "@grapecity/wijmo.react.chart.finance"; import { getData } from "./data"; class App extends React.Component { constructor(props) { super(props); this.state = { data: getData() }; } render() { return <div className="container-fluid"> <div className="form-group"> <wjFinance.FinancialChart initialized={this.initChart.bind(this)} itemsSource={this.state.data} bindingX="date" chartType="ColumnVolume" tooltipContent="tooltip"> <wjFinance.FinancialChartSeries binding="close,volume" name="Column Volume" chartType="ColumnVolume"> </wjFinance.FinancialChartSeries> <wjFinance.FinancialChartSeries binding="high,low,open,close,volume" name="Equi Volume" chartType="EquiVolume"> <wjChart.FlexChartAxis wjProperty="axisY" position="Left"></wjChart.FlexChartAxis> </wjFinance.FinancialChartSeries> <wjFinance.FinancialChartSeries binding="high,low,open,close,volume" name="Candle Volume" chartType="CandleVolume"> <wjChart.FlexChartAxis wjProperty="axisY" position="Left"></wjChart.FlexChartAxis> </wjFinance.FinancialChartSeries> <wjFinance.FinancialChartSeries binding="high,low,open,close,volume" name="Arms CandleVolume" chartType="ArmsCandleVolume"> <wjChart.FlexChartAxis wjProperty="axisY" position="Left"></wjChart.FlexChartAxis> </wjFinance.FinancialChartSeries> <wjChart.FlexChartLegend position="None"></wjChart.FlexChartLegend> <wjChart.FlexChartPlotArea row={0} height={100}></wjChart.FlexChartPlotArea> <wjChart.FlexChartPlotArea row={1} height={100}></wjChart.FlexChartPlotArea> <wjChart.FlexChartPlotArea row={2} height={100}></wjChart.FlexChartPlotArea> <wjChart.FlexChartPlotArea row={3} height={100}></wjChart.FlexChartPlotArea> </wjFinance.FinancialChart> <wjFinance.FinancialChart initialized={this.initRSChart.bind(this)} id="rsChart" itemsSource={this.state.data} bindingX="date" chartType="ColumnVolume" tooltipContent="" rendered={this.rsRendered.bind(this)}> <wjFinance.FinancialChartSeries binding="close,volume" name="Box Inc" chartType="ColumnVolume"> </wjFinance.FinancialChartSeries> <wjChart.FlexChartLegend position="None"></wjChart.FlexChartLegend> <wjChart.FlexChartAxis wjProperty="axisX" labels={false}></wjChart.FlexChartAxis> <wjChart.FlexChartAxis wjProperty="axisY" labels={false} majorGrid={false}></wjChart.FlexChartAxis> <wjChartInteraction.FlexChartRangeSelector seamless={true} rangeChanged={this.rangeChanged.bind(this)}></wjChartInteraction.FlexChartRangeSelector> </wjFinance.FinancialChart> </div> </div>; } initChart(flex) { this.theChart = flex; let ser = flex.series[1]; this.axisY1 = ser.axisY; this.axisY1.plotArea = flex.plotAreas[1]; ser = flex.series[2]; this.axisY2 = ser.axisY; this.axisY2.plotArea = flex.plotAreas[2]; ser = flex.series[3]; this.axisY3 = ser.axisY; this.axisY3.plotArea = flex.plotAreas[3]; } initRSChart(flex) { this.rsChart = flex; } tooltip(ht) { var date = ht.item && ht.item.date ? ht.item.date : null, content = ''; if (wjCore.isDate(date)) { date = wjCore.Globalize.formatDate(date, 'MM/dd/yy'); } if (ht && ht.item) { content = '<b>' + ht.name + '</b><br/>' + 'Date: ' + date + '<br/>' + 'Open: ' + wjCore.Globalize.format(ht.item.open, 'n2') + '<br/>' + 'High: ' + wjCore.Globalize.format(ht.item.high, 'n2') + '<br/>' + 'Low: ' + wjCore.Globalize.format(ht.item.low, 'n2') + '<br/>' + 'Close: ' + wjCore.Globalize.format(ht.item.close, 'n2') + '<br/>' + 'Volume: ' + wjCore.Globalize.format(ht.item.volume, 'n0'); } return content; } rsRendered() { let rsChart = this.rsChart; let rs = this.selector; // set range if (rs) { var range = this.findRange(rsChart.axisX.actualMin, rsChart.axisX.actualMax); rs.min = range.min; rs.max = range.max; } } rangeChanged(rs) { if (this.selector) { this.selector = rs; } let theChart = this.theChart; // find visible y-range var yRange = this.findYRange(this.state.data, rs.min, rs.max); // update main chart's x & y range theChart.axisX.min = rs.min; theChart.axisX.max = rs.max; [theChart.axisY, this.axisY1, this.axisY2, this.axisY3].forEach(axis => { axis.min = yRange.min; axis.max = yRange.max; }); theChart.invalidate(); } // helper method to calculate (upper) percentage of total range // the default will show the top 20% of the available range findRange(min, max, percent) { var pctToShow = wjCore.isNumber(percent) && 0 < percent && percent < 1 ? percent : 0.2, range = { min: NaN, max: NaN }; if (wjCore.isDate(min) && wjCore.isDate(max)) { range.max = max.valueOf(); range.min = (max.valueOf() - min.valueOf()) * (1 - pctToShow) + min.valueOf(); } else if (wjCore.isNumber(min) && wjCore.isNumber(max)) { range.max = max; range.min = (max - min) * (1 - pctToShow) + min; } return range; } // assumes High, Low, Open, Close, and Volume data // also assumes category axis findYRange(data, xmin, xmax) { var item, i, ymin = null, ymax = null; // for (i = 0; i < data.length; i++) { item = data[i]; if (xmin > i || i > xmax) { continue; } if (ymax === null || item.high > ymax) { ymax = item.high; } if (ymin === null || item.low < ymin) { ymin = item.low; } } return { min: ymin, max: ymax }; } } 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>Grapecity Wijmo OLAP Pivot Chart Overview</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; } label { margin-right: 3px; } #rsChart { height: 100px; } export function getData() { return [ { "date": "01/23/15", "open": 20.2, "high": 24.73, "low": 20.16, "close": 23.23, "volume": 42593223 }, { "date": "01/26/15", "open": 23.67, "high": 24.39, "low": 22.5, "close": 22.6, "volume": 8677164 }, { "date": "01/27/15", "open": 22, "high": 22.47, "low": 21.17, "close": 21.3, "volume": 3272512 }, { "date": "01/28/15", "open": 21.62, "high": 21.84, "low": 19.6, "close": 19.78, "volume": 5047364 }, { "date": "01/29/15", "open": 19.9, "high": 19.95, "low": 18.51, "close": 18.8, "volume": 3419482 }, { "date": "01/30/15", "open": 18.47, "high": 19.48, "low": 18.22, "close": 18.81, "volume": 2266439 }, { "date": "02/02/15", "open": 19.18, "high": 19.3, "low": 18.01, "close": 18.02, "volume": 2071168 }, { "date": "02/03/15", "open": 18.22, "high": 18.64, "low": 18.12, "close": 18.24, "volume": 1587435 }, { "date": "02/04/15", "open": 18.2, "high": 18.35, "low": 17, "close": 17.1, "volume": 2912224 }, { "date": "02/05/15", "open": 17.3, "high": 17.31, "low": 16.41, "close": 16.66, "volume": 2682187 }, { "date": "02/06/15", "open": 17.39, "high": 18.88, "low": 17.21, "close": 18.12, "volume": 3929164 }, { "date": "02/09/15", "open": 18.86, "high": 19.95, "low": 18.45, "close": 19.6, "volume": 3226650 }, { "date": "02/10/15", "open": 20.5, "high": 21, "low": 19.63, "close": 20.99, "volume": 2804409 }, { "date": "02/11/15", "open": 20.89, "high": 21, "low": 20.2, "close": 20.96, "volume": 1698365 }, { "date": "02/12/15", "open": 20.66, "high": 20.85, "low": 19.75, "close": 20.17, "volume": 1370320 }, { "date": "02/13/15", "open": 20.19, "high": 20.68, "low": 20, "close": 20.18, "volume": 711951 }, { "date": "02/17/15", "open": 19.5, "high": 20.1, "low": 18.8, "close": 19.05, "volume": 2093602 }, { "date": "02/18/15", "open": 18.31, "high": 18.5, "low": 17.96, "close": 18, "volume": 1849490 }, { "date": "02/19/15", "open": 18.33, "high": 19.25, "low": 17.91, "close": 18.96, "volume": 1311518 }, { "date": "02/20/15", "open": 18.68, "high": 19.3, "low": 18.65, "close": 18.85, "volume": 1001692 }, { "date": "02/23/15", "open": 18.8, "high": 18.89, "low": 18.11, "close": 18.21, "volume": 670087 }, { "date": "02/24/15", "open": 18.46, "high": 19, "low": 18.27, "close": 18.83, "volume": 759263 }, { "date": "02/25/15", "open": 18.83, "high": 19.48, "low": 18.47, "close": 18.67, "volume": 915580 }, { "date": "02/26/15", "open": 18.64, "high": 19.2, "low": 18.64, "close": 18.94, "volume": 461283 }, { "date": "02/27/15", "open": 18.8, "high": 19.12, "low": 18.55, "close": 18.66, "volume": 617199 }, { "date": "03/02/15", "open": 18.66, "high": 19.09, "low": 18.65, "close": 18.79, "volume": 519605 }, { "date": "03/03/15", "open": 18.79, "high": 19.21, "low": 18.45, "close": 18.59, "volume": 832415 }, { "date": "03/04/15", "open": 18.64, "high": 19.05, "low": 18.32, "close": 19, "volume": 539688 }, { "date": "03/05/15", "open": 19.2, "high": 19.2, "low": 18.8, "close": 19.14, "volume": 486149 }, { "date": "03/06/15", "open": 19.03, "high": 19.1, "low": 18.7, "close": 18.91, "volume": 685659 }, { "date": "03/09/15", "open": 18.98, "high": 20.15, "low": 18.96, "close": 19.4, "volume": 1321363 }, { "date": "03/10/15", "open": 19.3, "high": 19.8, "low": 18.85, "close": 19.64, "volume": 615743 }, { "date": "03/11/15", "open": 20.08, "high": 20.65, "low": 19.24, "close": 20.53, "volume": 2167167 }, { "date": "03/12/15", "open": 17.17, "high": 18.2, "low": 16.76, "close": 18.2, "volume": 6837638 }, { "date": "03/13/15", "open": 18.05, "high": 18.05, "low": 17.3, "close": 17.88, "volume": 1715629 }, { "date": "03/16/15", "open": 17.91, "high": 18, "low": 17.01, "close": 17.13, "volume": 1321313 }, { "date": "03/17/15", "open": 17.28, "high": 17.37, "low": 16.6, "close": 17.12, "volume": 1272242 }, { "date": "03/18/15", "open": 17.1, "high": 17.27, "low": 16.91, "close": 17.01, "volume": 530063 }, { "date": "03/19/15", "open": 17, "high": 17.28, "low": 17, "close": 17.06, "volume": 536427 }, { "date": "03/20/15", "open": 17.13, "high": 17.24, "low": 16.88, "close": 17.21, "volume": 1320237 }, { "date": "03/23/15", "open": 17.21, "high": 17.23, "low": 17.01, "close": 17.11, "volume": 509798 }, { "date": "03/24/15", "open": 17.02, "high": 17.18, "low": 16.82, "close": 17, "volume": 962149 }, { "date": "03/25/15", "open": 16.92, "high": 16.99, "low": 16.82, "close": 16.97, "volume": 565673 }, { "date": "03/26/15", "open": 16.83, "high": 17.56, "low": 16.83, "close": 17.54, "volume": 884523 }, { "date": "03/27/15", "open": 17.58, "high": 18.3, "low": 17.11, "close": 18.3, "volume": 705626 }, { "date": "03/30/15", "open": 18.5, "high": 19.4, "low": 18.4, "close": 19.05, "volume": 1151620 }, { "date": "03/31/15", "open": 19.08, "high": 20.58, "low": 18.4, "close": 19.75, "volume": 2020679 }, { "date": "04/01/15", "open": 19.69, "high": 19.69, "low": 18.55, "close": 18.65, "volume": 961078 }, { "date": "04/02/15", "open": 18.56, "high": 18.66, "low": 17.85, "close": 17.9, "volume": 884233 }, { "date": "04/06/15", "open": 17.78, "high": 17.94, "low": 17.51, "close": 17.66, "volume": 605252 }, { "date": "04/07/15", "open": 17.62, "high": 17.9, "low": 17.53, "close": 17.61, "volume": 591988 }, { "date": "04/08/15", "open": 17.64, "high": 17.85, "low": 17.32, "close": 17.36, "volume": 618855 }, { "date": "04/09/15", "open": 17.33, "high": 17.54, "low": 17.1, "close": 17.1, "volume": 761855 }, { "date": "04/10/15", "open": 17.08, "high": 17.36, "low": 17, "close": 17.05, "volume": 568373 }, { "date": "04/13/15", "open": 17.24, "high": 17.26, "low": 16.81, "close": 17.1, "volume": 667142 }, { "date": "04/14/15", "open": 17.1, "high": 17.89, "low": 17.02, "close": 17.52, "volume": 870138 }, { "date": "04/15/15", "open": 17.6, "high": 17.99, "low": 17.5, "close": 17.69, "volume": 530456 }, { "date": "04/16/15", "open": 17.95, "high": 18, "low": 17.6, "close": 17.82, "volume": 548730 }, { "date": "04/17/15", "open": 17.75, "high": 17.79, "low": 17.5, "close": 17.79, "volume": 446373 }, { "date": "04/20/15", "open": 17.63, "high": 17.98, "low": 17.52, "close": 17.93, "volume": 487017 }, { "date": "04/21/15", "open": 17.96, "high": 17.98, "low": 17.71, "close": 17.92, "volume": 320302 }, { "date": "04/22/15", "open": 17.88, "high": 18.33, "low": 17.57, "close": 18.29, "volume": 644812 }, { "date": "04/23/15", "open": 18.29, "high": 18.61, "low": 18.18, "close": 18.28, "volume": 563879 }, { "date": "04/24/15", "open": 18.5, "high": 18.5, "low": 17.61, "close": 17.75, "volume": 650762 }, { "date": "04/27/15", "open": 17.97, "high": 18.05, "low": 17.45, "close": 17.57, "volume": 437294 }, { "date": "04/28/15", "open": 17.65, "high": 17.79, "low": 17.39, "close": 17.5, "volume": 224519 }, { "date": "04/29/15", "open": 17.68, "high": 17.68, "low": 17.1, "close": 17.21, "volume": 495706 }, { "date": "04/30/15", "open": 17.22, "high": 17.3, "low": 17, "close": 17.11, "volume": 391040 }, { "date": "05/01/15", "open": 17.11, "high": 17.55, "low": 16.85, "close": 17.5, "volume": 563075 }, { "date": "05/04/15", "open": 17.56, "high": 17.85, "low": 17.3, "close": 17.4, "volume": 253138 }, { "date": "05/05/15", "open": 17.68, "high": 17.68, "low": 17.09, "close": 17.43, "volume": 290935 }, { "date": "05/06/15", "open": 17.48, "high": 17.48, "low": 17, "close": 17.04, "volume": 313662 }, { "date": "05/07/15", "open": 17.05, "high": 17.19, "low": 16.92, "close": 17.04, "volume": 360284 }, { "date": "05/08/15", "open": 17.13, "high": 17.21, "low": 16.91, "close": 17.1, "volume": 297653 }, { "date": "05/11/15", "open": 17.16, "high": 17.44, "low": 17.13, "close": 17.31, "volume": 268504 }, { "date": "05/12/15", "open": 17.28, "high": 17.44, "low": 16.99, "close": 17.24, "volume": 376961 }, { "date": "05/13/15", "open": 17.24, "high": 17.3, "low": 17.06, "close": 17.2, "volume": 244617 }, { "date": "05/14/15", "open": 17.24, "high": 17.25, "low": 17.02, "close": 17.08, "volume": 252526 }, { "date": "05/15/15", "open": 17.06, "high": 17.16, "low": 16.95, "close": 16.95, "volume": 274783 }, { "date": "05/18/15", "open": 16.95, "high": 17.01, "low": 16.76, "close": 16.87, "volume": 418513 }, { "date": "05/19/15", "open": 16.93, "high": 16.94, "low": 16.6, "close": 16.83, "volume": 367660 }, { "date": "05/20/15", "open": 16.8, "high": 16.9, "low": 16.65, "close": 16.86, "volume": 297914 }, { "date": "05/21/15", "open": 16.9, "high": 17.08, "low": 16.79, "close": 16.88, "volume": 229346 }, { "date": "05/22/15", "open": 16.9, "high": 17.05, "low": 16.85, "close": 17, "volume": 253279 }, { "date": "05/26/15", "open": 17.03, "high": 17.08, "low": 16.86, "close": 17.01, "volume": 212640 }, { "date": "05/27/15", "open": 17.01, "high": 17.99, "low": 16.87, "close": 17.75, "volume": 857109 }, { "date": "05/28/15", "open": 17.77, "high": 17.77, "low": 17.44, "close": 17.62, "volume": 338482 } ]; }