-
-
Save gist-master/e750c35511eb82de377b5a96536de877 to your computer and use it in GitHub Desktop.
Pie charts: binding to remote data
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> | |
<require from="./binding-to-remote-data.css"></require> | |
<div class="row" id="pie-charts-remote-data"> | |
<div class="col-xs-12 col-sm-2" repeat.for="year of years"> | |
<ak-chart class="pie-chart" | |
k-title.bind="{ text: year }" | |
k-data-source.bind="getDatasource(year)" | |
k-legend.bind="legend" | |
k-series-defaults.bind="seriesDefaults" | |
k-series.bind="series" | |
k-tooltip.bind="tooltip"> | |
</ak-chart> | |
</div> | |
</div> | |
</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 resolution from './screen_resolution.json!json'; | |
export class BindingToRemoteData { | |
years = [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009]; | |
seriesDefaults = { | |
type: 'pie' | |
}; | |
legend = { | |
position: 'top' | |
}; | |
series = [{ | |
field: 'share', | |
categoryField: 'resolution', | |
padding: 0 | |
}]; | |
tooltip = { | |
visible: true, | |
format: 'N0', | |
template: '#= category # - #= kendo.format("{0:P}", percentage)#' | |
} | |
getDatasource(year) { | |
return new kendo.data.DataSource({ | |
transport: { | |
read: function(options) { | |
options.success(resolution); | |
} | |
}, | |
filter: { | |
field: 'year', operator: 'eq', value: year | |
}, | |
sort: { | |
field: 'year', | |
dir: 'asc' | |
} | |
}); | |
} | |
} |
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
.k-chart { | |
height: 120px; | |
width: 125px | |
} |
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()); | |
} |
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
[{ | |
"year": 2000, | |
"resolution": "1024x768", | |
"share": 25, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2000, | |
"resolution": "Other", | |
"share": 75, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2001, | |
"resolution": "1024x768", | |
"share": 29, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2001, | |
"resolution": "Other", | |
"share": 71, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2002, | |
"resolution": "1024x768", | |
"share": 34, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2002, | |
"resolution": "Other", | |
"share": 66, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2003, | |
"resolution": "1024x768", | |
"share": 40, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2003, | |
"resolution": "Other", | |
"share": 60, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2004, | |
"resolution": "1024x768", | |
"share": 47, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2004, | |
"resolution": "Other", | |
"share": 53, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2005, | |
"resolution": "1024x768", | |
"share": 53, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2005, | |
"resolution": "Other", | |
"share": 47, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2006, | |
"resolution": "1024x768", | |
"share": 57, | |
"visibleInLegend": false, | |
"order": 1, | |
"color": "#c00" | |
},{ | |
"year": 2006, | |
"resolution": "Other", | |
"share": 43, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2007, | |
"resolution": "1024x768", | |
"share": 54, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2007, | |
"resolution": "Other", | |
"share": 46, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2008, | |
"resolution": "1024x768", | |
"share": 48, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2008, | |
"resolution": "Other", | |
"share": 52, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
},{ | |
"year": 2009, | |
"resolution": "1024x768", | |
"share": 36, | |
"visibleInLegend": false, | |
"order": 1 | |
},{ | |
"year": 2009, | |
"resolution": "Other", | |
"share": 64, | |
"visibleInLegend": false, | |
"order": 2, | |
"color": "#ccc" | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment