added ability to update chart data

This commit is contained in:
Luis Correa d'Almeida 2012-10-16 16:30:53 +01:00
parent 30206c1355
commit a727a3a23a
4 changed files with 38 additions and 1 deletions

27
examples/pie.html Normal file
View File

@ -0,0 +1,27 @@
<!doctype html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://raw.github.com/DmitryBaranovskiy/raphael/300aa589f5a0ba7fce667cd62c7cdda0bd5ad904/raphael-min.js"></script>
<script src="../morris.js"></script>
<script src="lib/prettify.js"></script>
<script src="lib/example.js"></script>
<link rel="stylesheet" href="lib/example.css">
<link rel="stylesheet" href="lib/prettify.css">
</head>
<body>
<h1>Pie chart</h1>
<div id="pie"></div>
<pre id="code" class="prettyprint linenums">
data = [
{ label: "2010", value: 12 },
{ label: "2011", value: 15 },
{ label: "2012", value: 19 },
{ label: "2013", value: 28 }
]
Morris.Pie({ element: "pie", data: data, enhanceMax: true })
</pre>
</body>

View File

@ -42,6 +42,11 @@ class Morris.Pie
@draw()
setData: (data)->
@data = data
@draw()
draw: ->
@paper.clear()

View File

@ -1023,6 +1023,11 @@
this.draw();
}
Pie.prototype.setData = function(data) {
this.data = data;
return this.draw();
};
Pie.prototype.draw = function() {
var color, currentAngle, cx, cy, index, label, labelAndValue, max, pieSegment, r, step, total, value, x, _i, _j, _len, _len1, _ref, _ref1, _results;
this.paper.clear();

2
morris.min.js vendored

File diff suppressed because one or more lines are too long