mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
added ability to update chart data
This commit is contained in:
parent
30206c1355
commit
a727a3a23a
27
examples/pie.html
Normal file
27
examples/pie.html
Normal 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>
|
@ -42,6 +42,11 @@ class Morris.Pie
|
||||
|
||||
@draw()
|
||||
|
||||
setData: (data)->
|
||||
|
||||
@data = data
|
||||
@draw()
|
||||
|
||||
draw: ->
|
||||
|
||||
@paper.clear()
|
||||
|
@ -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
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user