Skip to content

Commit

Permalink
Merge pull request #454 from Kitware/fix-sizing
Browse files Browse the repository at this point in the history
Fix sizing of Geo, GeoDots, LineUp
  • Loading branch information
jeffbaumes committed Oct 19, 2016
2 parents 7aee8e0 + 449ce38 commit 576d3b7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions python/pycandela/pycandela/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
require.config({
paths: {
candela: 'https://unpkg.com/candela/dist/candela'
// To test unreleased candela: comment above, uncomment below,
// start jupyter-notebook from base of candela checkout,
// and navigate to python/pycandela before creating notebook.
// candela: '/files/build/candela/candela'
},
urlArgs: null
});
Expand Down
8 changes: 7 additions & 1 deletion src/candela/components/Geo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import geojs from 'geojs/geo.js';
import VisComponent from '../../VisComponent';

export default class Geo extends VisComponent {
constructor (el, {map = {}, layers = []}) {
constructor (el, {map = {}, layers = [], width, height}) {
super(el);

width = width || map.width || 600;
height = height || map.height || 600;

el.style.width = width + 'px';
el.style.height = height + 'px';

// Construct a GeoJS map object based on the requested options.
this.plot = geojs.map(Object.assign({
node: el
Expand Down
Binary file modified src/candela/components/Geo/test/geo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/candela/components/GeoDots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export default class GeoDots extends VisComponent {
constructor (el, options) {
super(el);

let width = options.width || 600;
let height = options.height || 600;

el.style.width = width + 'px';
el.style.height = height + 'px';

let sizeTransform = 5;
if (options.size) {
const range = minmax(options.data.map(d => d[options.size]));
Expand Down
Binary file modified src/candela/components/GeoDots/test/geodots.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/candela/components/LineUp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export default class LineUp extends VisComponent {

constructor (el, options) {
super(el);

let width = options.width || 800;
let height = options.height || 600;

el.style.width = width + 'px';
el.style.height = height + 'px';

this.options = options;
this.lineUpConfig = {
interaction: {
Expand Down
2 changes: 1 addition & 1 deletion src/candela/components/LineUp/test/lineup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('LineUp component', t => {
$('body').append($('<div/>').attr({id: 'elem'}).css({width: 800, height: 600}));
t.ok(LineUp, 'LineUp exists');
t.ok(LineUp.options, 'LineUp options exists');
let lu = new LineUp('#elem', {
let lu = new LineUp(document.getElementById('elem'), {
data: [
{a: 1, b: 2, c: 'a', d: true},
{a: 3, b: 4, c: 'b', d: false},
Expand Down

0 comments on commit 576d3b7

Please sign in to comment.