Skip to content

Table view - squashed #2052

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

Merged
merged 44 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c4244db
table - initial commit (squashed feature branch)
monfera Oct 3, 2017
865e444
adding birds mock
monfera Oct 3, 2017
2648e51
minor mock change
monfera Oct 3, 2017
1922721
avoid crispEdges in cell contents and scrollbar; minor mock change
monfera Oct 3, 2017
30cbaa0
doc change
monfera Oct 3, 2017
aa0c116
fewer accessor uses
monfera Oct 3, 2017
c0ac213
doc update
monfera Oct 3, 2017
732bd46
more idiomatic D3
monfera Oct 3, 2017
22e23e3
no prefixing with window
monfera Oct 3, 2017
9571be3
amending document
monfera Oct 3, 2017
345b027
switched off bounciness
monfera Oct 3, 2017
ff3c8f6
minor mock fix
monfera Oct 3, 2017
b9c8de6
staying valign for the moment
monfera Oct 4, 2017
c1d19b4
fixes non-wrapping wrappable case by including it in the `alignment-b…
monfera Oct 4, 2017
f8e7647
mock update - showing text wrapping
monfera Oct 4, 2017
7186527
separate mock for wrapped text; fixing a scrolling issue
monfera Oct 4, 2017
e96c3c4
adding editType (for now, conservatively)
monfera Oct 4, 2017
5336725
new mock
monfera Oct 4, 2017
6f21697
adding multitrace latex mock; fixing multitrace drag bug
monfera Oct 4, 2017
f3f1a5d
fixing multitrace drag bug 2
monfera Oct 4, 2017
9574099
fixing multitrace drag bug 3
monfera Oct 4, 2017
5a59e04
fixing multitrace drag bug 4
monfera Oct 4, 2017
dd5841d
multitrace mock with scrollers to show trace independence
monfera Oct 4, 2017
9b60156
new mock: adding scatter plot to trace
monfera Oct 4, 2017
309c8bb
moving functionality from `calc.js` to a helper file
monfera Oct 4, 2017
78cb5ec
moving functionality from `plot.js` to the data split file
monfera Oct 4, 2017
b14f6c6
mock JSON consolidated to fewer items
monfera Oct 5, 2017
2be591f
removed clipView debug option
monfera Oct 5, 2017
addb85b
allow cell text selection
monfera Oct 5, 2017
c2f251f
fixing server image gen issue - thanks Étienne - and removing the pos…
monfera Oct 5, 2017
3cab51d
adding baselines
monfera Oct 5, 2017
fa84c68
globally safe clipPath #1
monfera Oct 5, 2017
465b45b
use overrideAll in table attributes
etpinard Oct 5, 2017
0fa1cc8
globally safe clipPath #2
monfera Oct 5, 2017
cd0578d
Merge branch 'table-squashed' of https://github.com/plotly/plotly.js …
monfera Oct 5, 2017
a6c4935
add baselines
etpinard Oct 5, 2017
0ad1a0c
preparing for user-specified stroke/stroke-opacity, fill/fill-opacity…
monfera Oct 5, 2017
1254c9f
user-specified stroke/stroke-opacity, fill/fill-opacity setting via C…
monfera Oct 5, 2017
e38b7cf
Merge branch 'table-squashed' of https://github.com/plotly/plotly.js …
monfera Oct 5, 2017
94338f4
Merge branch 'table-textselect' into table-squashed
monfera Oct 5, 2017
6288559
minor simplification before rewiring event handlers to enable text copy
monfera Oct 5, 2017
154ab24
allow both dragging and text cell copying
monfera Oct 5, 2017
9402020
disable visible scrollbar on initial load
monfera Oct 5, 2017
d4f0ed7
updating other mocks
monfera Oct 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Plotly.register([
require('./pointcloud'),
require('./heatmapgl'),
require('./parcoords'),
require('./table'),

require('./scattermapbox'),

Expand Down
11 changes: 11 additions & 0 deletions lib/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = require('../src/traces/table');
34 changes: 34 additions & 0 deletions src/lib/gup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var identity = require('./identity');

function wrap(d) {return [d];}

module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. Thanks @monfera 🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind reusing this in parcoords.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added note to #2058


// The D3 data binding concept and the General Update Pattern promotes the idea of
// traversing into the scenegraph by using the `.data(fun, keyFun)` call.
// The `fun` is most often a `repeat`, ie. the elements beneath a `<g>` element need
// access to the same data, or a `descend`, which fans a scenegraph node into a bunch of
// of elements, e.g. points, lines, rows, requiring an array as input.
// The role of the `keyFun` is to identify what elements are being entered/exited/updated,
// otherwise D3 reverts to using a plain index which would screw up `transition`s.
keyFun: function(d) {return d.key;},
repeat: wrap,
descend: identity,

// Plotly.js uses a convention of storing the actual contents of the `calcData` as the
// element zero of a container array. These helpers are just used for clarity as a
// newcomer to the codebase may not know what the `[0]` is, and whether there can be further
// elements (not atm).
wrap: wrap,
unwrap: function(d) {return d[0];}
};
7 changes: 7 additions & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ lib.raiseToTop = function raiseToTop(elem) {
elem.parentNode.appendChild(elem);
};

/**
* cancel a possibly pending transition; returned selection may be used by caller
*/
lib.cancelTransition = function(selection) {
return selection.transition().duration(0);
};

// constrain - restrict a number v to be between v0 and v1
lib.constrain = function(v, v0, v1) {
if(v0 > v1) return Math.max(v1, Math.min(v0, v));
Expand Down
278 changes: 278 additions & 0 deletions src/traces/table/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var annAttrs = require('../../components/annotations/attributes');
var extendFlat = require('../../lib/extend').extendFlat;

module.exports = {

domain: {
x: {
valType: 'info_array',
role: 'info',
items: [
{valType: 'number', min: 0, max: 1},
{valType: 'number', min: 0, max: 1}
],
dflt: [0, 1],
description: [
'Sets the horizontal domain of this `table` trace',
'(in plot fraction).'
].join(' ')
},
y: {
valType: 'info_array',
role: 'info',
items: [
{valType: 'number', min: 0, max: 1},
{valType: 'number', min: 0, max: 1}
],
dflt: [0, 1],
description: [
'Sets the vertical domain of this `table` trace',
'(in plot fraction).'
].join(' ')
}
},

columnwidth: {
valType: 'number',
arrayOk: true,
dflt: null,
role: 'style',
description: 'The width of cells.'
},

columnorder: {
valType: 'data_array',
role: 'info',
description: [
'Specifies the rendered order of the data columns; for example, a value `2` at position `0`',
'means that column index `0` in the data will be rendered as the',
'third column, as columns have an index base of zero.'
].join(' ')
},

header: {

values: {
valType: 'data_array',
role: 'info',
dflt: [],
description: [
'Dimension values. `values[n]` represents the value of the `n`th point in the dataset,',
'therefore the `values` vector for all dimensions must be the same (longer vectors',
'will be truncated). Each value must be a finite number.'
].join(' ')
},

format: {
valType: 'data_array',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be an arrayOk valType: 'string', to format all values to same way more easily?

role: 'info',
dflt: [],
description: [
'Sets the cell value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
].join(' ')
},

prefix: {
valType: 'string',
arrayOk: true,
dflt: null,
role: 'style',
description: 'Prefix for cell values.'
},

suffix: {
valType: 'string',
arrayOk: true,
dflt: null,
role: 'style',
description: 'Suffix for cell values.'
},

height: {
valType: 'number',
dflt: 28,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting number. How did you come up with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took a look at what'd look balanced with a font height of 12px although it could as well be computed
image

role: 'style',
description: 'The height of cells.'
},

align: extendFlat({}, annAttrs.align, {arrayOk: true}),
valign: extendFlat({}, annAttrs.valign, {arrayOk: true}),

line: {
width: {
valType: 'number',
arrayOk: true,
role: 'style'
},
color: {
valType: 'color',
arrayOk: true,
role: 'style'
}
},

fill: {
color: {
valType: 'color',
arrayOk: true,
role: 'style',
description: [
'Sets the cell fill color. It accepts either a specific color',
' or an array of colors.'
].join('')
}
},

font: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

family: {
valType: 'string',
arrayOk: true,
role: 'style',
noBlank: true,
strict: true,
description: [
'HTML font family - the typeface that will be applied by the web browser.',
'The web browser will only be able to apply a font if it is available on the system',
'which it operates. Provide multiple font families, separated by commas, to indicate',
'the preference in which to apply fonts if they aren\'t available on the system.',
'The plotly service (at https://plot.ly or on-premise) generates images on a server,',
'where only a select number of',
'fonts are installed and supported.',
'These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*,',
'*Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*,',
'*PT Sans Narrow*, *Raleway*, *Times New Roman*.'
].join(' ')
},
size: {
valType: 'number',
arrayOk: true,
role: 'style'
},
color: {
valType: 'color',
arrayOk: true,
role: 'style'
}
}
},

cells: {

values: {
valType: 'data_array',
role: 'info',
dflt: [],
description: [
'Dimension values. `values[n]` represents the value of the `n`th point in the dataset,',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't values be 2D? That is, values[n][m] represents the value of ....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to revise all attribute descriptions, indeed it's a nested array:
image

'therefore the `values` vector for all dimensions must be the same (longer vectors',
'will be truncated). Each value must be a finite number.'
].join(' ')
},

format: {
valType: 'data_array',
role: 'info',
dflt: [],
description: [
'Sets the cell value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
].join(' ')
},

prefix: {
valType: 'string',
arrayOk: true,
dflt: null,
role: 'style',
description: 'Prefix for cell values.'
},

suffix: {
valType: 'string',
arrayOk: true,
dflt: null,
role: 'style',
description: 'Suffix for cell values.'
},

height: {
valType: 'number',
dflt: 20,
role: 'style',
description: 'The height of cells.'
},

align: extendFlat({}, annAttrs.align, {arrayOk: true}),
valign: extendFlat({}, annAttrs.valign, {arrayOk: true}),

line: {
width: {
valType: 'number',
arrayOk: true,
role: 'style'
},
color: {
valType: 'color',
arrayOk: true,
role: 'style'
}
},

fill: {
color: {
valType: 'color',
arrayOk: true,
role: 'style',
description: [
'Sets the cell fill color. It accepts either a specific color',
' or an array of colors.'
].join('')
}
},

font: {
family: {
valType: 'string',
arrayOk: true,
role: 'style',
noBlank: true,
strict: true,
description: [
'HTML font family - the typeface that will be applied by the web browser.',
'The web browser will only be able to apply a font if it is available on the system',
'which it operates. Provide multiple font families, separated by commas, to indicate',
'the preference in which to apply fonts if they aren\'t available on the system.',
'The plotly service (at https://plot.ly or on-premise) generates images on a server,',
'where only a select number of',
'fonts are installed and supported.',
'These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*,',
'*Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*,',
'*PT Sans Narrow*, *Raleway*, *Times New Roman*.'
].join(' ')
},
size: {
valType: 'number',
arrayOk: true,
role: 'style'
},
color: {
valType: 'color',
arrayOk: true,
role: 'style'
}
}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add editType declarations to these attributes.

See #1999

30 changes: 30 additions & 0 deletions src/traces/table/base_plot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var Plots = require('../../plots/plots');
var tablePlot = require('./plot');

exports.name = 'table';

exports.attr = 'type';

exports.plot = function(gd) {
var calcData = Plots.getSubplotCalcData(gd.calcdata, 'table', 'table');
if(calcData.length) tablePlot(gd, calcData);
};

exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
var hadTable = (oldFullLayout._has && oldFullLayout._has('table'));
var hasTable = (newFullLayout._has && newFullLayout._has('table'));

if(hadTable && !hasTable) {
oldFullLayout._paperdiv.selectAll('.table').remove();
}
};
Loading