Skip to content

Commit 6c93f36

Browse files
Merge pull request #762 from plotly/piescale
Pie scale, tick format
2 parents 23ccec2 + 03a845f commit 6c93f36

8 files changed

Lines changed: 54 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"prop-types": "^15.5.10",
2020
"raf": "^3.4.0",
2121
"react-color": "^2.13.8",
22-
"react-colorscales": "0.6.1",
22+
"react-colorscales": "0.7.2",
2323
"react-dropzone": "^5.0.1",
2424
"react-plotly.js": "^2.2.0",
2525
"react-rangeslider": "^2.2.0",

src/components/fields/DropdownCustom.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Field from './Field';
66
import DropdownWidget from '../widgets/Dropdown';
77
import Text from './Text';
88

9-
class UnconnectedDropdownCustom extends Component {
9+
export class UnconnectedDropdownCustom extends Component {
1010
constructor(props, context) {
1111
super(props, context);
1212

@@ -35,19 +35,20 @@ class UnconnectedDropdownCustom extends Component {
3535

3636
setValue(value, custom = false) {
3737
this.value = value;
38+
const customOpt = this.props.customOpt;
3839
this.setState({
39-
custom: (custom || value === this.props.customOpt) && value !== '',
40+
custom: (custom || value === customOpt) && value !== '',
4041
});
4142
this.props.updateContainer({
42-
[this.props.attr]: value === this.props.customOpt && !custom ? 'custom' : value,
43+
[this.props.attr]: value === customOpt && !custom ? customOpt : value,
4344
});
4445
}
4546

4647
render() {
47-
const {options, attr} = this.props;
48+
const {options, attr, customOpt} = this.props;
4849
const value =
4950
(this.value === '' || !options.map(o => o.value).includes(this.value)) && this.state.custom
50-
? 'custom'
51+
? customOpt
5152
: this.value;
5253

5354
return (

src/components/fields/derived.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import isNumeric from 'fast-isnumeric';
22
import {UnconnectedDropdown} from './Dropdown';
3+
import {UnconnectedDropdownCustom} from './DropdownCustom';
34
import {UnconnectedFlaglist} from './Flaglist';
45
import {UnconnectedNumeric} from './Numeric';
56
import {UnconnectedAxisRangeValue} from './AxisRangeValue';
@@ -145,6 +146,25 @@ export const BinningDropdown = connectToContainer(UnconnectedDropdown, {
145146
},
146147
});
147148

149+
export const TickFormat = connectToContainer(UnconnectedDropdownCustom, {
150+
modifyPlotProps: (props, context, plotProps) => {
151+
const {localize: _} = context;
152+
if (plotProps.fullContainer.type === 'date') {
153+
plotProps.options = [
154+
{label: _('Default'), value: ''},
155+
{label: _('Advanced (d3-time-format)'), value: '%x'},
156+
];
157+
plotProps.customOpt = '%x';
158+
} else {
159+
plotProps.options = [
160+
{label: _('Simple'), value: ''},
161+
{label: _('Advanced (d3-format)'), value: 's'},
162+
];
163+
plotProps.customOpt = 's';
164+
}
165+
},
166+
});
167+
148168
export const ShowInLegend = connectToContainer(UnconnectedVisibilitySelect, {
149169
modifyPlotProps: (props, context, plotProps) => {
150170
plotProps.isVisible = context.fullLayout.showlegend;

src/components/fields/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
ShowInLegend,
5555
HoveronDropdown,
5656
HovermodeDropdown,
57+
TickFormat,
5758
} from './derived';
5859
import {LineDashSelector, LineShapeSelector} from './LineSelectors';
5960

@@ -93,6 +94,7 @@ export {
9394
DualNumeric,
9495
AxisRangeValue,
9596
Text,
97+
TickFormat,
9698
Radio,
9799
SymbolSelector,
98100
RangesliderVisible,

src/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
LocationSelector,
5757
HoveronDropdown,
5858
HovermodeDropdown,
59+
TickFormat,
5960
} from './fields';
6061

6162
import {
@@ -89,6 +90,7 @@ import {Button} from './widgets';
8990
import PanelMenuWrapper from './PanelMenuWrapper';
9091

9192
export {
93+
TickFormat,
9294
AnnotationAccordion,
9395
AxisAnchorDropdown,
9496
AxisOverlayDropdown,

src/components/widgets/ColorscalePicker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class Scale extends Component {
3131
const {onColorscaleChange, selected} = this.props;
3232
const {selectedColorscaleType, showColorscalePicker} = this.state;
3333
const description = COLOR_PICKER_CONSTANTS.COLORSCALE_DESCRIPTIONS[selectedColorscaleType];
34-
const colorscaleOptions = COLOR_PICKER_CONSTANTS.COLORSCALE_TYPES.map(type => ({
34+
const colorscaleOptions = COLOR_PICKER_CONSTANTS.COLORSCALE_TYPES.filter(
35+
type => type !== 'custom'
36+
).map(type => ({
3537
label: type + ' scales',
3638
value: type,
3739
}));

src/default_panels/StyleAxesPanel.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
RangeSelectorAccordion,
2020
VisibilitySelect,
2121
DropdownCustom,
22+
TickFormat,
2223
} from '../components';
2324

2425
class StyleAxesPanel extends Component {
@@ -163,6 +164,12 @@ class StyleAxesPanel extends Component {
163164
]}
164165
/>
165166

167+
<TickFormat
168+
label={_('Label Format')}
169+
attr="tickformat"
170+
dafaultOpt=""
171+
clearable={false}
172+
/>
166173
<Radio
167174
label={_('Separate Thousands')}
168175
attr="separatethousands"
@@ -181,6 +188,17 @@ class StyleAxesPanel extends Component {
181188
{label: _('k/M/B'), value: 'B'},
182189
]}
183190
/>
191+
<Dropdown
192+
label={_('Show Exponents')}
193+
attr="showexponent"
194+
clearable={false}
195+
options={[
196+
{label: _('All'), value: 'all'},
197+
{label: _('First'), value: 'first'},
198+
{label: _('Last'), value: 'last'},
199+
{label: _('None'), value: 'none'},
200+
]}
201+
/>
184202

185203
<DropdownCustom
186204
label={_('Prefix')}

src/default_panels/StyleTracesPanel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
540540
/>
541541
</PlotlySection>
542542
<PlotlySection name={_('Scaling')}>
543-
<Numeric label={_('Bandwidth')} attr="bandwidth" />
543+
<GroupCreator label={_('Scale Group')} prefix={_('Group')} attr="scalegroup" />
544544
<Radio
545545
label={_('Scale Mode')}
546546
attr="scalemode"
@@ -555,6 +555,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
555555
{label: _('Manual'), value: 'manual'},
556556
]}
557557
/>
558+
<Numeric label={_('Bandwidth')} attr="bandwidth" />
558559
<Numeric label={_('Span')} attr="span" />
559560
<Radio
560561
attr="side"

0 commit comments

Comments
 (0)