I am building a simple data visualization that shows the share of device type based on the total number of records. I am wondering if there is a way to compute a property based on all elements in the Fixture.
App.Devices = DS.Model.extend({
label: DS.attr('string'),
measure: DS.attr('number'),
share: function() {
//code to return measure / fixtureTotal
}.property('measure')
});
App.Devices.FIXTURES = [
{ id: "0", label: "Computer", measure: 10 },
{ id: "1", label: "Mobile", measure: 20 },
{ id: "2", label: "Tablet", measure: 30 }
] // fixtureTotal = 60
So in this case "Computers" would have a (10/60) share of the total records.
Can this be accomplished with computed properties or does it require another solution? Ideally this solution would work with a fixtureAdaptor or RESTAdaptor
Thanks