Plot de jQuery en enyo
Podemos incluir la librería de jQuery con hasnode
by EDWIN MAURICIO QUISHPE MALDONADO
HTML
<script src="http://enyojs.com/enyo-2.0b/enyo.js"></script>
<script src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>
JavaScript
// added enyo, jQuery, and jQuery.flot as resources in jsfiddle
enyo.kind({
name:"jquery.Flot",
kind:"Control",
published:{
data:null
},
rendered:function() {
if(!this.hasNode()) return;
this.dataChanged();
},
dataChanged:function() {
this.plot();
},
plot:function() {
var n = this.hasNode();
if(!n || !enyo.isArray(this.data)) return;
jQuery.plot(jQuery(n), this.data);
}
});
enyo.kind({
name:"ex.App",
kind:"Control",
components:[
{kind:"jquery.Flot", name:"flot", style:"width:400px;height:300px;"},
],
create:function() {
this.inherited(arguments);
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
// a null signifies separate line segments
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
this.$.flot.setData([d1, d2, d3]);
}
});
new ex.App().renderInto(document.body)