From 7189a8fcfbb789ebc2456f20138641a050d82189 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Fri, 29 Jun 2012 04:33:09 -0400 Subject: [PATCH] And we have charts! easier than i thought it would be :o --- src/app/index.coffee | 26 +++++++++++++++++++++----- views/app/index.html | 17 +++++++++-------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/app/index.coffee b/src/app/index.coffee index b4b935bd9c..6bc7ca237c 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -240,11 +240,27 @@ ready (model) -> # Derby extends model.at to support creation from DOM nodes model.at(e.target).remove() - exports.toggleMeta = (e, el) -> - selector = $(el).attr('data-selector') - if selector.charAt(0) == '$' - selector = '\\' + selector - $('#'+selector).toggle() + exports.toggleEdit = (e, el) -> + task = model.at $(el).parents('li')[0] + $('#\\' + task.get('id') + '-chart').hide() + $('#\\' + task.get('id') + '-edit').toggle() + + exports.toggleChart = (e, el) -> + task = model.at $(el).parents('li')[0] + $('#\\' + task.get('id') + '-edit').hide() + $('#\\' + task.get('id') + '-chart').toggle() + + matrix = [['Date', 'Score']] + for obj in task.get('history') + matrix.push [obj.date, obj.value] + data = google.visualization.arrayToDataTable matrix + + options = { + title: 'History' + } + + chart = new google.visualization.LineChart(document.getElementById( task.get('id') + '-chart' )) + chart.draw(data, options) exports.vote = (e, el, next) -> direction = $(el).attr('data-direction') diff --git a/views/app/index.html b/views/app/index.html index 653fc3fa93..50fdb9742b 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -107,9 +107,9 @@
- + {#if :task.history} - + {/}
@@ -166,12 +166,7 @@ - + Fork me on GitHub @@ -186,3 +181,9 @@ + + + \ No newline at end of file