Skip to content

Commit

Permalink
WIP: style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbekolay committed Aug 22, 2016
1 parent adf698c commit b13b815
Show file tree
Hide file tree
Showing 43 changed files with 2,905 additions and 2,549 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ out/

# TypeScript
typings/

# JS files associated with tests
**/tests/*.js
52 changes: 34 additions & 18 deletions nengo_gui/static/components/2d_axes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,35 @@
*/

import * as d3 from "d3";
import * as $ from "jquery";

export default class Axes2D {
ax_bottom;
ax_left;
ax_right;
ax_top;
axis_x;
axis_x_g;
axis_y;
axis_y_g;
height;
max_y_width;
min_height;
min_width;
scale_x;
scale_y;
svg;
tick_padding;
tick_size;
width;

constructor(parent, args) {
var self = this;

this.max_y_width = 100;

// Draw the plot as an SVG
this.svg = d3.select(parent).append('svg')
.attr('width', '100%')
.attr('height', '100%');
this.svg = d3.select(parent).append("svg")
.attr("width", "100%")
.attr("height", "100%");

// Scales for mapping x and y values to pixels
this.scale_x = d3.scale.linear();
Expand Down Expand Up @@ -54,7 +71,7 @@ export default class Axes2D {
};

set_axes_geometry(width, height) {
var scale = parseFloat($('#main').css('font-size'));
const scale = parseFloat($("#main").css("font-size"));
this.width = width;
this.height = height;
this.ax_left = this.max_y_width;
Expand All @@ -70,12 +87,12 @@ export default class Axes2D {
* Adjust the graph layout due to changed size
*/
on_resize(width, height) {
if (width < this.minWidth) {
width = this.minWidth;
if (width < this.min_width) {
width = this.min_width;
}
if (height < this.min_height) {
height = this.min_height;
}
if (height < this.minHeight) {
height = this.minHeight;
};
this.set_axes_geometry(width, height);

this.scale_x.range([this.ax_left, this.ax_right]);
Expand All @@ -96,20 +113,19 @@ export default class Axes2D {
};

fit_ticks(parent) {
var self = this;
const self = this;
setTimeout(function() {
var ticks = $(parent.div).find('.tick');
var max_w = 0;
for (var i = 0; i < ticks.length; i++) {
var w = ticks[i].getBBox().width;
const ticks = $(parent.div).find(".tick");
let max_w = 0;
for (let i = 0; i < ticks.length; i++) {
const w = (<any> ticks[i]).getBBox().width;
if (w > max_w) {
max_w = w;
}
}
self.max_y_width = max_w;
self.set_axes_geometry();
self.set_axes_geometry(parent.width, parent.height); // TODO: parent?
self.on_resize(parent.width, parent.height);
}, 1);
};

}
Loading

0 comments on commit b13b815

Please sign in to comment.