From 17a1f749d166f4c8ccae562feb4ab538edf4bf22 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Thu, 8 Sep 2011 13:06:40 -0400 Subject: [PATCH] Save hidden serieses as well. --- collects/meta/drdr/static/chart.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/collects/meta/drdr/static/chart.js b/collects/meta/drdr/static/chart.js index f3e12e279a..951988ad11 100644 --- a/collects/meta/drdr/static/chart.js +++ b/collects/meta/drdr/static/chart.js @@ -28,6 +28,7 @@ var options = { selection: { mode: "xy" }, function legend_click(l) { show_hide[l] = !show_hide[l]; show(); + serialize_opts(options); } var placeholder = $("#_chart"); @@ -100,7 +101,6 @@ function load_data(d) { overall_times = []; sub_times = []; pdata = [] - reset_chart(); data = d; pdata = data && JSON.parse(data); @@ -163,7 +163,7 @@ function show() { $.plot(placeholder, chart_data, cur_options); } -function serialize_zoom(options) { +function serialize_opts(options) { var o = {}; if (options.xaxes[0].min) o.xmin = options.xaxes[0].min; @@ -173,14 +173,14 @@ function serialize_zoom(options) { o.ymin = options.yaxes[0].min; if (options.yaxes[0].max) o.ymax = options.yaxes[0].max; - window.location.hash = "#" + (JSON.stringify(o)); + window.location.hash = "#" + (JSON.stringify([o,show_hide])); } function handle_selection(event, ranges) { cur_options = $.extend(true, {}, cur_options, { yaxes: [ { min: ranges.yaxis.from, max: ranges.yaxis.to },cur_options.yaxes[1]], xaxes: [ { min: ranges.xaxis.from, max: ranges.xaxis.to } ]}); - serialize_zoom(cur_options); + serialize_opts(cur_options); show(); } @@ -210,8 +210,12 @@ try { } catch(e) {} if (opts) { - cur_options.xaxes[0].min = opts.xmin; - cur_options.xaxes[0].max = opts.xmax; - cur_options.yaxes[0].min = opts.ymin; - cur_options.yaxes[0].max = opts.ymax; + cur_options.xaxes[0].min = opts[0].xmin; + cur_options.xaxes[0].max = opts[0].xmax; + cur_options.yaxes[0].min = opts[0].ymin; + cur_options.yaxes[0].max = opts[0].ymax; + for(i in opts[1]) { + console.log(i,opts[1][i]); + show_hide[i] = opts[1][i]; + } }