reorganizing update helpers

10.3.x-maintenance
cTn 2014-04-21 12:14:03 +02:00
parent 3421916c21
commit 3a5741d9ed
2 changed files with 19 additions and 21 deletions

View File

@ -156,9 +156,18 @@ function tab_initialize_receiver() {
}
var samples = 0;
var svg = d3.select("svg");
var width, height, widthScale, heightScale;
function update_receiver_plot_size() {
var margin = {top: 20, right: 20, bottom: 10, left: 40};
width = $('#RX_plot').width() - margin.left - margin.right;
height = $('#RX_plot').height() - margin.top - margin.bottom;
widthScale.range([0, width]);
heightScale.range([height, 0]);
}
function update_ui() {
meter_array[0].val(RC.throttle);
meter_values_array[0].text('[ ' + RC.throttle + ' ]');
@ -207,24 +216,14 @@ function tab_initialize_receiver() {
}
// update required parts of the plot
var widthScale = d3.scale.linear().
widthScale = d3.scale.linear().
domain([(samples - 299), samples]);
var heightScale = d3.scale.linear().
heightScale = d3.scale.linear().
domain([800, 2200]);
var margin, width, height;
function update_receiver_plot_size() {
margin = {top: 20, right: 20, bottom: 10, left: 40};
width = $('#RX_plot').width() - margin.left - margin.right;
height = $('#RX_plot').height() - margin.top - margin.bottom;
widthScale.range([0, width]);
heightScale.range([height, 0]);
}
update_receiver_plot_size();
var xGrid = d3.svg.axis().
scale(widthScale).
orient("bottom").

View File

@ -40,14 +40,13 @@ function tab_initialize_sensors() {
return sampleNumber + 1;
}
var margin, width, height;
function updateGraphHelperSize(selector, helpers) {
margin = {top: 20, right: 20, bottom: 10, left: 40};
width = $(selector).width() - margin.left - margin.right;
height = $(selector).height() - margin.top - margin.bottom;
var margin = {top: 20, right: 20, bottom: 10, left: 40};
helpers.width = $(selector).width() - margin.left - margin.right;
helpers.height = $(selector).height() - margin.top - margin.bottom;
helpers.widthScale.range([0, width]);
helpers.heightScale.range([height, 0]);
helpers.widthScale.range([0, helpers.width]);
helpers.heightScale.range([helpers.height, 0]);
}
function initGraphHelpers(selector, sampleNumber, heightDomain) {
@ -67,14 +66,14 @@ function tab_initialize_sensors() {
.scale(helpers.widthScale)
.orient("bottom")
.ticks(5)
.tickSize(-height, 0, 0)
.tickSize(-helpers.height, 0, 0)
.tickFormat("");
helpers.yGrid = d3.svg.axis()
.scale(helpers.heightScale)
.orient("left")
.ticks(5)
.tickSize(-width, 0, 0)
.tickSize(-helpers.width, 0, 0)
.tickFormat("");
helpers.xAxis = d3.svg.axis()