有一个jquery函数将值传递给圆环图并在调用函数时更新图表。但我想在咖啡脚本中调用jquery函数。
我该怎么做?
这是我尝试过的。我收到错误Uncaught ReferenceError: get_data1 is not defined
的script.js
$( document ).ready(function() {
function get_data() {
var props = ["Slice1","Slice2","Slice3"];
var out = [];
//for (var i = 0; i <= 6; i++) {
out.push({"name":props[1], "hvalue": 30});
out.push({"name":props[2], "hvalue": 20});
out.push({"name":props[3], "hvalue": 50});
//};
return out;
}
function get_data1() {
var props = ["Slice1","Slice2","Slice3"];
var out = [];
//for (var i = 0; i <= 6; i++) {
out.push({"name":props[1], "hvalue": 50});
out.push({"name":props[2], "hvalue": 40});
out.push({"name":props[3], "hvalue": 10});
//};
return out;
}
$(".exp").donutpie();
$(".exp").donutpie('update', get_data());
$(".exp").donutpie('update', get_data1()); //I need to call this on coffee script
});
App.coffee
sketchlayer = new Layer
width:400
height:400
x:426
y:126
backgroundColor: ""
opacity: 1
sketchlayer.html = "<div class='exp' width='315' height='315'></div>"
buttonlayer = new Layer
width:100
height:40
backgroundColor:"red"
buttonlayer.onClick -> $(".exp").donutpie('update', get_data1());