score:2

Accepted answer

i have previously built an application using marionette and highcharts so i think i can speak to this from some experience.

there's more than one way to go about this but in general unless you have some special reason you would just want to have one marionette app running. i can't tell if you're trying to display two views at the same time in the same region but in case you are this is definitely not possible--as soon as you show the second view the first will be removed from the dom.

anyways on to your questions: the simplest way (and the way i have done this) is to use an itemview and draw the chart in the onrender() method. so it will look something like this:

var myview = marionette.itemview.extend({

  template: _.template('<div class="chart-container" style="height: 325px;"></div>'),

  onrender: function() {
    this.$('.chart-container').highcharts({
        ...highcharts options here
    })
  }

});

then when you're ready to display it you'll create an instance and show it in the region:

var view = new myview();
graph1manager.nameofregion.show(view);

whenever you show another view in the region the previous one will automatically close so remember you'll have to create a new instance of it if you want to use it again...


Related Query

More Query from same tag