vendredi 15 janvier 2016

Passing model to component

I'm trying to display a chart using Ember.js. I tried to load data from the model from the component "multiple-line.js" like so:

{{multiple-line datagroup=model}}

Route

model: function() {
    return this.store.findAll('datagroup');
}

Models/datagroup.js

App.Datagroup = DS.Model.extend({datasets: DS.hasMany('dataset')});

Models/dataset.js

App.Dataset = DS.Model.extend({
  datagroup: DS.belongsTo('datagroup'),
  key: attr('string'),
  values: DS.hasMany('value')
});

Models/datagroup.js

App.Value = DS.Model.extend({
  dataset: DS.belongsTo('dataset'),
  xValue: DS.attr('number'),
  yValue: DS.attr('number')
});

Adapters/Application.js That start by :

findAll: function() {
  return {
    "Cbio": [{
      "xValue": 1,
      "yValue": 21.969
    },{
      "xValue": 2,
      "yValue": 44.0294
    }, ...

I didn't combine all the code for displaying my D3.js's Chart in the component. So How can I use Model/Adapter/Route/Component for this application correctly. Here is a JsBin with the code.




Aucun commentaire:

Enregistrer un commentaire