-
-
Save JeroenVinke/6f16b017bb514682f4c188f8b20e52fa to your computer and use it in GitHub Desktop.
Bar charts: basic use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<require from="aurelia-kendoui-bridge/chart/chart"></require> | |
<ak-chart k-title.bind="{text: 'Site Visitors Stats \n /thousands/'}" | |
k-legend.bind="{position: 'bottom'}" | |
k-series-defaults.bind="seriesDefaults" | |
k-series.two-way="series" | |
k-value-axis.bind="valueAxis" | |
k-category-axis.bind="categoryAxis" | |
k-tooltip.bind="tooltip" | |
view-model.ref="theChart"> | |
</ak-chart> | |
<button click.delegate="toggleVisitors()">${showVisitors ? 'Hide Visitors' : 'Show Visitors'}</button> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {inject} from 'aurelia-framework'; | |
import {TaskQueue} from 'aurelia-task-queue'; | |
@inject(TaskQueue) | |
export class BasicUse { | |
showVisitors = true; | |
theChart; | |
constructor(taskQueue) { | |
this.taskQueue = taskQueue; | |
} | |
seriesDefaults = { | |
type: 'bar' | |
}; | |
series = [{ | |
name: 'Total Visits', | |
data: [56000, 63000, 74000, 91000, 117000, 138000] | |
}, { | |
name: 'Unique visitors', | |
data: [52000, 34000, 23000, 48000, 67000, 83000] | |
}]; | |
valueAxis = { | |
max: 140000, | |
line: { | |
visible: false | |
}, | |
minorGridLines: { | |
visible: true | |
}, | |
labels: { | |
rotation: 'auto' | |
} | |
}; | |
categoryAxis = { | |
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'], | |
majorGridLines: { | |
visible: false | |
} | |
}; | |
tooltip = { | |
visible: true, | |
template: '${series.name} ${value}' | |
} | |
toggleVisitors() { | |
this.showVisitors = !this.showVisitors; | |
if(this.showVisitors) { | |
this.series = [{ | |
name: 'Total Visits', | |
data: [56000, 63000, 74000, 91000, 117000, 138000] | |
}, { | |
name: 'Unique visitors', | |
data: [52000, 34000, 23000, 48000, 67000, 83000] | |
}]; | |
} else { | |
this.series = [{ | |
name: 'Total Visits', | |
data: [56000, 63000, 74000, 91000, 117000, 138000] | |
}]; | |
} | |
this.taskQueue.queueTask(() => { | |
this.theChart.recreate(); | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia KendoUI bridge</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.common.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.rtl.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.default.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.mobile.all.min.css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.0/bluebird.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.2.1/chroma.min.js"></script> | |
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/jquery.min.js"></script> | |
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/jszip.min.js"></script> | |
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/kendo.all.min.js"></script> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script> | |
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-kendoui-bundles/1.0.0-beta.1.0.6/config2.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.plugin('aurelia-kendoui-bridge'); | |
aurelia.start().then(a => a.setRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment