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

Restyle Remove Helper Classes from visualizations #4821

Closed
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
8 changes: 1 addition & 7 deletions client/app/components/visualizations/editor/Switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import Typography from "antd/lib/typography";
import "./Switch.less";

export default function Switch({ id, children, disabled, ...props }) {
const fallbackId = useMemo(
() =>
`visualization-editor-control-${Math.random()
.toString(36)
.substr(2, 10)}`,
[]
);
const fallbackId = useMemo(() => `visualization-editor-control-${Math.random().toString(36).substr(2, 10)}`, []);
id = id || fallbackId;

if (children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ ControlLabel.defaultProps = {
export default function withControlLabel(WrappedControl) {
// eslint-disable-next-line react/prop-types
function ControlWrapper({ className, id, layout, label, labelProps, disabled, ...props }) {
const fallbackId = useMemo(
() =>
`visualization-editor-control-${Math.random()
.toString(36)
.substr(2, 10)}`,
[]
);
const fallbackId = useMemo(() => `visualization-editor-control-${Math.random().toString(36).substr(2, 10)}`, []);
labelProps = {
...labelProps,
htmlFor: id || fallbackId,
Expand Down
12 changes: 6 additions & 6 deletions client/app/visualizations/chart/Editor/AxisSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default function AxisSettings({ id, options, features, onChange }) {
onChange(merge({}, options, newOptions));
}

const [handleNameChange] = useDebouncedCallback(text => {
const [handleNameChange] = useDebouncedCallback((text) => {
const title = isString(text) && text !== "" ? { text } : null;
optionsChanged({ title });
}, 200);

const [handleMinMaxChange] = useDebouncedCallback(opts => optionsChanged(opts), 200);
const [handleMinMaxChange] = useDebouncedCallback((opts) => optionsChanged(opts), 200);

return (
<React.Fragment>
Expand All @@ -29,7 +29,7 @@ export default function AxisSettings({ id, options, features, onChange }) {
label="Scale"
data-test={`Chart.${id}.Type`}
defaultValue={options.type}
onChange={type => optionsChanged({ type })}>
onChange={(type) => optionsChanged({ type })}>
{features.autoDetectType && (
<Select.Option value="-" data-test={`Chart.${id}.Type.Auto`}>
Auto Detect
Expand All @@ -55,7 +55,7 @@ export default function AxisSettings({ id, options, features, onChange }) {
label="Name"
data-test={`Chart.${id}.Name`}
defaultValue={isObject(options.title) ? options.title.text : null}
onChange={event => handleNameChange(event.target.value)}
onChange={(event) => handleNameChange(event.target.value)}
/>
</Section>

Expand All @@ -68,7 +68,7 @@ export default function AxisSettings({ id, options, features, onChange }) {
placeholder="Auto"
data-test={`Chart.${id}.RangeMin`}
defaultValue={toNumber(options.rangeMin)}
onChange={value => handleMinMaxChange({ rangeMin: toNumber(value) })}
onChange={(value) => handleMinMaxChange({ rangeMin: toNumber(value) })}
/>
</Grid.Col>
<Grid.Col span={12}>
Expand All @@ -77,7 +77,7 @@ export default function AxisSettings({ id, options, features, onChange }) {
placeholder="Auto"
data-test={`Chart.${id}.RangeMax`}
defaultValue={toNumber(options.rangeMax)}
onChange={value => handleMinMaxChange({ rangeMax: toNumber(value) })}
onChange={(value) => handleMinMaxChange({ rangeMax: toNumber(value) })}
/>
</Grid.Col>
</Grid.Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const MappingTypes = {
};

export default function ColumnMappingSelect({ value, availableColumns, type, onChange }) {
const options = sortBy(filter(uniq(flatten([availableColumns, value])), v => isString(v) && v !== ""));
const options = sortBy(filter(uniq(flatten([availableColumns, value])), (v) => isString(v) && v !== ""));
const { label, multiple } = MappingTypes[type];

return (
Expand All @@ -26,8 +26,8 @@ export default function ColumnMappingSelect({ value, availableColumns, type, onC
showSearch
placeholder={multiple ? "Choose columns..." : "Choose column..."}
value={value || undefined}
onChange={column => onChange(column || null, type)}>
{map(options, c => (
onChange={(column) => onChange(column || null, type)}>
{map(options, (c) => (
<Select.Option key={c} value={c} data-test={`Chart.ColumnMapping.${type}.${c}`}>
{c}
</Select.Option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export default function CustomChartSettings({ options, onOptionsChange }) {
data-test="Chart.Custom.Code"
rows="10"
defaultValue={isNil(options.customCode) ? defaultCustomCode : options.customCode}
onChange={event => onOptionsChange({ customCode: event.target.value })}
onChange={(event) => onOptionsChange({ customCode: event.target.value })}
/>
</Section>

<Section>
<Switch
data-test="Chart.Custom.EnableConsoleLogs"
defaultChecked={options.enableConsoleLogs}
onChange={enableConsoleLogs => onOptionsChange({ enableConsoleLogs })}>
onChange={(enableConsoleLogs) => onOptionsChange({ enableConsoleLogs })}>
Show errors in the console
</Switch>
</Section>
Expand All @@ -37,7 +37,7 @@ export default function CustomChartSettings({ options, onOptionsChange }) {
id="chart-editor-auto-update-custom-chart"
data-test="Chart.Custom.AutoUpdate"
defaultChecked={options.autoRedraw}
onChange={autoRedraw => onOptionsChange({ autoRedraw })}>
onChange={(autoRedraw) => onOptionsChange({ autoRedraw })}>
Auto update graph
</Switch>
</Section>
Expand Down
10 changes: 5 additions & 5 deletions client/app/visualizations/chart/Editor/DataLabelsSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function DataLabelsSettings({ options, onOptionsChange }) {
<Checkbox
data-test="Chart.DataLabels.ShowDataLabels"
defaultChecked={options.showDataLabels}
onChange={event => onOptionsChange({ showDataLabels: event.target.checked })}>
onChange={(event) => onOptionsChange({ showDataLabels: event.target.checked })}>
Show Data Labels
</Checkbox>
</Section>
Expand All @@ -35,7 +35,7 @@ export default function DataLabelsSettings({ options, onOptionsChange }) {
}
data-test="Chart.DataLabels.NumberFormat"
defaultValue={options.numberFormat}
onChange={e => debouncedOnOptionsChange({ numberFormat: e.target.value })}
onChange={(e) => debouncedOnOptionsChange({ numberFormat: e.target.value })}
/>
</Section>

Expand All @@ -49,7 +49,7 @@ export default function DataLabelsSettings({ options, onOptionsChange }) {
}
data-test="Chart.DataLabels.PercentFormat"
defaultValue={options.percentFormat}
onChange={e => debouncedOnOptionsChange({ percentFormat: e.target.value })}
onChange={(e) => debouncedOnOptionsChange({ percentFormat: e.target.value })}
/>
</Section>

Expand All @@ -63,7 +63,7 @@ export default function DataLabelsSettings({ options, onOptionsChange }) {
}
data-test="Chart.DataLabels.DateTimeFormat"
defaultValue={options.dateTimeFormat}
onChange={e => debouncedOnOptionsChange({ dateTimeFormat: e.target.value })}
onChange={(e) => debouncedOnOptionsChange({ dateTimeFormat: e.target.value })}
/>
</Section>

Expand Down Expand Up @@ -104,7 +104,7 @@ export default function DataLabelsSettings({ options, onOptionsChange }) {
data-test="Chart.DataLabels.TextFormat"
placeholder="(auto)"
defaultValue={options.textFormat}
onChange={e => debouncedOnOptionsChange({ textFormat: e.target.value })}
onChange={(e) => debouncedOnOptionsChange({ textFormat: e.target.value })}
/>
</Section>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function DefaultColorsSettings({ options, data, onOptionsChange }
presetColors={colors}
placement="topRight"
color={item.color}
onChange={value => updateSeriesOption(item.key, "color", value)}
onChange={(value) => updateSeriesOption(item.key, "color", value)}
addonAfter={<ColorPicker.Label color={item.color} presetColors={colors} />}
/>
),
Expand Down
24 changes: 12 additions & 12 deletions client/app/visualizations/chart/Editor/GeneralSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ function getAvailableColumnMappingTypes(options) {
function getMappedColumns(options, availableColumns) {
const mappedColumns = {};
const availableTypes = getAvailableColumnMappingTypes(options);
each(availableTypes, type => {
each(availableTypes, (type) => {
mappedColumns[type] = ColumnMappingSelect.MappingTypes[type].multiple ? [] : null;
});

availableColumns = map(availableColumns, c => c.name);
availableColumns = map(availableColumns, (c) => c.name);
const usedColumns = [];

each(options.columnMapping, (type, column) => {
Expand All @@ -61,7 +61,7 @@ function mappedColumnsToColumnMappings(mappedColumns) {
const result = {};
each(mappedColumns, (value, type) => {
if (isArray(value)) {
each(value, v => {
each(value, (v) => {
result[v] = type;
});
} else {
Expand All @@ -83,7 +83,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
onOptionsChange({
globalSeriesType,
showDataLabels: globalSeriesType === "pie",
seriesOptions: mapValues(options.seriesOptions, series => ({
seriesOptions: mapValues(options.seriesOptions, (series) => ({
...series,
type: globalSeriesType,
})),
Expand Down Expand Up @@ -126,7 +126,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
label="Bubble Size Coefficient"
data-test="Chart.BubbleCoefficient"
defaultValue={options.coefficient}
onChange={value => onOptionsChange({ coefficient: toNumber(value) })}
onChange={(value) => onOptionsChange({ coefficient: toNumber(value) })}
/>
</Section>

Expand All @@ -135,7 +135,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
label="Bubble Size Proportional To"
data-test="Chart.SizeMode"
defaultValue={options.sizemode}
onChange={mode => onOptionsChange({ sizemode: mode })}>
onChange={(mode) => onOptionsChange({ sizemode: mode })}>
<Select.Option value="area" data-test="Chart.SizeMode.Area">
Area
</Select.Option>
Expand All @@ -153,7 +153,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
label="Direction"
data-test="Chart.PieDirection"
defaultValue={options.direction.type}
onChange={type => onOptionsChange({ direction: { type } })}>
onChange={(type) => onOptionsChange({ direction: { type } })}>
<Select.Option value="counterclockwise" data-test="Chart.PieDirection.Counterclockwise">
Counterclockwise
</Select.Option>
Expand All @@ -169,7 +169,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
<Checkbox
data-test="Chart.ShowLegend"
defaultChecked={options.legend.enabled}
onChange={event => onOptionsChange({ legend: { enabled: event.target.checked } })}>
onChange={(event) => onOptionsChange({ legend: { enabled: event.target.checked } })}>
Show Legend
</Checkbox>
</Section>
Expand All @@ -180,7 +180,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
<Checkbox
data-test="Chart.ShowPoints"
defaultChecked={options.showpoints}
onChange={event => onOptionsChange({ showpoints: event.target.checked })}>
onChange={(event) => onOptionsChange({ showpoints: event.target.checked })}>
Show All Points
</Checkbox>
</Section>
Expand All @@ -193,7 +193,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
data-test="Chart.Stacking"
defaultValue={options.series.stacking}
disabled={!includes(["line", "area", "column"], options.globalSeriesType)}
onChange={stacking => onOptionsChange({ series: { stacking } })}>
onChange={(stacking) => onOptionsChange({ series: { stacking } })}>
<Select.Option value={null} data-test="Chart.Stacking.Disabled">
Disabled
</Select.Option>
Expand All @@ -209,7 +209,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
<Checkbox
data-test="Chart.NormalizeValues"
defaultChecked={options.series.percentValues}
onChange={event => onOptionsChange({ series: { percentValues: event.target.checked } })}>
onChange={(event) => onOptionsChange({ series: { percentValues: event.target.checked } })}>
Normalize values to percentage
</Checkbox>
</Section>
Expand All @@ -221,7 +221,7 @@ export default function GeneralSettings({ options, data, onOptionsChange }) {
label="Missing and NULL values"
data-test="Chart.MissingValues"
defaultValue={options.missingValuesAsZero ? 1 : 0}
onChange={value => onOptionsChange({ missingValuesAsZero: !!value })}>
onChange={(value) => onOptionsChange({ missingValuesAsZero: !!value })}>
<Select.Option value={0} data-test="Chart.MissingValues.Keep">
Do not display in chart
</Select.Option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default function HeatmapColorsSettings({ options, onOptionsChange }) {
placeholder="Choose Color Scheme..."
allowClear
value={options.colorScheme || undefined}
onChange={value => onOptionsChange({ colorScheme: value || null })}>
{map(ColorSchemes, scheme => (
onChange={(value) => onOptionsChange({ colorScheme: value || null })}>
{map(ColorSchemes, (scheme) => (
<Select.Option key={scheme} value={scheme} data-test={`Chart.Colors.Heatmap.ColorScheme.${scheme}`}>
{scheme}
</Select.Option>
Expand All @@ -55,7 +55,7 @@ export default function HeatmapColorsSettings({ options, onOptionsChange }) {
placement="topLeft"
presetColors={ColorPalette}
color={options.heatMinColor}
onChange={heatMinColor => onOptionsChange({ heatMinColor })}
onChange={(heatMinColor) => onOptionsChange({ heatMinColor })}
addonAfter={<ColorPicker.Label color={options.heatMinColor} presetColors={ColorPalette} />}
/>
</Section>
Expand All @@ -68,7 +68,7 @@ export default function HeatmapColorsSettings({ options, onOptionsChange }) {
placement="topRight"
presetColors={ColorPalette}
color={options.heatMaxColor}
onChange={heatMaxColor => onOptionsChange({ heatMaxColor })}
onChange={(heatMaxColor) => onOptionsChange({ heatMaxColor })}
addonAfter={<ColorPicker.Label color={options.heatMaxColor} presetColors={ColorPalette} />}
/>
</Section>
Expand Down
8 changes: 4 additions & 4 deletions client/app/visualizations/chart/Editor/PieColorsSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import getChartData from "../getChartData";

function getUniqueValues(chartData) {
const uniqueValuesNames = new Set();
each(chartData, series => {
each(series.data, row => {
each(chartData, (series) => {
each(series.data, (row) => {
uniqueValuesNames.add(row.x);
});
});
Expand All @@ -27,7 +27,7 @@ export default function PieColorsSettings({ options, data, onOptionsChange }) {

const series = useMemo(
() =>
map(getUniqueValues(getChartData(data.rows, options)), value => ({
map(getUniqueValues(getChartData(data.rows, options)), (value) => ({
key: value,
color: (options.valuesOptions[value] || {}).color || null,
})),
Expand Down Expand Up @@ -63,7 +63,7 @@ export default function PieColorsSettings({ options, data, onOptionsChange }) {
presetColors={colors}
placement="topRight"
color={item.color}
onChange={value => updateValuesOption(item.key, "color", value)}
onChange={(value) => updateValuesOption(item.key, "color", value)}
addonAfter={<ColorPicker.Label color={item.color} presetColors={colors} />}
/>
),
Expand Down
12 changes: 6 additions & 6 deletions client/app/visualizations/chart/Editor/SeriesSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EditorPropTypes } from "@/visualizations/prop-types";
import ChartTypeSelect from "./ChartTypeSelect";
import getChartData from "../getChartData";

const SortableBodyRow = sortableElement(props => <tr {...props} />);
const SortableBodyRow = sortableElement((props) => <tr {...props} />);

function getTableColumns(options, updateSeriesOption, debouncedUpdateSeriesOption) {
const result = [
Expand All @@ -32,7 +32,7 @@ function getTableColumns(options, updateSeriesOption, debouncedUpdateSeriesOptio
data-test={`Chart.Series.${item.key}.Label`}
placeholder={item.key}
defaultValue={item.name}
onChange={event => debouncedUpdateSeriesOption(item.key, "name", event.target.value)}
onChange={(event) => debouncedUpdateSeriesOption(item.key, "name", event.target.value)}
/>
),
},
Expand All @@ -46,7 +46,7 @@ function getTableColumns(options, updateSeriesOption, debouncedUpdateSeriesOptio
<Radio.Group
className="series-settings-y-axis"
value={item.yAxis === 1 ? 1 : 0}
onChange={event => updateSeriesOption(item.key, "yAxis", event.target.value)}>
onChange={(event) => updateSeriesOption(item.key, "yAxis", event.target.value)}>
<Radio value={0} data-test={`Chart.Series.${item.key}.UseLeftAxis`}>
left
</Radio>
Expand All @@ -64,7 +64,7 @@ function getTableColumns(options, updateSeriesOption, debouncedUpdateSeriesOptio
data-test={`Chart.Series.${item.key}.Type`}
dropdownMatchSelectWidth={false}
value={item.type}
onChange={value => updateSeriesOption(item.key, "type", value)}
onChange={(value) => updateSeriesOption(item.key, "type", value)}
/>
),
});
Expand Down Expand Up @@ -120,7 +120,7 @@ export default function SeriesSettings({ options, data, onOptionsChange }) {
lockToContainerEdges
useDragHandle
helperClass="chart-editor-series-dragged-item"
helperContainer={container => container.querySelector("tbody")}
helperContainer={(container) => container.querySelector("tbody")}
onSortEnd={handleSortEnd}
containerProps={{
className: "chart-editor-series",
Expand All @@ -133,7 +133,7 @@ export default function SeriesSettings({ options, data, onOptionsChange }) {
row: SortableBodyRow,
},
}}
onRow={item => ({ index: item.zIndex })}
onRow={(item) => ({ index: item.zIndex })}
pagination={false}
/>
</SortableContainer>
Expand Down
Loading