Function create graph in C3js don't show inside a event Meteor.js

47 Views Asked by At

I have a event who create a graph in C3.js inside a div. And When I call my function who create my graph I see my console.log() and my graph is not create.

Template.home.events({      
    'click .zone': function(event){
        //alert(event.target.id);
        var mydiv = "#" + $(event.target).attr("id");
        console.log(name);
        $("mydiv").remove();
        $("mydiv").on(create());
      }    
});

function create(){
  console.log("inside create");
      var chart = c3.generate({
            bindto: '#graphItem0_2',
            data: {
              columns: [
                ['data1', 30, 200, 100, 400, 150, 250],
                ['data2', 50, 20, 10, 40, 15, 25]
              ],
              empty: {
                label: {
                  text: "No Data"
                }
              }
            }
        });
  console.log("End create");
}

my template :

<template name="graphDisplayer">
    <div class="zone">
      <svg id="graphItemt0_2" with="300" height="300"></svg>
    </div>
</template>
1

There are 1 best solutions below

1
On BEST ANSWER

You have quoted "mydiv" but it is a variable:

    $("mydiv").remove();
    $("mydiv").on(create());

Should be

    $(mydiv).remove();
    $(mydiv).on(create());