Bubble Charts

Unlike most other chart types, Bubble Charts display three dimensions of data: X, Y, and size.

To create bubble charts with the FlexChart control, you must set the binding property to a comma-delimited list of property names. The first property will be bound to the Y value, and the second to the bubble size.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as chart from '@grapecity/wijmo.chart'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let theChart = new chart.FlexChart('#theChart', { itemsSource: getData(), chartType: 'Bubble', bindingX: 'sales', series: [ { binding: 'expenses,downloads' } ], legend: { position: 'None' }, tooltip: { content: '<b>{item.country}</b>:<table class="chart-tip">' + '<tr><td>Sales</td><td>{sales:c0}</td></tr>' + '<tr><td>Expenses</td><td>{expenses:c0}</td></tr>' + '<tr><td>Downloads</td><td>{downloads:n0}</td></tr>' + '</table>' }, axisX: { title: 'Sales', min: 0 }, axisY: { title: 'Expenses', min: 0 } }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Bubble Chart</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> </body> </html> // create some random data export function getData() { let countries = ['US', 'Canada', 'Mexico', 'UK', 'Germany', 'France', 'Italy', 'Japan', 'Korea', 'China', 'Autralia', 'New Zealand'], data = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; } .wj-flexchart { height: 300px; } .chart-tip td { text-align: right; } .chart-tip td:first-child { font-weight: bold; padding-right: 12px; } body { margin-bottom: 24pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as wijmo from '@grapecity/wijmo'; 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 { DataService, TDataItem } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: TDataItem[]; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); } // customTooltip(ht: chart.HitTestInfo) { let item: TDataItem = ht.item; // return `<b>${item.country}</b>:<table class="chart-tip">` + `<tr><td>Sales</td><td>${wijmo.Globalize.format(item.sales, 'c0')}</td></tr>` + `<tr><td>Expenses</td><td>${wijmo.Globalize.format(item.expenses, 'c0')}</td></tr>` + `<tr><td>Downloads</td><td>${wijmo.Globalize.format(item.downloads, 'n0')}</td></tr>` + `</table>`; } } // @NgModule({ imports: [WjChartModule, 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 Bubble Chart</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 [chartType]="'Bubble'" [bindingX]="'sales'" [itemsSource]="data" [tooltipContent]="customTooltip"> <wj-flex-chart-axis wjProperty="axisY" [title]="'Expenses'" [min]="0"></wj-flex-chart-axis> <wj-flex-chart-axis wjProperty="axisX" [title]="'Sales'" [min]="0" [axisLine]="true"></wj-flex-chart-axis> <wj-flex-chart-legend [position]="'None'"> </wj-flex-chart-legend> <wj-flex-chart-series [binding]="'expenses,downloads'"> </wj-flex-chart-series> </wj-flex-chart> </div> import { Injectable } from '@angular/core'; // export type TDataItem = { country: string; sales: number; expenses: number; downloads: number; } // @Injectable() export class DataService { getData() { let countries = ['US', 'Canada', 'Mexico', 'UK', 'Germany', 'France', 'Italy', 'Japan', 'Korea', 'China', 'Autralia', 'New Zealand'], data: TDataItem[] = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; } } .wj-flexchart { height: 300px; } .chart-tip td { text-align: right; } .chart-tip td:first-child { font-weight: bold; padding-right: 12px; } body { margin-bottom: 24pt; } <template> <div class="container-fluid"> <wj-flex-chart chartType="Bubble" bindingX="sales" :itemsSource="data" :tooltipContent="customTooltip"> <wj-flex-chart-axis wjProperty="axisY" title="Expenses" :min=0></wj-flex-chart-axis> <wj-flex-chart-axis wjProperty="axisX" title="Sales" :min=0 :axisLine=true></wj-flex-chart-axis> <wj-flex-chart-legend position="None"> </wj-flex-chart-legend> <wj-flex-chart-series binding="expenses,downloads"> </wj-flex-chart-series> </wj-flex-chart> </div> </template> <script> import '@grapecity/wijmo.styles/wijmo.css'; import 'bootstrap.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.chart'; import { getData } from './data'; // new Vue({ el: '#app', data: { data: getData() }, methods: { customTooltip(ht) { let item = ht.item; // return `<b>${item.country}</b>:<table class="chart-tip">` + `<tr><td>Sales</td><td>${wijmo.Globalize.format(item.sales, 'c0')}</td></tr>` + `<tr><td>Expenses</td><td>${wijmo.Globalize.format(item.expenses, 'c0')}</td></tr>` + `<tr><td>Downloads</td><td>${wijmo.Globalize.format(item.downloads, 'n0')}</td></tr>` + `</table>`; } } }); </script> <style> .container-fluid .wj-flexchart { height: 300px; } .container-fluid .chart-tip td { text-align: right; } .container-fluid .chart-tip td:first-child { font-weight: bold; padding-right: 12px; } body { margin-bottom: 24pt; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Bubble Chart</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> // create some random data export function getData() { let countries = ['US', 'Canada', 'Mexico', 'UK', 'Germany', 'France', 'Italy', 'Japan', 'Korea', 'China', 'Autralia', 'New Zealand'], data = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; } 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 wijmo from '@grapecity/wijmo'; import * as wjChart from '@grapecity/wijmo.react.chart'; import { getData } from './data'; // class App extends React.Component { constructor(props) { super(props); this.initChart = (sender) => { sender.tooltip.content = this.customTooltip; this.chart = sender; }; this.customTooltip = (ht) => { let item = ht.item; // return `<b>${item.country}</b>:<table className="chart-tip">` + `<tr><td>Sales</td><td>${wijmo.Globalize.format(item.sales, 'c0')}</td></tr>` + `<tr><td>Expenses</td><td>${wijmo.Globalize.format(item.expenses, 'c0')}</td></tr>` + `<tr><td>Downloads</td><td>${wijmo.Globalize.format(item.downloads, 'n0')}</td></tr>` + `</table>`; }; this.state = { data: getData() }; } render() { return <div className="container-fluid"> <wjChart.FlexChart chartType="Bubble" bindingX="sales" itemsSource={this.state.data} initialized={this.initChart}> <wjChart.FlexChartAxis wjProperty="axisY" title="Expenses" min={0}> </wjChart.FlexChartAxis> <wjChart.FlexChartAxis wjProperty="axisY" title="Expenses" min={0} axisLine={true}> </wjChart.FlexChartAxis> <wjChart.FlexChartLegend position="None"></wjChart.FlexChartLegend> <wjChart.FlexChartSeries binding="expenses,downloads"> </wjChart.FlexChartSeries> </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> .wj-flexchart { height: 300px; } .chart-tip td { text-align: right; } .chart-tip td:first-child { font-weight: bold; padding-right: 12px; } body { margin-bottom: 24pt; } export function getData() { let countries = ['US', 'Canada', 'Mexico', 'UK', 'Germany', 'France', 'Italy', 'Japan', 'Korea', 'China', 'Autralia', 'New Zealand'], data = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; }