Skip to content
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

[New Viz] Partition Diagram #3642

Merged
merged 2 commits into from
Oct 13, 2017
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions superset/assets/javascripts/components/OptionDescription.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import PropTypes from 'prop-types';

import InfoTooltipWithTrigger from './InfoTooltipWithTrigger';

const propTypes = {
option: PropTypes.object.isRequired,
};

// This component provides a general tooltip for options
// in a SelectControl
export default function OptionDescription({ option }) {
return (
<span>
<span className="m-r-5 option-label">
{option.label}
</span>
{option.description &&
<InfoTooltipWithTrigger
className="m-r-5 text-muted"
icon="question-circle-o"
tooltip={option.description}
label={`descr-${option.label}`}
/>
}
</span>);
}
OptionDescription.propTypes = propTypes;
102 changes: 102 additions & 0 deletions superset/assets/javascripts/explore/stores/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as v from '../validators';
import { ALL_COLOR_SCHEMES, spectrums } from '../../modules/colors';
import MetricOption from '../../components/MetricOption';
import ColumnOption from '../../components/ColumnOption';
import OptionDescription from '../../components/OptionDescription';
import { t } from '../../locales';
import controlMap from '../components/controls';

Expand Down Expand Up @@ -99,6 +100,7 @@ export const controls = {
}),
description: t('One or many metrics to display'),
},

y_axis_bounds: {
type: 'BoundsControl',
label: t('Y Axis Bounds'),
Expand All @@ -109,6 +111,7 @@ export const controls = {
"this feature will only expand the axis range. It won't " +
"narrow the data's extent."),
},

order_by_cols: {
type: 'SelectControl',
multi: true,
Expand Down Expand Up @@ -908,6 +911,16 @@ export const controls = {
description: D3_FORMAT_DOCS,
},

date_time_format: {
type: 'SelectControl',
freeForm: true,
label: t('Date Time Format'),
renderTrigger: true,
default: 'smart_date',
choices: D3_TIME_FORMAT_OPTIONS,
description: D3_FORMAT_DOCS,
},

markup_type: {
type: 'SelectControl',
label: t('Markup Type'),
Expand Down Expand Up @@ -1099,6 +1112,14 @@ export const controls = {
description: t('Use a log scale for the X axis'),
},

log_scale: {
type: 'CheckboxControl',
label: t('Log Scale'),
default: false,
renderTrigger: true,
description: t('Use a log scale'),
},

donut: {
type: 'CheckboxControl',
label: t('Donut'),
Expand Down Expand Up @@ -1411,12 +1432,93 @@ export const controls = {
default: 4,
description: 'Number of decimal places with which to display lift values',
},

column_collection: {
type: 'CollectionControl',
label: t('Time Series Columns'),
validators: [v.nonEmpty],
control: controlMap.TimeSeriesColumnControl,
},

time_series_option: {
type: 'SelectControl',
label: t('Options'),
validators: [v.nonEmpty],
default: 'not_time',
valueKey: 'value',
options: [
{
label: t('Not Time Series'),
value: 'not_time',
description: t('Ignore time'),
},
{
label: t('Time Series'),
value: 'time_series',
description: t('Standard time series'),
},
{
label: t('Aggregate Mean'),
value: 'agg_mean',
description: t('Mean of values over specified period'),
},
{
label: t('Aggregate Sum'),
value: 'agg_sum',
description: t('Sum of values over specified period'),
},
{
label: t('Difference'),
value: 'point_diff',
description: t('Metric change in value from `since` to `until`'),
},
{
label: t('Percent Change'),
value: 'point_percent',
description: t('Metric percent change in value from `since` to `until`'),
},
{
label: t('Factor'),
value: 'point_factor',
description: t('Metric factor change from `since` to `until`'),
},
{
label: t('Advanced Analytics'),
value: 'adv_anal',
description: t('Use the Advanced Analytics options below'),
},
],
optionRenderer: op => <OptionDescription option={op} />,
valueRenderer: op => <OptionDescription option={op} />,
description: t('Settings for time series'),
},

equal_date_size: {
type: 'CheckboxControl',
label: t('Equal Date Sizes'),
default: true,
renderTrigger: true,
description: t('Check to force date partitions to have the same height'),
},

partition_limit: {
type: 'TextControl',
label: t('Partition Limit'),
isInt: true,
default: '5',
description:
t('The maximum number of subdivisions of each group; ' +
'lower values are pruned first'),
},

partition_threshold: {
type: 'TextControl',
label: t('Partition Threshold'),
isFloat: true,
default: '0.05',
description:
t('Partitions whose height to parent height proportions are ' +
'below this value are pruned'),
},
};
export default controls;
27 changes: 27 additions & 0 deletions superset/assets/javascripts/explore/stores/visTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,33 @@ export const visTypes = {
},
],
},

partition: {
label: 'Partition Diagram',
showOnExplore: true,
controlPanelSections: [
sections.NVD3TimeSeries[0],
{
label: t('Time Series Options'),
expanded: true,
controlSetRows: [
['time_series_option'],
],
},
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['color_scheme'],
['number_format', 'date_time_format'],
['partition_limit', 'partition_threshold'],
['log_scale', 'equal_date_size'],
['rich_tooltip'],
],
},
sections.NVD3TimeSeries[1],
],
},
};

export default visTypes;
Expand Down
1 change: 1 addition & 0 deletions superset/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"d3-sankey": "^0.4.2",
"d3-svg-legend": "^1.x",
"d3-tip": "^0.6.7",
"d3-hierarchy": "^1.1.5",
"datamaps": "^0.5.8",
"datatables.net-bs": "^1.10.15",
"distributions": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions superset/assets/visualizations/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ const vizMap = {
dual_line: require('./nvd3_vis.js'),
event_flow: require('./EventFlow.jsx'),
paired_ttest: require('./paired_ttest.jsx'),
partition: require('./partition.js'),
};
export default vizMap;
27 changes: 27 additions & 0 deletions superset/assets/visualizations/partition.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.partition .chart {
display: block;
margin: auto;
font-size: 11px;
}

.partition rect {
stroke: #eee;
fill: #aaa;
fill-opacity: .8;
transition: fill-opacity 180ms linear;
cursor: pointer;
}

.partition rect:hover {
fill-opacity: 1;
}

.partition g text {
font-weight: bold;
pointer-events: none;
fill: rgba(0, 0, 0, 0.8);
}

.partition g:hover text {
fill: rgba(0, 0, 0, 1);
}
Loading