diff --git a/app/components/line-chart.js b/app/components/line-chart.js index eab77dd..f2c9ff6 100644 --- a/app/components/line-chart.js +++ b/app/components/line-chart.js @@ -1,17 +1,24 @@ import Ember from 'ember'; -const { Component, computed } = Ember; - export default Ember.Component.extend({ - tagName: 'canvas', + tagName: 'div', classNames: ['line-chart'], - didInsertElement: function() { - // create chart - var element = this.get('element'); - this.chart = new Chart(element.getContext('2d')); - this.chart.Line(this.chartData, { + init: function() { + this._super(); + this.addObserver('data', this.dataDidChange); + }, - }); + didInsertElement: function() { + this._drawPlot(); + }, + + dataDidChange: function() { + this._drawPlot(); + }, + + _drawPlot: function() { + var elementId = this.get('elementId'); + $.plot('#' + elementId, this.data); } }); diff --git a/app/routes/lab-mashup/entity/property.js b/app/routes/lab-mashup/entity/property.js index b2a2a2b..a01e1c6 100644 --- a/app/routes/lab-mashup/entity/property.js +++ b/app/routes/lab-mashup/entity/property.js @@ -10,9 +10,9 @@ export default Ember.Route.extend({ return record; }, - chartData() { + chartData: function() { return { name: 'test' }; - } + }.property() }); diff --git a/app/styles/app.css b/app/styles/app.css index 2549145..b8f10a6 100644 --- a/app/styles/app.css +++ b/app/styles/app.css @@ -124,9 +124,9 @@ footer { margin: 0; } -canvas.line-chart { - width: 90%; - height: 90%; +.line-chart { + width: 500px; + height: 300px; margin: 10px; } diff --git a/app/templates/components/line-chart.hbs b/app/templates/components/line-chart.hbs index 8b13789..8120e4e 100644 --- a/app/templates/components/line-chart.hbs +++ b/app/templates/components/line-chart.hbs @@ -1 +1,10 @@ + diff --git a/app/templates/lab-mashup/entity/property.hbs b/app/templates/lab-mashup/entity/property.hbs index 4ff2748..cc45aeb 100644 --- a/app/templates/lab-mashup/entity/property.hbs +++ b/app/templates/lab-mashup/entity/property.hbs @@ -1,7 +1,12 @@ -{{#if property}} -

{{property.name}}

+{{#if model.name}} +

Model: {{model.name}}, {{model.history.[0].length}}

{{/if}} -{{chartData.name}} +{{#if chartData}} +

{{chartData.name}}

+{{else}} +

No chart data

+{{/if}} -{{flot-chart height="500px" data=model.history}} + +{{line-chart data=model.history}}