-
-
Couldn't load subscription status.
- Fork 1.9k
Violin plots #2116
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
Violin plots #2116
Changes from 4 commits
c578cde
8f34227
c8f38ff
3438eae
d779509
bb252a5
ea43b25
a706f2a
1eb453b
7769f20
ad51966
4a40fc7
6ffc379
dfa918f
bc6bc02
e737664
e625c44
14bded3
48758d8
17f65d0
71700de
677aacc
0a32b98
3c9e0a0
ea66dea
789121c
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/violin'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,25 @@ var Color = require('../../components/color'); | |
|
|
||
| var attributes = require('./attributes'); | ||
|
|
||
| module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) { | ||
| function supplyDefaults(traceIn, traceOut, defaultColor, layout) { | ||
| function coerce(attr, dflt) { | ||
| return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); | ||
| } | ||
|
|
||
| handleSampleDefaults(traceIn, traceOut, coerce, layout); | ||
| if(traceOut.visible === false) return; | ||
|
|
||
| coerce('line.color', (traceIn.marker || {}).color || defaultColor); | ||
| coerce('line.width'); | ||
| coerce('fillcolor', Color.addOpacity(traceOut.line.color, 0.5)); | ||
|
|
||
| coerce('whiskerwidth'); | ||
| coerce('boxmean'); | ||
|
|
||
| handlePointsDefaults(traceIn, traceOut, coerce, {prefix: 'box'}); | ||
| } | ||
|
|
||
| function handleSampleDefaults(traceIn, traceOut, coerce, layout) { | ||
| var y = coerce('y'); | ||
| var x = coerce('x'); | ||
|
|
||
|
|
@@ -39,25 +53,22 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout | |
| handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); | ||
|
|
||
| coerce('orientation', defaultOrientation); | ||
| } | ||
|
|
||
| coerce('line.color', (traceIn.marker || {}).color || defaultColor); | ||
| coerce('line.width'); | ||
| coerce('fillcolor', Color.addOpacity(traceOut.line.color, 0.5)); | ||
|
|
||
| coerce('whiskerwidth'); | ||
| coerce('boxmean'); | ||
| function handlePointsDefaults(traceIn, traceOut, coerce, opts) { | ||
| var prefix = opts.prefix; | ||
|
|
||
| var outlierColorDflt = Lib.coerce2(traceIn, traceOut, attributes, 'marker.outliercolor'); | ||
| var lineoutliercolor = coerce('marker.line.outliercolor'); | ||
|
|
||
| var boxpoints = coerce( | ||
| 'boxpoints', | ||
| var points = coerce( | ||
| prefix + 'points', | ||
| (outlierColorDflt || lineoutliercolor) ? 'suspectedoutliers' : undefined | ||
| ); | ||
|
|
||
| if(boxpoints) { | ||
| coerce('jitter', boxpoints === 'all' ? 0.3 : 0); | ||
| coerce('pointpos', boxpoints === 'all' ? -1.5 : 0); | ||
| if(points) { | ||
| coerce('jitter', points === 'all' ? 0.3 : 0); | ||
| coerce('pointpos', points === 'all' ? -1.5 : 0); | ||
|
|
||
| coerce('marker.symbol'); | ||
| coerce('marker.opacity'); | ||
|
|
@@ -66,7 +77,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout | |
| coerce('marker.line.color'); | ||
| coerce('marker.line.width'); | ||
|
|
||
| if(boxpoints === 'suspectedoutliers') { | ||
| if(points === 'suspectedoutliers') { | ||
| coerce('marker.line.outliercolor', traceOut.marker.color); | ||
| coerce('marker.line.outlierwidth'); | ||
| } | ||
|
|
@@ -77,4 +88,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout | |
| } | ||
|
|
||
| coerce('hoveron'); | ||
| } | ||
|
|
||
| module.exports = { | ||
| supplyDefaults: supplyDefaults, | ||
| handleSampleDefaults: handleSampleDefaults, | ||
| handlePointsDefaults: handlePointsDefaults | ||
|
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. I made a separate reorganisation commit, to show a new way to factor out common trace module blocks. I think this method is a little more consistent with ES6 modules. For example here, |
||
| }; | ||
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.
Making sure violins are under boxes always.