javascript - On select highlight related table cell on xy axis -


i have table looks chart.

quick view:

enter image description here

how can make table work area selection chart? example if select 6, the (x, y) of element 6 (2, 1). minimum related area include elements @ positions (0,0), (0,1), (1,0), (1,1), (2,0), (2,1) should highlighted. therefore, grids '0,3,1,4,2,6' highlighted. this:

enter image description here

similarly,

-if select 3 highlight 0,3 grids

enter image description here

-if select 2 highlight 0,1,2 grids

enter image description here

i know less js make type of actions. save day. plunker

so, others, puzzled bit trying do. there seems break in consistency examples gave. if want highlight along x,y axis little different have shown.
either way, threw together, perhaps started:

plunker

it shown in picture 1 , 3, though not picture 2.

  $scope.boxes = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']   $scope.boxclass = ['cone', 'ctwo', 'cthree', 'cfour', 'cfive', 'csix', 'cseven', 'ceight', 'cnine']    $scope.boxes.reverse();   console.log($scope.boxes)    $scope.findchecked = function () {     (var = 0; < $scope.boxes.length; i++){       if ($scope[$scope.boxes[i]]) {         $scope.currentbox = 9 -         console.log($scope.currentbox)         break;       }     }      (var x = 0; x < $scope.boxclass.length; x++) {       if (x < $scope.currentbox) {         $scope[$scope.boxclass[x]] = 'checked'       } else {          $scope[$scope.boxclass[x]] = ''       }     }     } 

if want highlight along along x,y coordinates, can this:

  var row1 = ['cone', 'ctwo', 'cthree'];   var row2 = ['cfour', 'cfive', 'csix'];   var row3 = ['cseven', 'ceight', 'cnine'];   var col1 = ['cone', 'cfour', 'cseven'];   var col2 = ['ctwo', 'cfive', 'ceight'];   var col3 = ['cthree', 'csix', 'cnine'];    var rows = [row1, row2, row3];   var cols = [col1, col2, col3];    $scope.setxy = function(x, y) {     console.log(x, y)     var = 0, z = 0;     for(i = 0; < rows.length; i++) {       for(z = 0; z < rows[i].length; z++) {         $scope[rows[i][z]] = '';         $scope[cols[i][z]] = '';       }     }      for(i = 0; < 3; i++) {       $scope[rows[y][i]] = 'checked';       $scope[cols[x][i]] = 'checked';     }   } 

plunker (i used buttons time...works bit better)


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -