mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
Add helpers to resize the receiver/sensor plots
This commit is contained in:
parent
e5d2f77f09
commit
c1fc82e0e4
2 changed files with 23 additions and 13 deletions
|
@ -157,10 +157,6 @@ function tab_initialize_receiver() {
|
||||||
|
|
||||||
var samples = 0;
|
var samples = 0;
|
||||||
|
|
||||||
var margin = {top: 20, right: 20, bottom: 10, left: 40};
|
|
||||||
var width = $('#RX_plot').width() - margin.left - margin.right;
|
|
||||||
var height = $('#RX_plot').height() - margin.top - margin.bottom;
|
|
||||||
|
|
||||||
var svg = d3.select("svg");
|
var svg = d3.select("svg");
|
||||||
|
|
||||||
function update_ui() {
|
function update_ui() {
|
||||||
|
@ -212,12 +208,21 @@ function tab_initialize_receiver() {
|
||||||
|
|
||||||
// update required parts of the plot
|
// update required parts of the plot
|
||||||
var widthScale = d3.scale.linear().
|
var widthScale = d3.scale.linear().
|
||||||
domain([(samples - 299), samples]).
|
domain([(samples - 299), samples]);
|
||||||
range([0, width]);
|
|
||||||
|
|
||||||
var heightScale = d3.scale.linear().
|
var heightScale = d3.scale.linear().
|
||||||
domain([800, 2200]).
|
domain([800, 2200]);
|
||||||
range([height, 0]);
|
|
||||||
|
function update_receiver_plot_size() {
|
||||||
|
var margin = {top: 20, right: 20, bottom: 10, left: 40};
|
||||||
|
var width = $('#RX_plot').width() - margin.left - margin.right;
|
||||||
|
var height = $('#RX_plot').height() - margin.top - margin.bottom;
|
||||||
|
widthSclae.range([0, width]);
|
||||||
|
heightScale.range([height, 0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
update_receiver_plot_size();
|
||||||
|
|
||||||
|
|
||||||
var xGrid = d3.svg.axis().
|
var xGrid = d3.svg.axis().
|
||||||
scale(widthScale).
|
scale(widthScale).
|
||||||
|
|
|
@ -40,22 +40,27 @@ function tab_initialize_sensors() {
|
||||||
return sampleNumber + 1;
|
return sampleNumber + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initGraphHelpers(selector, sampleNumber, heightDomain) {
|
function updateGraphHelperSize(selector, helpers) {
|
||||||
var margin = {top: 20, right: 20, bottom: 10, left: 40};
|
var margin = {top: 20, right: 20, bottom: 10, left: 40};
|
||||||
var width = $(selector).width() - margin.left - margin.right;
|
var width = $(selector).width() - margin.left - margin.right;
|
||||||
var height = $(selector).height() - margin.top - margin.bottom;
|
var height = $(selector).height() - margin.top - margin.bottom;
|
||||||
|
|
||||||
|
helpers.widthScale.range([0, width]);
|
||||||
|
helpers.heightScale.range([height, 0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initGraphHelpers(selector, sampleNumber, heightDomain) {
|
||||||
var helpers = {selector: selector, dynamicHeightDomain: !heightDomain};
|
var helpers = {selector: selector, dynamicHeightDomain: !heightDomain};
|
||||||
|
|
||||||
helpers.widthScale = d3.scale.linear()
|
helpers.widthScale = d3.scale.linear()
|
||||||
.clamp(true)
|
.clamp(true)
|
||||||
.domain([(sampleNumber - 299), sampleNumber])
|
.domain([(sampleNumber - 299), sampleNumber]);
|
||||||
.range([0, width]);
|
|
||||||
|
|
||||||
helpers.heightScale = d3.scale.linear()
|
helpers.heightScale = d3.scale.linear()
|
||||||
.clamp(true)
|
.clamp(true)
|
||||||
.domain(heightDomain || [1, -1])
|
.domain(heightDomain || [1, -1]);
|
||||||
.range([height, 0]);
|
|
||||||
|
updateGraphHelperSize(selector, helpers);
|
||||||
|
|
||||||
helpers.xGrid = d3.svg.axis()
|
helpers.xGrid = d3.svg.axis()
|
||||||
.scale(helpers.widthScale)
|
.scale(helpers.widthScale)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue