0

There is a jquery function which passes value to the donut chart and updates the chart when function is called.but i want to call the jquery function in coffee script.

how can i do that?

Here's what i have tried.i am getting error 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());
4

0 回答 0