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

refactor: Remove JSAPI databar code #1758

Merged
merged 1 commit into from
Jan 31, 2024
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
56 changes: 0 additions & 56 deletions packages/iris-grid/src/IrisGridTableModelTemplate.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only changes we need is for dataBarOptionsForCell to throw, and remove formatDataBar from the Format type in dh.types.ts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataBarOptionsForCell throws from IrisGridModel, so just removing it from the table model template. renderTypeForCell returns text from GridModel, so removing that from the table model template as well

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import memoize from 'memoize-one';
import throttle from 'lodash.throttle';
import {
CellRenderType,
EditOperation,
GridRange,
GridUtils,
Expand Down Expand Up @@ -39,13 +38,6 @@ import {
assertNotNull,
} from '@deephaven/utils';
import { TableUtils, Formatter, FormatterUtils } from '@deephaven/jsapi-utils';
import type {
AxisOption,
DataBarOptions,
DirectionOption,
Marker,
ValuePlacementOption,
} from 'packages/grid/src/DataBarGridModel';
import IrisGridModel, { DisplayColumn } from './IrisGridModel';
import AggregationOperation from './sidebar/aggregations/AggregationOperation';
import IrisGridUtils from './IrisGridUtils';
Expand Down Expand Up @@ -646,54 +638,6 @@ class IrisGridTableModelTemplate<
return 'left';
}

dataBarOptionsForCell(
column: ModelIndex,
row: ModelIndex,
theme: IrisGridThemeType
): DataBarOptions {
const format = this.formatForCell(column, row);
assertNotNull(format);
const { axis, direction, max, min, valuePlacement, value, marker } =
format.formatDataBar;
let { positiveColor, negativeColor, markerColor, opacity } =
format.formatDataBar;

positiveColor = positiveColor ?? theme.positiveBarColor;
negativeColor = negativeColor ?? theme.negativeBarColor;
let databarColor: string | string[] =
format.color ?? (value >= 0 ? positiveColor : negativeColor);
if (databarColor.includes(',')) {
databarColor = databarColor.split(',');
}
markerColor = markerColor ?? theme.markerBarColor;

opacity = valuePlacement.toLowerCase() === 'overlap' ? 0.5 : opacity;

const databarOptions = {
axis: axis.toLowerCase() as AxisOption,
direction: direction.toUpperCase() as DirectionOption,
columnMax: max,
columnMin: min,
opacity,
color: databarColor,
valuePlacement: valuePlacement.toLowerCase() as ValuePlacementOption,
value,
markers: [
{
value: marker,
color: markerColor,
},
] as Marker[],
};

return databarOptions;
}

renderTypeForCell(column: ModelIndex, row: ModelIndex): CellRenderType {
const format = this.formatForCell(column, row);
return format?.formatDataBar != null ? 'dataBar' : 'text';
}

textForColumnHeader(x: ModelIndex, depth = 0): string | undefined {
const header = this.columnAtDepth(x, depth);
if (isColumnHeaderGroup(header)) {
Expand Down
15 changes: 0 additions & 15 deletions packages/jsapi-types/src/dh.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,21 +887,6 @@ export interface Format {
readonly color: string;
readonly backgroundColor: string;
readonly formatString: string;
readonly formatDataBar: DatabarFormat;
}

export interface DatabarFormat {
axis: string;
direction: string;
max: number;
min: number;
negativeColor: string | string[];
opacity: number;
positiveColor: string | string[];
valuePlacement: string;
value: number;
marker: number;
markerColor: string | string[];
}

export interface ColumnStatistics {
Expand Down
Loading