Skip to content

Commit 85fe532

Browse files
[Explore vis] visualization fixes and improvements (#10836)
1. Optimize discover vis performance by turn off visual interactions for data point cound > 1000 2. Fix useDebounceValue bug which onChange get called for initial value 3. Fix discover vis tooltip issue for multiple series data that if field contains vega reserved charaters 4. Fix React missing key warnings 5. Discover vis map PPL field type ip as category 6. Tweaks the label text of vis style panel 7. Fix explore embeddable initially display a "No result" screen --------- Signed-off-by: Yulong Ruan <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent 8e867b7 commit 85fe532

File tree

13 files changed

+99
-61
lines changed

13 files changed

+99
-61
lines changed

changelogs/fragments/10836.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fix:
2+
- Optimize discover vis performance by turn off visual interactions for data point cound > 1000 ([#10836](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10836))
3+
- UseDebounceValue bug which onChange get called for initial value ([#10836](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10836))
4+
- Discover vis tooltip issue for multiple series data that if field contains vega reserved charaters ([#10836](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10836))
5+
- React missing key warnings ([#10836](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10836))
6+
- Tweaks the label text of vis style panel ([#10836](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10836))
7+
- Explore embeddable initially display a "No result" screen ([#10836](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10836))
8+
- Discover vis map PPL field type `ip` as category ([#10836](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10836))

src/plugins/explore/public/application/legacy/discover/application/components/no_results/no_results.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ export const DiscoverNoResults = ({ queryString, query, savedQuery, timeFieldNam
223223
const tabs = useMemo(() => {
224224
const buildSampleQueryBlock = (sampleTitle: string, sampleQuery: string) => {
225225
return (
226-
<>
226+
<Fragment key={sampleQuery}>
227227
<EuiText size="s">{sampleTitle}</EuiText>
228228
<EuiSpacer size="s" />
229229
<EuiCodeBlock isCopyable>{sampleQuery}</EuiCodeBlock>
230230
<EuiSpacer size="s" />
231-
</>
231+
</Fragment>
232232
);
233233
};
234234
return [

src/plugins/explore/public/components/visualizations/bar_gauge/bar_gauge_exclusive_vis_options.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('BarGaugeExclusiveVisOptions', () => {
4545
});
4646
});
4747

48-
it('should call onChange when display mode is changed', () => {
48+
it('should call onChange when display style is changed', () => {
4949
const { getByText } = render(
5050
<BarGaugeExclusiveVisOptions
5151
styles={defaultStyles}

src/plugins/explore/public/components/visualizations/bar_gauge/bar_gauge_exclusive_vis_options.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ export const BarGaugeExclusiveVisOptions = ({
119119
</EuiFormRow>
120120

121121
<EuiFormRow
122-
label={i18n.translate('explore.stylePanel.barGauge.exclusive.displayMode', {
123-
defaultMessage: 'Display mode',
122+
label={i18n.translate('explore.stylePanel.barGauge.exclusive.displayStyle', {
123+
defaultMessage: 'Display style',
124124
})}
125125
>
126126
<EuiButtonGroup
127-
legend={i18n.translate('explore.stylePanel.barGauge.exclusive.displayMode', {
128-
defaultMessage: 'Display mode',
127+
legend={i18n.translate('explore.stylePanel.barGauge.exclusive.displayStyle', {
128+
defaultMessage: 'Display style',
129129
})}
130130
isFullWidth
131131
options={displayModeOption}

src/plugins/explore/public/components/visualizations/bar_gauge/bar_gauge_utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('bar_gauge_utils', () => {
118118
expect(result).toEqual({ x1: 1, y1: 1, x2: 1, y2: 0 });
119119
});
120120

121-
it('returns undefined for non-gradient display mode', () => {
121+
it('returns undefined for non-gradient display style', () => {
122122
const result = getGradientConfig('horizontal', 'basic', false);
123123
expect(result).toBeUndefined();
124124
});

src/plugins/explore/public/components/visualizations/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const FIELD_TYPE_MAP: Partial<Record<string, VisFieldType>> = {
5858
[PPL_FIELD_TYPES.TIMESTAMP]: VisFieldType.Date,
5959
[PPL_FIELD_TYPES.TIME]: VisFieldType.Date,
6060
[PPL_FIELD_TYPES.INTERVAL]: VisFieldType.Unknown,
61-
[PPL_FIELD_TYPES.IP]: VisFieldType.Unknown,
61+
[PPL_FIELD_TYPES.IP]: VisFieldType.Categorical,
6262
[PPL_FIELD_TYPES.GEO_POINT]: VisFieldType.Unknown,
6363
[PPL_FIELD_TYPES.BINARY]: VisFieldType.Unknown,
6464
[PPL_FIELD_TYPES.STRUCT]: VisFieldType.Unknown,

src/plugins/explore/public/components/visualizations/style_panel/axes/axes.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,9 @@ export const AxesOptions: React.FC<AxesOptionsProps> = ({
303303
{isRule2
304304
? // Special rendering for Rule 2: Show both axes with clear labels
305305
valueAxes.slice(0, 2).map((axis, index) => (
306-
<>
306+
<React.Fragment key={axis.id}>
307307
<EuiSplitPanel.Inner
308308
paddingSize="s"
309-
key={axis.id}
310309
color="subdued"
311310
data-test-subj="twoValueAxesPanel"
312311
>
@@ -469,17 +468,12 @@ export const AxesOptions: React.FC<AxesOptionsProps> = ({
469468
</>
470469
)}
471470
</EuiSplitPanel.Inner>
472-
</>
471+
</React.Fragment>
473472
))
474473
: // Standard rendering for other rules
475474
valueAxes.map((axis, index) => (
476-
<>
477-
<EuiSplitPanel.Inner
478-
paddingSize="s"
479-
key={axis.id}
480-
color="subdued"
481-
data-test-subj="ValueAxisPanel"
482-
>
475+
<React.Fragment key={axis.id}>
476+
<EuiSplitPanel.Inner paddingSize="s" color="subdued" data-test-subj="ValueAxisPanel">
483477
<EuiText size="s" style={{ fontWeight: 600 }}>
484478
{i18n.translate('explore.vis.gridOptions.valueAxis', {
485479
defaultMessage: 'Y-Axis',
@@ -627,7 +621,7 @@ export const AxesOptions: React.FC<AxesOptionsProps> = ({
627621
</>
628622
)}
629623
</EuiSplitPanel.Inner>
630-
</>
624+
</React.Fragment>
631625
))}
632626
</StyleAccordion>
633627
);

src/plugins/explore/public/components/visualizations/table/table_vis_options.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export const TableVisStyleControls: React.FC<TableVisStyleControlsProps> = ({
123123
/>
124124
</EuiFormRow>
125125
<EuiFormRow
126-
label={i18n.translate('explore.stylePanel.table.cellTypes', {
127-
defaultMessage: 'Cell types',
126+
label={i18n.translate('explore.stylePanel.table.cellStyle', {
127+
defaultMessage: 'Cell style',
128128
})}
129129
>
130130
<TableCellTypeOptions

src/plugins/explore/public/components/visualizations/utils/__snapshots__/create_hover_state.test.ts.snap

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/explore/public/components/visualizations/utils/create_hover_state.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface Options {
2828
function createTooltip(fields: Field[]) {
2929
const tooltip = fields.map((f) => {
3030
return {
31-
field: f.name,
31+
field: `["${f.name}"]`,
3232
type: f.type,
3333
title: f.title,
3434
...(f.format && { format: f.format }),
@@ -37,6 +37,8 @@ function createTooltip(fields: Field[]) {
3737
return tooltip;
3838
}
3939

40+
const MAX_DATA_POINTS_NUM = 1000;
41+
4042
function createPointLayer(xField: Field, yFields: Field[], colorField?: Field) {
4143
let color = null;
4244
if (colorField) {
@@ -133,6 +135,7 @@ function createHiddenBarLayer(axisConfig: AxisConfig, options: Options & { barOp
133135
axisConfig.x,
134136
...[...uniqueColorFieldValues].map((v) => ({
135137
name: v,
138+
title: v,
136139
type: (axisConfig.y as Field).type,
137140
})),
138141
]);
@@ -177,6 +180,11 @@ function createHiddenBarLayer(axisConfig: AxisConfig, options: Options & { barOp
177180
}
178181

179182
export function createCrosshairLayers(axisConfig: AxisConfig, options: Options) {
183+
// For better performance, don't create crosshair layers if too many data points
184+
if (options.data && options.data.length > MAX_DATA_POINTS_NUM) {
185+
return [];
186+
}
187+
180188
const colors = getColors();
181189
const layers = [];
182190
const yFields = Array<Field>().concat(axisConfig.y);
@@ -224,6 +232,11 @@ export function createCrosshairLayers(axisConfig: AxisConfig, options: Options)
224232
}
225233

226234
export function createHighlightBarLayers(axisConfig: AxisConfig, options: Options) {
235+
// For better performance, don't create highlight bar layers if too many data points
236+
if (options.data && options.data.length > MAX_DATA_POINTS_NUM) {
237+
return [];
238+
}
239+
227240
const layers = [];
228241
const yFields = Array<Field>().concat(axisConfig.y);
229242
const y1Fields = Array<Field>().concat(axisConfig.y1 ? axisConfig.y1 : []);

0 commit comments

Comments
 (0)