diff --git a/client/app/visualizations/chart/Editor/AxisSettings.jsx b/client/app/visualizations/chart/Editor/AxisSettings.jsx new file mode 100644 index 0000000000..45af149f64 --- /dev/null +++ b/client/app/visualizations/chart/Editor/AxisSettings.jsx @@ -0,0 +1,104 @@ +import { isString, isObject, isFinite, isNumber, merge } from 'lodash'; +import React from 'react'; +import PropTypes from 'prop-types'; +import Select from 'antd/lib/select'; +import Input from 'antd/lib/input'; +import InputNumber from 'antd/lib/input-number'; +import * as Grid from 'antd/lib/grid'; + +function toNumber(value) { + value = isNumber(value) ? value : parseFloat(value); + return isFinite(value) ? value : null; +} + +export default function AxisSettings({ id, options, features, onChange }) { + function optionsChanged(newOptions) { + onChange(merge({}, options, newOptions)); + } + + function handleNameChange(event) { + const text = event.target.value; + const title = isString(text) && (text !== '') ? { text } : null; + optionsChanged({ title }); + } + + return ( + + + Scale + optionsChanged({ type })} + > + {features.autoDetectType && Auto Detect} + Datetime + Linear + Logarithmic + Category + + + + + Name + + + + {features.range && ( + + + Min Value + optionsChanged({ rangeMin: toNumber(value) })} + /> + + + Max Value + optionsChanged({ rangeMax: toNumber(value) })} + /> + + + )} + + ); +} + +AxisSettings.propTypes = { + id: PropTypes.string.isRequired, + options: PropTypes.shape({ + type: PropTypes.string.isRequired, + title: PropTypes.shape({ + text: PropTypes.string, + }), + rangeMin: PropTypes.number, + rangeMax: PropTypes.number, + }).isRequired, + features: PropTypes.shape({ + autoDetectType: PropTypes.bool, + range: PropTypes.bool, + }), + onChange: PropTypes.func, +}; + +AxisSettings.defaultProps = { + features: {}, + onChange: () => {}, +}; diff --git a/client/app/visualizations/chart/Editor/XAxisSettings.jsx b/client/app/visualizations/chart/Editor/XAxisSettings.jsx index 010640c442..6ad2070705 100644 --- a/client/app/visualizations/chart/Editor/XAxisSettings.jsx +++ b/client/app/visualizations/chart/Editor/XAxisSettings.jsx @@ -1,48 +1,18 @@ -import { isString, isObject } from 'lodash'; import React from 'react'; import Switch from 'antd/lib/switch'; -import Input from 'antd/lib/input'; -import Select from 'antd/lib/select'; import { EditorPropTypes } from '@/visualizations'; -export default function XAxisSettings({ options, onOptionsChange }) { - function handleNameChange(event) { - const text = event.target.value; - if (isString(text) && (text !== '')) { - onOptionsChange({ xAxis: { title: { text } } }); - } else { - onOptionsChange({ xAxis: { title: null } }); - } - } +import AxisSettings from './AxisSettings'; +export default function XAxisSettings({ options, onOptionsChange }) { return ( - - Scale - onOptionsChange({ xAxis: { type } })} - > - Auto Detect - Datetime - Linear - Logarithmic - Category - - - - - Name - - + onOptionsChange({ xAxis })} + /> diff --git a/client/app/visualizations/chart/Editor/YAxisSettings.jsx b/client/app/visualizations/chart/Editor/YAxisSettings.jsx index 7bbeeff4e1..dc4e28c7cd 100644 --- a/client/app/visualizations/chart/Editor/YAxisSettings.jsx +++ b/client/app/visualizations/chart/Editor/YAxisSettings.jsx @@ -1,9 +1,64 @@ import React from 'react'; +import Switch from 'antd/lib/switch'; import { EditorPropTypes } from '@/visualizations'; -export default function YAxisSettings() { +import AxisSettings from './AxisSettings'; + +export default function YAxisSettings({ options, onOptionsChange }) { + const [leftYAxis, rightYAxis] = options.yAxis; + return ( - Y Axis Settings + + + Left Y Axis + onOptionsChange({ yAxis: [axis, rightYAxis] })} + /> + + + {(options.globalSeriesType !== 'heatmap') && ( + + Right Y Axis + onOptionsChange({ yAxis: [leftYAxis, axis] })} + /> + + )} + + {(options.globalSeriesType === 'heatmap') && ( + + + + onOptionsChange({ sortY })} + /> + Sort Values + + + + + + onOptionsChange({ reverseY })} + /> + Reverse Order + + + + )} + ); }