-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Parallel Categories (parcats) trace type for multi dimensional categorical data #2963
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
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
1a8a0f0
Initial parcats trace implementation
406cd24
color attribute fixes for rebase on 1.39.3
jonmmease ee7fd17
lint fixes
jonmmease 3e43ef3
Remove customHovers, replace with loneHover
jonmmease 0c9c75f
Bring back customHovers
jonmmease 7b75100
Renamed `parcats.marker` -> `parcats.line`
jonmmease d2c5ae8
Use plots/domain and handleDomainDefaults
jonmmease a34dafa
Rename displayInd -> displayindex
jonmmease 71e212b
Convert to simplified colorbar logic
jonmmease 6797a83
Remove maxDimensionCount check
jonmmease 2c14168
Cleanup supplyDefaults and add visible dimension property
jonmmease c8e3cc9
Added support for dimensions with visible=false
jonmmease 6a5c20e
Fixed failing test (needed to rename displayInd -> displayindex)
jonmmease 22346d0
Added mock with color hovermode
jonmmease 3680084
Replace tooltip with hoverinfo
2d07f4d
Added `arrangement` property that is very similar to the sankey trace
7f90fc1
WIP towards categoryorder/categoryarray/categorylabels
5e60062
Full support for categoryorder, categoryarray, and categorylabels
66c90fa
Fixed tests to use new `categoryorder`, `categoryarray`, `categorylab…
69f6922
Add 'dimension' hovermode that uses multi-hoverlabel logic
f2aa9b9
Added labelfont and categorylabelfont top-level attributes
4eb5317
Review / cleanup attribute descriptions
a897388
Add `counts` attribute to parcats_hovermode_dimension mock
98d76ee
Refactor dimension and category dragging tests and test arrangements
66f21fe
Add tests for clicking on category and path with/without hoverinfo skip
30ca2ec
Add tests for clicking on category and path with hovermode 'color'
69311fc
Implement plotly_unhover events
b3b73a6
Add tests for hovering on category and paths
fed71e7
eslint fixes
9361cc4
Fix up attribute description specifications
6ca2d66
Fix test comments
2a51ca9
Added new baseline images for parcats mocks
948bf0a
Fix headers (it *was* 2017 when I started this!)
b1ef6c9
markerColorscale no longer used
5a19499
Rename categorylabels -> ticktext and categorylabelfont -> tickfont
1f6a2e0
Update baseline image for parcats_reordered (Added "One"/"Two" labels)
340ae53
eslint fixes
9b66bee
Support Rich text / Latex in category labels (ticktext)
870ff82
eslint fixes
7e4a6ad
Handle line.color as TypedArray
e7edebd
hovermode -> hoveron
20bc21b
Baseline images for hovermode -> hoveron conversion
273d2d0
Hide unsupported top-level properties from plot-schema
e8ded39
Merge remote-tracking branch 'upstream/master' into parcats
4bc3d35
Fix plotschema tests in the presence of potentially undefined schema …
2684d69
Fix path tooltip direction when graph div is offset from left margin
267c750
Increase default font size slightly
2100d96
Remove redundant require('./hover') operations
eba1b4a
Cleanup line defaults logic
4117612
Create `parcats_grid_subplots` mock with 4 grid-based subplots
99f9a47
Use layout.colorway[0] as the default color for parcats traces
jonmmease File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright 2012-2018, 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/parcats'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
/** | ||
* Copyright 2012-2018, 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 extendFlat = require('../../lib/extend').extendFlat; | ||
var plotAttrs = require('../../plots/attributes'); | ||
var fontAttrs = require('../../plots/font_attributes'); | ||
var colorAttributes = require('../../components/colorscale/attributes'); | ||
var domainAttrs = require('../../plots/domain').attributes; | ||
var scatterAttrs = require('../scatter/attributes'); | ||
var scatterLineAttrs = scatterAttrs.line; | ||
var colorbarAttrs = require('../../components/colorbar/attributes'); | ||
|
||
var line = extendFlat({ | ||
editType: 'calc' | ||
}, colorAttributes('line', {editType: 'calc'}), | ||
{ | ||
showscale: scatterLineAttrs.showscale, | ||
colorbar: colorbarAttrs, | ||
shape: { | ||
valType: 'enumerated', | ||
values: ['linear', 'hspline'], | ||
dflt: 'linear', | ||
role: 'info', | ||
editType: 'plot', | ||
description: [ | ||
'Sets the shape of the paths.', | ||
'If `linear`, paths are composed of straight lines.', | ||
'If `hspline`, paths are composed of horizontal curved splines' | ||
].join(' ') | ||
} | ||
}); | ||
|
||
module.exports = { | ||
domain: domainAttrs({name: 'parcats', trace: true, editType: 'calc'}), | ||
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { | ||
flags: ['count', 'probability'], | ||
editType: 'plot' | ||
// plotAttrs.hoverinfo description is appropriate | ||
}), | ||
hoveron: { | ||
valType: 'enumerated', | ||
values: ['category', 'color', 'dimension'], | ||
dflt: 'category', | ||
role: 'info', | ||
editType: 'plot', | ||
description: [ | ||
'Sets the hover interaction mode for the parcats diagram.', | ||
'If `category`, hover interaction take place per category.', | ||
'If `color`, hover interactions take place per color per category.', | ||
'If `dimension`, hover interactions take place across all categories per dimension.' | ||
].join(' ') | ||
}, | ||
arrangement: { | ||
valType: 'enumerated', | ||
values: ['perpendicular', 'freeform', 'fixed'], | ||
dflt: 'perpendicular', | ||
role: 'style', | ||
editType: 'plot', | ||
description: [ | ||
'Sets the drag interaction mode for categories and dimensions.', | ||
'If `perpendicular`, the categories can only move along a line perpendicular to the paths.', | ||
'If `freeform`, the categories can freely move on the plane.', | ||
'If `fixed`, the categories and dimensions are stationary.' | ||
].join(' ') | ||
}, | ||
bundlecolors: { | ||
valType: 'boolean', | ||
dflt: true, | ||
role: 'info', | ||
editType: 'plot', | ||
description: 'Sort paths so that like colors are bundled together within each category.' | ||
}, | ||
sortpaths: { | ||
valType: 'enumerated', | ||
values: ['forward', 'backward'], | ||
dflt: 'forward', | ||
role: 'info', | ||
editType: 'plot', | ||
description: [ | ||
'Sets the path sorting algorithm.', | ||
'If `forward`, sort paths based on dimension categories from left to right.', | ||
'If `backward`, sort paths based on dimensions categories from right to left.' | ||
].join(' ') | ||
}, | ||
labelfont: fontAttrs({ | ||
editType: 'calc', | ||
description: 'Sets the font for the `dimension` labels.' | ||
}), | ||
|
||
tickfont: fontAttrs({ | ||
editType: 'calc', | ||
description: 'Sets the font for the `category` labels.' | ||
}), | ||
|
||
dimensions: { | ||
_isLinkedToArray: 'dimension', | ||
label: { | ||
valType: 'string', | ||
role: 'info', | ||
editType: 'calc', | ||
description: 'The shown name of the dimension.' | ||
}, | ||
categoryorder: { | ||
valType: 'enumerated', | ||
values: [ | ||
'trace', 'category ascending', 'category descending', 'array' | ||
], | ||
dflt: 'trace', | ||
role: 'info', | ||
editType: 'calc', | ||
description: [ | ||
'Specifies the ordering logic for the categories in the dimension.', | ||
'By default, plotly uses *trace*, which specifies the order that is present in the data supplied.', | ||
'Set `categoryorder` to *category ascending* or *category descending* if order should be determined by', | ||
'the alphanumerical order of the category names.', | ||
'Set `categoryorder` to *array* to derive the ordering from the attribute `categoryarray`. If a category', | ||
'is not found in the `categoryarray` array, the sorting behavior for that attribute will be identical to', | ||
'the *trace* mode. The unspecified categories will follow the categories in `categoryarray`.' | ||
].join(' ') | ||
}, | ||
categoryarray: { | ||
valType: 'data_array', | ||
role: 'info', | ||
editType: 'calc', | ||
description: [ | ||
'Sets the order in which categories in this dimension appear.', | ||
'Only has an effect if `categoryorder` is set to *array*.', | ||
'Used with `categoryorder`.' | ||
].join(' ') | ||
}, | ||
ticktext: { | ||
valType: 'data_array', | ||
role: 'info', | ||
editType: 'calc', | ||
description: [ | ||
'Sets alternative tick labels for the categories in this dimension.', | ||
'Only has an effect if `categoryorder` is set to *array*.', | ||
'Should be an array the same length as `categoryarray`', | ||
'Used with `categoryorder`.' | ||
].join(' ') | ||
}, | ||
values: { | ||
valType: 'data_array', | ||
role: 'info', | ||
dflt: [], | ||
editType: 'calc', | ||
description: [ | ||
'Dimension values. `values[n]` represents the category 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).' | ||
].join(' ') | ||
}, | ||
displayindex: { | ||
valType: 'integer', | ||
role: 'info', | ||
editType: 'calc', | ||
description: [ | ||
'The display index of dimension, from left to right, zero indexed, defaults to dimension', | ||
'index.' | ||
].join(' ') | ||
}, | ||
editType: 'calc', | ||
description: 'The dimensions (variables) of the parallel categories diagram.', | ||
visible: { | ||
valType: 'boolean', | ||
dflt: true, | ||
role: 'info', | ||
editType: 'calc', | ||
description: 'Shows the dimension when set to `true` (the default). Hides the dimension for `false`.' | ||
} | ||
}, | ||
|
||
line: line, | ||
counts: { | ||
valType: 'number', | ||
min: 0, | ||
dflt: 1, | ||
arrayOk: true, | ||
role: 'info', | ||
editType: 'calc', | ||
description: [ | ||
'The number of observations represented by each state. Defaults to 1 so that each state represents', | ||
'one observation' | ||
].join(' ') | ||
}, | ||
|
||
// Hide unsupported top-level properties from plot-schema | ||
customdata: undefined, | ||
hoverlabel: undefined, | ||
ids: undefined, | ||
legendgroup: undefined, | ||
opacity: undefined, | ||
selectedpoints: undefined, | ||
showlegend: undefined | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright 2012-2018, 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 getModuleCalcData = require('../../plots/get_data').getModuleCalcData; | ||
var parcatsPlot = require('./plot'); | ||
|
||
var PARCATS = 'parcats'; | ||
exports.name = PARCATS; | ||
|
||
exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) { | ||
|
||
var cdModuleAndOthers = getModuleCalcData(gd.calcdata, PARCATS); | ||
|
||
if(cdModuleAndOthers.length) { | ||
var calcData = cdModuleAndOthers[0]; | ||
parcatsPlot(gd, calcData, transitionOpts, makeOnCompleteCallback); | ||
} | ||
}; | ||
|
||
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) { | ||
var hadTable = (oldFullLayout._has && oldFullLayout._has('parcats')); | ||
var hasTable = (newFullLayout._has && newFullLayout._has('parcats')); | ||
|
||
if(hadTable && !hasTable) { | ||
oldFullLayout._paperdiv.selectAll('.parcats').remove(); | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.