Skip to content

Commit

Permalink
[Dashboard] Pass in title to Charts (#122319)
Browse files Browse the repository at this point in the history
* Pass title from dashboard panel to charts

* Fix lint

* Fix CI

* Fix CI

* Fix CI

* Add 'ariaLabel' in expressions

* Fix text

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
VladLasitsa and kibanamachine authored Feb 7, 2022
1 parent de77a99 commit 807c625
Show file tree
Hide file tree
Showing 48 changed files with 224 additions and 20 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,27 @@ export const gaugeFunction = (): GaugeExpressionFunctionDefinition => ({
}),
required: false,
},
ariaLabel: {
types: ['string'],
help: i18n.translate('expressionGauge.functions.gaugeChart.config.ariaLabel.help', {
defaultMessage: 'Specifies the aria label of the gauge chart',
}),
required: false,
},
},
fn(data, args) {
fn(data, args, handlers) {
return {
type: 'render',
as: EXPRESSION_GAUGE_NAME,
value: {
data,
args,
args: {
...args,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
},
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type GaugeArguments = GaugeState & {
shape: GaugeShape;
colorMode: GaugeColorMode;
palette?: PaletteOutput<CustomPaletteState>;
ariaLabel?: string;
};

export type GaugeInput = Datatable;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ export const GaugeComponent: FC<GaugeRenderProps> = memo(

return (
<Chart>
<Settings debugState={window._echDebugStateFlag ?? false} theme={chartTheme} />
<Settings
debugState={window._echDebugStateFlag ?? false}
theme={chartTheme}
ariaLabel={args.ariaLabel}
ariaUseDefaultSummary={!args.ariaLabel}
/>
<Goal
id="goal"
subtype={subtype}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ export const heatmapFunction = (): HeatmapExpressionFunctionDefinition => ({
defaultMessage: 'The id of the split column or the corresponding dimension',
}),
},
ariaLabel: {
types: ['string'],
help: i18n.translate('expressionHeatmap.functions.args.ariaLabelHelpText', {
defaultMessage: 'Specifies the aria label of the heat map',
}),
required: false,
},
},
fn(data, args, handlers) {
if (handlers?.inspectorAdapters?.tables) {
Expand Down Expand Up @@ -203,7 +210,13 @@ export const heatmapFunction = (): HeatmapExpressionFunctionDefinition => ({
as: EXPRESSION_HEATMAP_NAME,
value: {
data,
args,
args: {
...args,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
},
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface HeatmapArguments {
splitColumnAccessor?: string | ExpressionValueVisDimension;
legend: HeatmapLegendConfigResult;
gridConfig: HeatmapGridConfigResult;
ariaLabel?: string;
}

export type HeatmapInput = Datatable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ export const HeatmapComponent: FC<HeatmapRenderProps> = memo(
: NaN,
}}
onBrushEnd={interactive ? (onBrushEnd as BrushEndListener) : undefined}
ariaLabel={args.ariaLabel}
ariaUseDefaultSummary={!args.ariaLabel}
/>
<Heatmap
id="heatmap"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export const strings = {
i18n.translate('expressionPartitionVis.waffle.function.args.showValuesInLegendHelpText', {
defaultMessage: 'Show values in legend',
}),
getAriaLabelHelp: () =>
i18n.translate('expressionPartitionVis.reusable.functions.args.ariaLabelHelpText', {
defaultMessage: 'Specifies the aria label of the chart',
}),

getSliceSizeHelp: () =>
i18n.translate('expressionPartitionVis.reusable.function.dimension.metric', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export const mosaicVisFunction = (): MosaicVisExpressionFunctionDefinition => ({
help: strings.getLabelsArgHelp(),
default: `{${PARTITION_LABELS_FUNCTION}}`,
},
ariaLabel: {
types: ['string'],
help: strings.getAriaLabelHelp(),
required: false,
},
},
fn(context, args, handlers) {
const maxSupportedBuckets = 2;
Expand All @@ -95,6 +100,10 @@ export const mosaicVisFunction = (): MosaicVisExpressionFunctionDefinition => ({

const visConfig: PartitionVisParams = {
...args,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
palette: args.palette,
dimensions: {
metric: args.metric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export const pieVisFunction = (): PieVisExpressionFunctionDefinition => ({
help: strings.getStartFromSecondLargestSliceArgHelp(),
default: true,
},
ariaLabel: {
types: ['string'],
help: strings.getAriaLabelHelp(),
required: false,
},
},
fn(context, args, handlers) {
if (args.splitColumn && args.splitRow) {
Expand All @@ -117,6 +122,10 @@ export const pieVisFunction = (): PieVisExpressionFunctionDefinition => ({

const visConfig: PartitionVisParams = {
...args,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
palette: args.palette,
dimensions: {
metric: args.metric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export const treemapVisFunction = (): TreemapVisExpressionFunctionDefinition =>
help: strings.getLabelsArgHelp(),
default: `{${PARTITION_LABELS_FUNCTION}}`,
},
ariaLabel: {
types: ['string'],
help: strings.getAriaLabelHelp(),
required: false,
},
},
fn(context, args, handlers) {
const maxSupportedBuckets = 2;
Expand All @@ -95,6 +100,10 @@ export const treemapVisFunction = (): TreemapVisExpressionFunctionDefinition =>

const visConfig: PartitionVisParams = {
...args,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
palette: args.palette,
dimensions: {
metric: args.metric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ export const waffleVisFunction = (): WaffleVisExpressionFunctionDefinition => ({
help: strings.getShowValuesInLegendArgHelp(),
default: false,
},
ariaLabel: {
types: ['string'],
help: strings.getAriaLabelHelp(),
required: false,
},
},
fn(context, args, handlers) {
if (args.splitColumn && args.splitRow) {
Expand All @@ -90,6 +95,10 @@ export const waffleVisFunction = (): WaffleVisExpressionFunctionDefinition => ({
const buckets = args.bucket ? [args.bucket] : [];
const visConfig: PartitionVisParams = {
...args,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
palette: args.palette,
dimensions: {
metric: args.metric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface VisCommonParams {
legendPosition: Position;
truncateLegend: boolean;
maxLegendLines: number;
ariaLabel?: string;
}

interface VisCommonConfig extends VisCommonParams {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ const PartitionVisComponent = (props: PartitionVisComponentProps) => {
]}
baseTheme={chartBaseTheme}
onRenderChange={onRenderChange}
ariaLabel={props.visParams.ariaLabel}
ariaUseDefaultSummary={!props.visParams.ariaLabel}
/>
<Partition
id={visType}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const strings = {
bucket: i18n.translate('expressionTagcloud.functions.tagcloud.args.bucketHelpText', {
defaultMessage: 'bucket dimension configuration',
}),
ariaLabel: i18n.translate('expressionTagcloud.functions.tagcloud.args.ariaLabelHelpText', {
defaultMessage: 'Specifies the aria label of the tagcloud',
}),
},
dimension: {
tags: i18n.translate('expressionTagcloud.functions.tagcloud.dimension.tags', {
Expand Down Expand Up @@ -123,6 +126,11 @@ export const tagcloudFunction: ExpressionTagcloudFunction = () => {
types: ['vis_dimension'],
help: argHelp.bucket,
},
ariaLabel: {
types: ['string'],
help: argHelp.ariaLabel,
required: false,
},
},
fn(input, args, handlers) {
const visParams: TagCloudRendererParams = {
Expand All @@ -136,6 +144,10 @@ export const tagcloudFunction: ExpressionTagcloudFunction = () => {
bucket: args.bucket,
}),
palette: args.palette,
ariaLabel:
args.ariaLabel ??
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
};

if (handlers?.inspectorAdapters?.tables) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface TagCloudCommonParams {
minFontSize: number;
maxFontSize: number;
showLabel: boolean;
ariaLabel?: string;
}

export interface TagCloudVisConfig extends TagCloudCommonParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ export const TagCloudChart = ({
{(resizeRef) => (
<div className="tgcChart__wrapper" ref={resizeRef} data-test-subj="tagCloudVisualization">
<Chart size="100%">
<Settings onElementClick={handleWordClick} onRenderChange={onRenderChange} />
<Settings
onElementClick={handleWordClick}
onRenderChange={onRenderChange}
ariaLabel={visParams.ariaLabel}
ariaUseDefaultSummary={!visParams.ariaLabel}
/>
<Wordcloud
id="tagCloud"
startAngle={0}
Expand Down
Loading

0 comments on commit 807c625

Please sign in to comment.