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

Fix optional and null vis config values #591

Open
thinkh opened this issue Oct 23, 2024 · 0 comments
Open

Fix optional and null vis config values #591

thinkh opened this issue Oct 23, 2024 · 0 comments

Comments

@thinkh
Copy link
Member

thinkh commented Oct 23, 2024

Currently, we are using different ways of null and undefined aka optional property with ?. Here is an example of the scatterplot config:

export interface IScatterConfig extends BaseVisConfig {
type: ESupportedPlotlyVis.SCATTER;
// Numerical columns selected for x and y axis. If 2 are selected, a normal scatter plot is shown. If more than 2 are selected, a SPLOM is shown.
numColumnsSelected: ColumnInfo[];
// This attribute splits the data into multiple scatter plots based on the selected column.
facets: ColumnInfo | null;
// This attribute can be used to directly control which subplots should be shown.
subplots: { xColumn: ColumnInfo; yColumn: ColumnInfo; title: string }[] | undefined;
color: ColumnInfo | null;
numColorScaleType: ENumericalColorScaleType;
shape: ColumnInfo | null;
dragMode: EScatterSelectSettings;
alphaSliderVal: number;
showLabels: ELabelingOptions;
showLabelLimit?: number;
regressionLineOptions?: IRegressionLineOptions;
showLegend?: boolean;
labelColumns?: ColumnInfo[];
}

We should avoid null if the property is optional and use the ? instead.

export interface IScatterConfig extends BaseVisConfig {
  type: ESupportedPlotlyVis.SCATTER;
  // Numerical columns selected for x and y axis. If 2 are selected, a normal scatter plot is shown. If more than 2 are selected, a SPLOM is shown.
  numColumnsSelected: ColumnInfo[];
  // This attribute splits the data into multiple scatter plots based on the selected column.
  facets?: ColumnInfo;
  // This attribute can be used to directly control which subplots should be shown.
  subplots?: { xColumn: ColumnInfo; yColumn: ColumnInfo; title: string }[];
  color?: ColumnInfo;
  numColorScaleType: ENumericalColorScaleType;
  shape?: ColumnInfo;
  dragMode: EScatterSelectSettings;
  alphaSliderVal: number;
  showLabels: ELabelingOptions;
  showLabelLimit?: number;
  regressionLineOptions?: IRegressionLineOptions;
  showLegend?: boolean;
  labelColumns?: ColumnInfo[];
}

By making the facets, color, and shape optional, we must also change the default config by removing the properties with null values:

export const defaultConfig: IScatterConfig = {
  type: ESupportedPlotlyVis.SCATTER,
  numColumnsSelected: [],
  numColorScaleType: ENumericalColorScaleType.SEQUENTIAL,
  dragMode: EScatterSelectSettings.RECTANGLE,
  alphaSliderVal: 0.5,
  showLabels: ELabelingOptions.NEVER,
  showLabelLimit: 50,
  regressionLineOptions: {
    type: ERegressionLineType.NONE,
    fitOptions: { order: 2, precision: 3 },
    lineStyle: defaultRegressionLineStyle,
    showStats: true,
  },
};

Changing this will change the application behavior, hence, it must be tested carefully.

This also applies to other configuration from visualization types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant