Skip to content

Instantly share code, notes, and snippets.

@robdodson
Created July 31, 2014 15:33
Show Gist options
  • Select an option

  • Save robdodson/c58b92e81fb4fecd3037 to your computer and use it in GitHub Desktop.

Select an option

Save robdodson/c58b92e81fb4fecd3037 to your computer and use it in GitHub Desktop.
chart-pie
<polymer-element name="chart-pie" attributes="values colors width height">
<template>
<style>
:host {
display: inline-block;
}
</style>
<canvas id="canvas" width="{{width}}" height="{{height}}"></canvas>
</template>
<script>
Polymer({
ready: function () {
this.data = [];
this.values.forEach(function (val, i) {
this.data.push({ color: this.colors[i], value: val });
}, this);
this.ctx = this.$.canvas.getContext('2d');
this.chart = new Chart(this.ctx).Pie(this.data);
},
values: [30, 50, 100, 40, 120],
colors: ["#F7464A", "#46BFBD", "#FDB45C", "#949FB1", "#4D5360"]
});
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment