Skip to content

Violin plot implementation #549

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 dev/mocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"/percy/panelTest.json",
"/percy/histogram.json",
"/percy/histogram2d.json",
"/percy/violin.json",
"0.json",
"1.json",
"10.json",
Expand Down
3 changes: 2 additions & 1 deletion dev/percy/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import panelTest from './panelTest.json';
import histogram from './histogram.json';
import histogram2d from './histogram2d.json';
import violin from './violin.json';

export {panelTest, histogram, histogram2d};
export {panelTest, histogram, histogram2d, violin};
28 changes: 28 additions & 0 deletions dev/percy/violin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"data": [
{
"type": "violin",
"mode": "markers",
"uid": "91db56",
"box": {
"visible": true
},
"meanline": {
"visible": true
},
"bandwidth": 0,
"x": [
1,
2,
3
],
"xsrc": "x1"
}
],
"layout": {
"xaxis": {},
"yaxis": {},
"autosize": true
},
"frames": []
}
1 change: 1 addition & 0 deletions src/__percy__/panels.percy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import './percy.css';
const panelsToTest = {
histogram: ['GraphCreatePanel'],
histogram2d: ['GraphCreatePanel', 'StyleTracesPanel'],
violin: ['GraphCreatePanel', 'StyleTracesPanel'],
};

window.URL.createObjectURL = function() {
Expand Down
69 changes: 67 additions & 2 deletions src/default_panels/StyleTracesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,25 @@ const StyleTracesPanel = (props, {localize: _}) => (
{label: _('Unsorted'), value: false},
]}
/>
<Radio
<Dropdown
options={[
{label: _('Show All'), value: 'all'},
{label: _('Outliers'), value: 'outliers'},
{label: _('Suspected Outliers'), value: 'suspectedoutliers'},
{label: _('Hide'), value: false},
]}
attr="boxpoints"
clearable={false}
/>
<Dropdown
options={[
{label: _('Show'), value: 'all'},
{label: _('Show All'), value: 'all'},
{label: _('Outliers'), value: 'outliers'},
{label: _('Suspected Outliers'), value: 'suspectedoutliers'},
{label: _('Hide'), value: false},
]}
attr="points"
clearable={false}
/>
<NumericFraction label={_('Jitter')} attr="jitter" />
<Numeric label={_('Position')} attr="pointpos" step={0.1} showSlider />
Expand Down Expand Up @@ -395,6 +408,27 @@ const StyleTracesPanel = (props, {localize: _}) => (
]}
/>
</PlotlySection>
<PlotlySection name={_('Scaling')}>
<Numeric label={_('Bandwidth')} attr="bandwidth" />
<Radio
label="Scale Mode"
attr="scalemode"
options={[
{label: _('Width'), value: 'width'},
{label: _('Count'), value: 'count'},
]}
/>
<Radio
label="Span Mode"
attr="spanmode"
options={[
{label: _('Soft'), value: 'soft'},
{label: _('Hard'), value: 'hard'},
{label: _('Manual'), value: 'manual'},
]}
/>
<Numeric label={_('Span')} attr="span" />
</PlotlySection>
<PlotlySection name={_('Highlight')}>
<Radio
attr="boxmean"
Expand All @@ -412,6 +446,37 @@ const StyleTracesPanel = (props, {localize: _}) => (
{label: _('Hide'), value: false},
]}
/>
<Radio
attr="box.visible"
label={_('Box Visible')}
options={[
{label: _('Show'), value: true},
{label: _('Hide'), value: false},
]}
/>
<NumericFraction label={_('Box Width')} attr="box.width" />
<ColorPicker label={_('Box Fill Color')} attr="box.color" />
<NumericFraction label={_('Box Line Width')} attr="box.line.width" />
<ColorPicker label={_('Box Line Color')} attr="box.line.color" />
<Radio
attr="meanline.visible"
label={_('Meanline Visible')}
options={[
{label: _('Show'), value: true},
{label: _('Hide'), value: false},
]}
/>
<NumericFraction label={_('Meanline Width')} attr="meanline.width" />
<ColorPicker label={_('Meanline Color')} attr="meanline.color" />
<Radio
attr="side"
label={_('Density Function Side')}
options={[
{label: _('Both'), value: 'both'},
{label: _('Positive'), value: 'positive'},
{label: _('Negative'), value: 'negative'},
]}
/>
</PlotlySection>
<PlotlySection name={_('On Hover')}>
<HoverInfo attr="hoverinfo" label={_('Values Shown On Hover')} />
Expand Down
1 change: 1 addition & 0 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const TRACE_TO_AXIS = {
'scatter',
'scattergl',
'box',
'violin',
'bar',
'heatmap',
'heatmapgl',
Expand Down
7 changes: 7 additions & 0 deletions src/lib/customTraceType.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export function traceTypeToPlotlyInitFigure(traceType) {
type: 'box',
boxpoints: false,
};
case 'violin':
return {
type: 'violin',
box: {visible: false},
meanline: {visible: false},
bandwidth: 0,
};
case 'line3d':
return {
type: 'scatter3d',
Expand Down
10 changes: 5 additions & 5 deletions src/lib/traceTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ export const traceTypes = _ => [
label: _('2D Contour Histogram'),
category: chartCategory(_).DISTRIBUTIONS,
},
// {
// value: 'violin',
// label: _('Violin'),
// category: chartCategory(_).DISTRIBUTIONS,
// },
{
value: 'violin',
label: _('Violin'),
category: chartCategory(_).DISTRIBUTIONS,
},
{
value: 'choropleth',
label: _('Choropleth'),
Expand Down