-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Table view - squashed #2052
Changes from 3 commits
c4244db
865e444
2648e51
1922721
30cbaa0
aa0c116
c0ac213
732bd46
22e23e3
9571be3
345b027
ff3c8f6
b9c8de6
c1d19b4
f8e7647
7186527
e96c3c4
5336725
6f21697
f3f1a5d
9574099
5a59e04
dd5841d
9b60156
309c8bb
78cb5ec
b14f6c6
2be591f
addb85b
c2f251f
3cab51d
fa84c68
465b45b
0fa1cc8
cd0578d
a6c4935
0ad1a0c
1254c9f
e38b7cf
94338f4
6288559
154ab24
9402020
d4f0ed7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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'); |
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 = { | ||
|
||
// 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];} | ||
}; |
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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be an |
||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting number. How did you come up with that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
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: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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,', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
'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' | ||
} | ||
} | ||
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to add See #1999 |
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(); | ||
} | ||
}; |
There was a problem hiding this comment.
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 🎉
There was a problem hiding this comment.
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
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added note to #2058