comparison interfaces/horizontal-sliders.js @ 3039:91d923c51e90

#78 Implemented for horizontal
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 26 Sep 2017 11:51:42 +0100
parents 1620cbee9111
children 38d2150045f5
comparison
equal deleted inserted replaced
3038:4927dc84e86d 3039:91d923c51e90
396 } 396 }
397 397
398 function drawScale() { 398 function drawScale() {
399 var interfaceObj = testState.currentStateMap.interfaces[0]; 399 var interfaceObj = testState.currentStateMap.interfaces[0];
400 var scales = testState.currentStateMap.interfaces[0].scales; 400 var scales = testState.currentStateMap.interfaces[0].scales;
401 var ticks = specification.interfaces.options.concat(interfaceObj.options).find(function (a) {
402 return (a.type == "show" && a.name == "ticks");
403 });
404 if (ticks !== undefined) {
405 ticks = true;
406 } else {
407 ticks = false;
408 }
401 scales = scales.sort(function (a, b) { 409 scales = scales.sort(function (a, b) {
402 return a.position - b.position; 410 return a.position - b.position;
403 }); 411 });
404 var canvas = document.getElementById('scale-canvas'); 412 var canvas = document.getElementById('scale-canvas');
405 var ctx = canvas.getContext("2d"); 413 var ctx = canvas.getContext("2d");
416 posPix = 1; 424 posPix = 1;
417 } 425 }
418 if (posPix >= width) { 426 if (posPix >= width) {
419 posPix = width - 1; 427 posPix = width - 1;
420 } 428 }
421 ctx.moveTo(posPix, 0); 429 if (ticks) {
422 ctx.lineTo(posPix, height); 430 ctx.moveTo(posPix, 0);
423 ctx.stroke(); 431 ctx.lineTo(posPix, height);
432 ctx.stroke();
433 }
424 434
425 var text = document.createElement('div'); 435 var text = document.createElement('div');
426 text.align = "center"; 436 text.align = "center";
427 var textC = document.createElement('span'); 437 var textC = document.createElement('span');
428 textC.textContent = scale.text; 438 textC.textContent = scale.text;