Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor parcoords - bug fixes - reuse axes ticktext - support pseudo html labels - features for label angle & position #3966

Merged
merged 70 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
b050eec
refactor parcoords - lims > limits
archmoj May 28, 2019
57c0abd
refactor parcoords - replace Array.apply with simple fill method
archmoj May 29, 2019
321b73a
refactor parcoords - i > i0 - ii > i1
archmoj May 29, 2019
e7f18af
refactor parcoords - simplify plot sorter function
archmoj May 29, 2019
e5304b1
refactor parcoords - dim1 > dim0
archmoj May 29, 2019
dd65f3f
refactor parcoords - dim2 > dim1
archmoj May 29, 2019
be5df36
refactor parcoords - pass1 - add highp flags - move imports to the to…
archmoj May 29, 2019
55a5018
refactor parcoords - remove one more argument to position functions
archmoj May 29, 2019
9702db6
refactor parcoords - move axisY funcs to main shaders - remove unused…
archmoj May 29, 2019
0c1959c
refactor parcoords - avoid passing complex multi dim mat4 argument be…
archmoj May 29, 2019
51c59e8
refactor parcoords - no need to pass resolution to position functions
archmoj May 29, 2019
3b01429
refactor parcoords - now no need to pass dims to one axisY functions
archmoj May 29, 2019
562973d
refactor parcoords - combine pick and vertex shader programs
archmoj May 29, 2019
3516ba5
refactor parcoords - move position code to single location used now i…
archmoj May 29, 2019
b320638
refactor parcoords - removed many now unused passing arguments
archmoj May 29, 2019
48e091e
refactor parcoords - combine two mod functions into one
archmoj May 29, 2019
f127343
refactor parcoords - remove one more function and adjustment for perf…
archmoj May 29, 2019
947dbe7
refactor parcoords - add function to handle hide logic
archmoj May 29, 2019
fcd4bcb
refactor parcoords - rearrange indices and arguments in makeItem
archmoj May 29, 2019
ac1ace3
refactor parcoords - lint shaders
archmoj May 29, 2019
c05683f
refactor parcoords - remove unused variables and optimize within rast…
archmoj May 29, 2019
5464b4a
refactor parcoords - change functions from inside to outside
archmoj May 30, 2019
5280ce4
refactor parcoords - no need for extra clamping - already between 0 a…
archmoj May 30, 2019
ea6fbe4
refactor parcoords - simplify code
archmoj May 31, 2019
296859f
refactor parcoords - remove non-parametic constants
archmoj May 31, 2019
e89676a
refactor parcoords - cut long variable names and move item.count twea…
archmoj May 31, 2019
b326947
no need to offset texture inputs in vertex shader
archmoj May 31, 2019
592f56b
refactor parcoords - set color info outside position loop
archmoj Jun 1, 2019
b4e285e
bug fix issue 3749 parcoords outside range - add image tests
archmoj Jun 2, 2019
76667c9
refactor parcoords - remove unused colorClamp parameter
archmoj Jun 3, 2019
3a5b4ca
refactor parcoords - add test for 60 dimensions - clean up shader for…
archmoj Jun 3, 2019
286db3b
refactor parcoords - describe panels 1-60 in vertex shaders
archmoj Jun 3, 2019
40de5d9
add image test for parcoords with 256 colors
archmoj Jun 3, 2019
5dfe455
refactor parcoords - use general variable names in plot and base_plot
archmoj Jun 3, 2019
9937208
apply Cartesian axis tickText to format parcoords linear data
archmoj Jun 3, 2019
ca79f97
refactor parcoords - rm root unused variable
archmoj Jun 4, 2019
5cccd86
psuedo-html and mathjax formats in parcoords labels - fix for issue 3206
archmoj Jun 4, 2019
4e749bd
refactor parcoords - get rid of one extra dimension, complex indexing…
archmoj Jun 4, 2019
ccfc81e
improve test for parcoords with 60 dims
archmoj Jun 4, 2019
90c358d
fix mathjax show on image test
archmoj Jun 4, 2019
178273c
implement labelangle for parcoords
archmoj Jun 5, 2019
73f23de
revise various parcoords editType from calc to plot
archmoj Jun 5, 2019
8f23241
use tickvals and ticktext in new parcoords mock
archmoj Jun 5, 2019
b0d3bdd
added jasmine test for parcoords react with editType plot instead of …
archmoj Jun 5, 2019
cc580fe
refactor parcoords - use one vertex shader
archmoj Jun 6, 2019
369eb46
optimize for performance - now no need to update palette for every co…
archmoj Jun 6, 2019
213f965
move 3 functions outside line.js main
archmoj Jun 6, 2019
407d72a
refactor parcoords - using isContext and isPick instead of context & …
archmoj Jun 6, 2019
ebf57f0
apply per dimension tickformat in linear axes ticktext
archmoj Jun 6, 2019
48860c2
fixup tests to run on CI
archmoj Jun 6, 2019
9cbbcbf
dont touch trace data - move handeling of typedarrays from calc to pl…
archmoj Jun 6, 2019
3a4d428
add parcoords labelside (top|bottom) help display tilted labels with …
archmoj Jun 7, 2019
6aad768
revisit contextColor setup
archmoj Jun 7, 2019
6403347
refactor parcoords - better variable names in parcoords plot
archmoj Jun 7, 2019
b5d24e1
refactor parcoords - move nested functions outside plot callbacks
archmoj Jun 7, 2019
1b7c0ef
centralize functions in parcoords helpers
archmoj Jun 7, 2019
c4a7867
move function outside main block
archmoj Jun 7, 2019
8b88690
refactor parcoords - rename dd > e
archmoj Jun 7, 2019
643ba30
reduce number of passing argumnets to parcoords
archmoj Jun 10, 2019
5c5873d
add unselected lines color to constants
archmoj Jun 14, 2019
e79af84
parcoords refactor - rename glLayers
archmoj Jun 14, 2019
4e3452b
make parcoords pick layer totally invisible
archmoj Jun 14, 2019
75f692d
refactor parcoords - init with new Array and use set instead of push
archmoj Jun 17, 2019
11b9434
mock separated linear axes for every dimension
archmoj Jun 17, 2019
9e73c27
ticktext is now set for each parcoords dimension
archmoj Jun 18, 2019
a80bf49
implement cartesian axis for parcoords and change parcoords tickforma…
archmoj Jun 19, 2019
97f61b6
add noCI tags for two more parcoords tests
archmoj Jun 20, 2019
dea5317
Merge branch 'master' into refactor-parcoords-bug-fixes-labelangle-side
etpinard Jun 20, 2019
c8dedcb
coerce range then create axis
archmoj Jun 20, 2019
2228339
make parcoords + uirevision test pass on CI
etpinard Jun 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
83 changes: 43 additions & 40 deletions src/traces/parcoords/lines.js
Expand Up @@ -265,14 +265,14 @@ module.exports = function(canvasGL, d) {
resolution: regl.prop('resolution'),
viewBoxPosition: regl.prop('viewBoxPosition'),
viewBoxSize: regl.prop('viewBoxSize'),
dim0A: regl.prop('dim0A'),
dim1A: regl.prop('dim1A'),
dim2A: regl.prop('dim2A'),
dim0B: regl.prop('dim0B'),
dim1B: regl.prop('dim1B'),
dim2B: regl.prop('dim2B'),
dim0C: regl.prop('dim0C'),
dim1C: regl.prop('dim1C'),
dim2C: regl.prop('dim2C'),
dim0D: regl.prop('dim0D'),
dim1D: regl.prop('dim1D'),
dim2D: regl.prop('dim2D'),
loA: regl.prop('loA'),
hiA: regl.prop('hiA'),
loB: regl.prop('loB'),
Expand Down Expand Up @@ -317,9 +317,9 @@ module.exports = function(canvasGL, d) {

var previousAxisOrder = [];

function makeItem(i, ii, x, y, panelSizeX, canvasPanelSizeY, crossfilterDimensionIndex, I, leftmost, rightmost, constraints) {
function makeItem(i0, i1, x, y, panelSizeX, canvasPanelSizeY, crossfilterDimensionIndex, I, leftmost, rightmost, constraints) {
var loHi, abcd, d, index;
var leftRight = [i, ii];
var leftRight = [i0, i1];

var dims = [0, 1].map(function() {return [0, 1, 2, 3].map(function() {return new Float32Array(16);});});

Expand All @@ -342,17 +342,17 @@ module.exports = function(canvasGL, d) {
resolution: [canvasWidth, canvasHeight],
viewBoxPosition: [x + overdrag, y],
viewBoxSize: [panelSizeX, canvasPanelSizeY],
i: i,
ii: ii,

dim1A: dims[0][0],
dim1B: dims[0][1],
dim1C: dims[0][2],
dim1D: dims[0][3],
dim2A: dims[1][0],
dim2B: dims[1][1],
dim2C: dims[1][2],
dim2D: dims[1][3],
i0: i0,
i1: i1,

dim0A: dims[0][0],
dim0B: dims[0][1],
dim0C: dims[0][2],
dim0D: dims[0][3],
dim1A: dims[1][0],
dim1B: dims[1][1],
dim1C: dims[1][2],
dim1D: dims[1][3],

colorClamp: colorClamp,

Expand All @@ -373,7 +373,7 @@ module.exports = function(canvasGL, d) {
function makeConstraints() {
var loHi, abcd, d;

var lims = [0, 1].map(function() {return [0, 1, 2, 3].map(function() {return new Float32Array(16);});});
var limits = [0, 1].map(function() {return [0, 1, 2, 3].map(function() {return new Float32Array(16);});});

for(loHi = 0; loHi < 2; loHi++) {
for(abcd = 0; abcd < 4; abcd++) {
Expand All @@ -383,7 +383,8 @@ module.exports = function(canvasGL, d) {
if(dimP < initialDims.length) {
lim = initialDims[dimP].brush.filter.getBounds()[loHi];
} else lim = loHi;
lims[loHi][abcd][d] = lim + (2 * loHi - 1) * filterEpsilon;

limits[loHi][abcd][d] = lim + (2 * loHi - 1) * filterEpsilon;
}
}
}
Expand All @@ -396,9 +397,11 @@ module.exports = function(canvasGL, d) {
];
}

var mask = Array.apply(null, new Array(maskHeight * channelCount)).map(function() {
return 255;
});
var mask = [];
for(var i = 0; i < maskHeight * channelCount; i++) {
etpinard marked this conversation as resolved.
Show resolved Hide resolved
mask[i] = 255;
}

for(var dimIndex = 0; dimIndex < initialDims.length; dimIndex++) {
var bitIndex = dimIndex % bitsPerByte;
var byteIndex = (dimIndex - bitIndex) / bitsPerByte;
Expand Down Expand Up @@ -432,14 +435,14 @@ module.exports = function(canvasGL, d) {
return {
maskTexture: maskTexture,
maskHeight: maskHeight,
loA: lims[0][0],
loB: lims[0][1],
loC: lims[0][2],
loD: lims[0][3],
hiA: lims[1][0],
hiB: lims[1][1],
hiC: lims[1][2],
hiD: lims[1][3]
loA: limits[0][0],
loB: limits[0][1],
loC: limits[0][2],
loD: limits[0][3],
hiA: limits[1][0],
hiB: limits[1][1],
hiC: limits[1][2],
hiD: limits[1][3]
};
}

Expand All @@ -453,12 +456,12 @@ module.exports = function(canvasGL, d) {
var highestX = -Infinity;

for(I = 0; I < panelCount; I++) {
if(panels[I].dim2.canvasX > highestX) {
highestX = panels[I].dim2.canvasX;
if(panels[I].dim1.canvasX > highestX) {
highestX = panels[I].dim1.canvasX;
rightmost = I;
}
if(panels[I].dim1.canvasX < lowestX) {
lowestX = panels[I].dim1.canvasX;
if(panels[I].dim0.canvasX < lowestX) {
lowestX = panels[I].dim0.canvasX;
leftmost = I;
}
}
Expand All @@ -471,18 +474,18 @@ module.exports = function(canvasGL, d) {

for(I = 0; I < panelCount; I++) {
var panel = panels[I];
var dim0 = panel.dim0;
var dim1 = panel.dim1;
var i = dim1.crossfilterDimensionIndex;
var i0 = dim0.crossfilterDimensionIndex;
var i1 = dim1.crossfilterDimensionIndex;
var x = panel.canvasX;
var y = panel.canvasY;
var dim2 = panel.dim2;
var ii = dim2.crossfilterDimensionIndex;
var panelSizeX = panel.panelSizeX;
var panelSizeY = panel.panelSizeY;
var xTo = x + panelSizeX;
if(setChanged || !previousAxisOrder[i] || previousAxisOrder[i][0] !== x || previousAxisOrder[i][1] !== xTo) {
previousAxisOrder[i] = [x, xTo];
var item = makeItem(i, ii, x, y, panelSizeX, panelSizeY, dim1.crossfilterDimensionIndex, I, leftmost, rightmost, constraints);
if(setChanged || !previousAxisOrder[i0] || previousAxisOrder[i0][0] !== x || previousAxisOrder[i0][1] !== xTo) {
previousAxisOrder[i0] = [x, xTo];
var item = makeItem(i0, i1, x, y, panelSizeX, panelSizeY, dim0.crossfilterDimensionIndex, I, leftmost, rightmost, constraints);
renderState.clearOnly = clearOnly;
renderBlock(regl, glAes, renderState, setChanged ? model.lines.blockLineCount : sampleCount, sampleCount, item);
}
Expand Down
12 changes: 6 additions & 6 deletions src/traces/parcoords/parcoords.js
Expand Up @@ -436,12 +436,12 @@ module.exports = function(root, svg, parcoordsLineLayers, styledData, layout, ca
var panelCount = dimData.length - 1;
for(var p = 0; p < panelCount; p++) {
var panel = panels[p] || (panels[p] = {});
var dim1 = dimData[p];
var dim2 = dimData[p + 1];
var dim0 = dimData[p];
var dim1 = dimData[p + 1];
panel.dim0 = dim0;
panel.dim1 = dim1;
panel.dim2 = dim2;
panel.canvasX = dim1.canvasX;
panel.panelSizeX = dim2.canvasX - dim1.canvasX;
panel.canvasX = dim0.canvasX;
panel.panelSizeX = dim1.canvasX - dim0.canvasX;
panel.panelSizeY = vm.model.canvasHeight;
panel.y = 0;
panel.canvasY = 0;
Expand Down Expand Up @@ -497,7 +497,7 @@ module.exports = function(root, svg, parcoordsLineLayers, styledData, layout, ca
yAxis.filter(function(dd) { return Math.abs(d.xIndex - dd.xIndex) !== 0; })
.attr('transform', function(d) { return 'translate(' + d.xScale(d.xIndex) + ', 0)'; });
d3.select(this).attr('transform', 'translate(' + d.x + ', 0)');
yAxis.each(function(dd, i, ii) { if(ii === d.parent.key) p.dimensions[i] = dd; });
yAxis.each(function(dd, i0, i1) { if(i1 === d.parent.key) p.dimensions[i0] = dd; });
p.contextLayer && p.contextLayer.render(p.panels, false, !someFiltersActive(p));
p.focusLayer.render && p.focusLayer.render(p.panels);
})
Expand Down
7 changes: 4 additions & 3 deletions src/traces/parcoords/plot.js
Expand Up @@ -98,9 +98,10 @@ module.exports = function plot(gd, cdparcoords) {

function sorter(orig) {
return function sorter(d1, d2) {
var i1 = newIdx(visibleIndices, orig, d1);
var i2 = newIdx(visibleIndices, orig, d2);
return i1 - i2;
return (
newIdx(visibleIndices, orig, d1) -
newIdx(visibleIndices, orig, d2)
);
};
}

Expand Down
42 changes: 31 additions & 11 deletions src/traces/parcoords/shaders/context_vertex.glsl
@@ -1,13 +1,15 @@
precision highp float;

#pragma glslify: axisY = require("./y.glsl", mats=mats)
etpinard marked this conversation as resolved.
Show resolved Hide resolved

attribute vec4 p0, p1, p2, p3,
p4, p5, p6, p7,
p8, p9, pa, pb,
pc, pd, pe;

attribute vec4 pf;

uniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D;
uniform mat4 dim0A, dim1A, dim0B, dim1B, dim0C, dim1C, dim0D, dim1D;

uniform vec2 resolution,
viewBoxPosition,
Expand All @@ -19,24 +21,42 @@ uniform vec2 colorClamp;

varying vec4 fragColor;

#pragma glslify: unfilteredPosition = require("./unfiltered_position.glsl")
vec2 xyProjection = vec2(1.0, 1.0);

vec4 unfilteredPosition(
float depth,
vec2 resolution,
mat4 dims[4],
float signum
) {

float x = 0.5 * signum + 0.5;
float y = axisY(x, dims, dim0A, dim1A, dim0B, dim1B, dim0C, dim1C, dim0D, dim1D);

vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);

return vec4(
xyProjection * (2.0 * viewBoxXY / resolution - 1.0),
depth,
1.0
);
}

void main() {

float prominence = abs(pf[3]);

mat4 p[4];
p[0] = mat4(p0, p1, p2, p3);
p[1] = mat4(p4, p5, p6, p7);
p[2] = mat4(p8, p9, pa, pb);
p[3] = mat4(pc, pd, pe, abs(pf));
mat4 dims[4];
dims[0] = mat4(p0, p1, p2, p3);
dims[1] = mat4(p4, p5, p6, p7);
dims[2] = mat4(p8, p9, pa, pb);
dims[3] = mat4(pc, pd, pe, abs(pf));

gl_Position = unfilteredPosition(
1.0 - prominence,
resolution, viewBoxPosition, viewBoxSize,
p,
sign(pf[3]),
dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D
resolution,
dims,
sign(pf[3])
);

float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion src/traces/parcoords/shaders/fragment.glsl
@@ -1,4 +1,4 @@
precision lowp float;
precision highp float;

varying vec4 fragColor;

Expand Down
24 changes: 13 additions & 11 deletions src/traces/parcoords/shaders/pick_vertex.glsl
@@ -1,13 +1,15 @@
precision highp float;

#pragma glslify: position = require("./position.glsl")

attribute vec4 p0, p1, p2, p3,
p4, p5, p6, p7,
p8, p9, pa, pb,
pc, pd, pe;

attribute vec4 pf;

uniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,
uniform mat4 dim0A, dim1A, dim0B, dim1B, dim0C, dim1C, dim0D, dim1D,
loA, hiA, loB, hiB, loC, hiC, loD, hiD;

uniform vec2 resolution,
Expand All @@ -21,25 +23,25 @@ uniform vec2 colorClamp;

varying vec4 fragColor;

#pragma glslify: position = require("./position.glsl")

void main() {

float prominence = abs(pf[3]);

mat4 p[4];
p[0] = mat4(p0, p1, p2, p3);
p[1] = mat4(p4, p5, p6, p7);
p[2] = mat4(p8, p9, pa, pb);
p[3] = mat4(pc, pd, pe, abs(pf));
mat4 dims[4];
dims[0] = mat4(p0, p1, p2, p3);
dims[1] = mat4(p4, p5, p6, p7);
dims[2] = mat4(p8, p9, pa, pb);
dims[3] = mat4(pc, pd, pe, abs(pf));

gl_Position = position(
1.0 - prominence,
resolution, viewBoxPosition, viewBoxSize,
p,
resolution,
dims,
sign(pf[3]),
dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,

dim0A, dim1A, dim0B, dim1B, dim0C, dim1C, dim0D, dim1D,
loA, hiA, loB, hiB, loC, hiC, loD, hiD,
viewBoxPosition, viewBoxSize,
mask, maskHeight
);

Expand Down
21 changes: 12 additions & 9 deletions src/traces/parcoords/shaders/position.glsl
@@ -1,5 +1,6 @@
#pragma glslify: axisY = require("./y.glsl", mats=mats)
precision highp float;

#pragma glslify: axisY = require("./y.glsl", mats=mats)
#pragma glslify: export(position)

const int bitsPerByte = 8;
Expand All @@ -12,9 +13,9 @@ int mod8(int a) {
return a - 8 * (a / 8);
}

vec4 zero = vec4(0, 0, 0, 0);
vec4 unit = vec4(1, 1, 1, 1);
vec2 xyProjection = vec2(1, 1);
vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
vec4 unit = vec4(1.0, 1.0, 1.0, 1.0);
vec2 xyProjection = vec2(1.0, 1.0);

mat4 mclamp(mat4 m, mat4 lo, mat4 hi) {
return mat4(clamp(m[0], lo[0], hi[0]),
Expand Down Expand Up @@ -61,20 +62,22 @@ bool withinRasterMask(mat4 d[4], sampler2D mask, float height) {

vec4 position(
float depth,
vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,
vec2 resolution,
mat4 dims[4],
float signum,
mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,

mat4 dim0A, mat4 dim1A, mat4 dim0B, mat4 dim1B, mat4 dim0C, mat4 dim1C, mat4 dim0D, mat4 dim1D,
mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,
vec2 viewBoxPosition, vec2 viewBoxSize,
sampler2D mask, float maskHeight
) {

float x = 0.5 * signum + 0.5;
float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);
float y = axisY(x, dims, dim0A, dim1A, dim0B, dim1B, dim0C, dim1C, dim0D, dim1D);

float show = float(
withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)
&& withinRasterMask(dims, mask, maskHeight)
withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD) &&
withinRasterMask(dims, mask, maskHeight)
);

vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);
Expand Down