history.append([time.time(), history[-1][1]])
for row in history:
row[0] *= 1000.
- return {'history': history}
+ pv_index = CONFIG['PV_lookup'][name]
+ precision = CONFIG['PVs'][pv_index]['precision']
+ return {'history': history, 'precision': precision}
@route('/static/<path:path>')
def static_content(path):
// defaults
var width = 200;
var height = 40;
+ var precision = null;
var dataSource = '';
var dataSourceType = '';
var selector = 'body';
return chart;
};
+ chart.precision = function(value) {
+ if (!arguments.length) return precision;
+ precision = value;
+ return chart;
+ };
+
chart.dataSource = function(value) {
if (!arguments.length) return dataSource;
dataSource = value;
} else {
d3.json(chart.dataSource(), function(error, json) {
if (error) return drawChart(error, json);
+ chart.precision(json.precision);
drawChart(error, json.history);
});
}
//console.log(x(d[0]));
//console.log(y(d[1]));
focus.attr("transform", "translate(" + x(d[0]) + "," + y(d[1]) + ")");
- tooltip_val.text(d[1]);
+ var val = d[1];
+ if (precision != null)
+ val = val.toFixed(precision);
+ tooltip_val.text(val);
var iso_date = d[0].toISOString();
tooltip_ts.text(iso_date.slice(11, 11+10));
}