Skip to content

Commit

Permalink
[Vislib] Removes fontAwesome usage (#113516)
Browse files Browse the repository at this point in the history
* [Vislib] Removes fontAwesome usage

* Fix CI

* Fix types

* Update src/plugins/vis_types/vislib/public/vislib/components/tooltip/_tooltip.scss

Co-authored-by: Caroline Horn <[email protected]>

Co-authored-by: Caroline Horn <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored Oct 4, 2021
1 parent 284732f commit 7162f16
Show file tree
Hide file tree
Showing 20 changed files with 8 additions and 203 deletions.
2 changes: 1 addition & 1 deletion src/plugins/vis_types/vislib/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["charts", "data", "expressions", "visualizations", "kibanaLegacy"],
"requiredPlugins": ["charts", "data", "expressions", "visualizations"],
"requiredBundles": ["kibanaUtils", "visDefaultEditor", "visTypeXy", "visTypePie", "fieldFormats"],
"owner": {
"name": "Vis Editors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@ function LabelsPanel({ stateParams, setValue, setGaugeValue }: GaugeOptionsInter
setGaugeValue('style', { ...stateParams.gauge.style, [paramName]: value })
}
/>

<SwitchOption
disabled={!stateParams.gauge.labels.show}
label={i18n.translate('visTypeVislib.controls.gaugeOptions.displayWarningsLabel', {
defaultMessage: 'Display warnings',
})}
tooltip={i18n.translate('visTypeVislib.controls.gaugeOptions.switchWarningsTooltip', {
defaultMessage:
'Turns on/off warnings. When turned on, a warning will be shown if not all labels could be displayed.',
})}
paramName="isDisplayWarning"
value={stateParams.isDisplayWarning}
setValue={setValue}
/>
</EuiPanel>
);
}
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/vis_types/vislib/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Plugin as ExpressionsPublicPlugin } from '../../../expressions/public';
import { VisualizationsSetup } from '../../../visualizations/public';
import { ChartsPluginSetup } from '../../../charts/public';
import { DataPublicPluginStart } from '../../../data/public';
import { KibanaLegacyStart } from '../../../kibana_legacy/public';
import { LEGACY_PIE_CHARTS_LIBRARY } from '../../pie/common/index';

import { createVisTypeVislibVisFn } from './vis_type_vislib_vis_fn';
Expand All @@ -31,7 +30,6 @@ export interface VisTypeVislibPluginSetupDependencies {
/** @internal */
export interface VisTypeVislibPluginStartDependencies {
data: DataPublicPluginStart;
kibanaLegacy: KibanaLegacyStart;
}

export type VisTypeVislibCoreSetup = CoreSetup<VisTypeVislibPluginStartDependencies, void>;
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/vis_types/vislib/public/vis_controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ export const createVislibVisController = (
return;
}

const [, { kibanaLegacy }] = await core.getStartServices();
kibanaLegacy.loadFontAwesome();

// @ts-expect-error
const { Vis: Vislib } = await import('./vislib/vis');
const { uiState, event: fireEvent } = handlers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
}

.visTooltip__headerIcon {
flex: 0 0 auto;
padding-right: $euiSizeS;
margin-right: $euiSizeXS;
}

.visTooltip__headerText {
Expand Down
55 changes: 0 additions & 55 deletions src/plugins/vis_types/vislib/public/vislib/lib/_alerts.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/plugins/vis_types/vislib/public/vislib/lib/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import './alerts';
@import './layout/index';
79 changes: 0 additions & 79 deletions src/plugins/vis_types/vislib/public/vislib/lib/alerts.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/plugins/vis_types/vislib/public/vislib/lib/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export class Binder {
destroyers.forEach((fn) => fn());
}

jqOn(el: HTMLElement, ...args: [string, (event: JQueryEventObject) => void]) {
jqOn(el: HTMLElement, ...args: [string, (event: JQuery.Event) => void]) {
const $el = $(el);
$el.on(...args);
this.disposal.push(() => $el.off(...args));
}

fakeD3Bind(el: HTMLElement, event: string, handler: (event: JQueryEventObject) => void) {
this.jqOn(el, event, (e: JQueryEventObject) => {
fakeD3Bind(el: HTMLElement, event: string, handler: (event: JQuery.Event) => void) {
this.jqOn(el, event, (e: JQuery.Event) => {
// mimic https://github.com/mbostock/d3/blob/3abb00113662463e5c19eb87cd33f6d0ddc23bc0/src/selection/on.js#L87-L94
const o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = e;
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/vis_types/vislib/public/vislib/lib/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { visTypes as chartTypes } from '../visualizations/vis_types';
import { NoResults } from '../errors';
import { Layout } from './layout/layout';
import { ChartTitle } from './chart_title';
import { Alerts } from './alerts';
import { Axis } from './axis/axis';
import { ChartGrid as Grid } from './chart_grid';
import { Binder } from './binder';
Expand Down Expand Up @@ -46,7 +45,6 @@ export class Handler {
this.ChartClass = chartTypes[visConfig.get('type')];
this.uiSettings = uiSettings;
this.charts = [];

this.vis = vis;
this.visConfig = visConfig;
this.data = visConfig.data;
Expand All @@ -56,7 +54,6 @@ export class Handler {
.map((axisArgs) => new Axis(visConfig, axisArgs));
this.valueAxes = visConfig.get('valueAxes').map((axisArgs) => new Axis(visConfig, axisArgs));
this.chartTitle = new ChartTitle(visConfig);
this.alerts = new Alerts(this, visConfig.get('alerts'));
this.grid = new Grid(this, visConfig.get('grid'));

if (visConfig.get('type') === 'point_series') {
Expand All @@ -69,7 +66,7 @@ export class Handler {

this.layout = new Layout(visConfig);
this.binder = new Binder();
this.renderArray = _.filter([this.layout, this.chartTitle, this.alerts], Boolean);
this.renderArray = _.filter([this.layout, this.chartTitle], Boolean);

this.renderArray = this.renderArray
.concat(this.valueAxes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,6 @@
min-width: 0;
}

.visWrapper__alerts {
position: relative;
}

// General Axes

.visAxis__column--top .axis-div svg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ export function columnLayout(el, data) {
class: 'visWrapper__chart',
splits: chartSplit,
},
{
type: 'div',
class: 'visWrapper__alerts',
},
{
type: 'div',
class: 'visAxis--x visAxis__column--bottom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export function gaugeLayout(el, data) {
class: 'visWrapper__chart',
splits: chartSplit,
},
{
type: 'div',
class: 'visWrapper__alerts',
},
{
type: 'div',
class: 'visAxis__splitTitles--x',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const DEFAULT_VIS_CONFIG = {
style: {
margin: { top: 10, right: 3, bottom: 5, left: 3 },
},
alerts: [],
categoryAxes: [],
valueAxes: [],
grid: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import React from 'react';
import ReactDOM from 'react-dom/server';
import { EuiIcon } from '@elastic/eui';

interface Props {
wholeBucket: boolean;
Expand All @@ -16,7 +17,7 @@ interface Props {
export const touchdownTemplate = ({ wholeBucket }: Props) => {
return ReactDOM.renderToStaticMarkup(
<p className="visTooltip__header">
<i className="fa fa-info-circle visTooltip__headerIcon" />
<EuiIcon type="iInCircle" className="visTooltip__headerIcon" />
<span className="visTooltip__headerText">
{wholeBucket ? 'Part of this bucket' : 'This area'} may contain partial data. The selected
time range does not fully cover it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export class MeterGauge {
const marginFactor = 0.95;
const tooltip = this.gaugeChart.tooltip;
const isTooltip = this.gaugeChart.handler.visConfig.get('addTooltip');
const isDisplayWarning = this.gaugeChart.handler.visConfig.get('isDisplayWarning', false);
const { angleFactor, maxAngle, minAngle } =
this.gaugeConfig.gaugeType === 'Circle' ? circleAngles : arcAngles;
const maxRadius = (Math.min(width, height / angleFactor) / 2) * marginFactor;
Expand Down Expand Up @@ -261,7 +260,6 @@ export class MeterGauge {
.style('fill', (d) => this.getColorBucket(Math.max(min, d.y)));

const smallContainer = svg.node().getBBox().height < 70;
let hiddenLabels = smallContainer;

// If the value label is hidden we later want to hide also all other labels
// since they don't make sense as long as the actual value is hidden.
Expand All @@ -286,7 +284,6 @@ export class MeterGauge {
// The text is too long if it's larger than the inner free space minus a couple of random pixels for padding.
const textTooLong = textLength >= getInnerFreeSpace() - 6;
if (textTooLong) {
hiddenLabels = true;
valueLabelHidden = true;
}
return textTooLong ? 'none' : 'initial';
Expand All @@ -302,9 +299,6 @@ export class MeterGauge {
.style('display', function () {
const textLength = this.getBBox().width;
const textTooLong = textLength > maxRadius;
if (textTooLong) {
hiddenLabels = true;
}
return smallContainer || textTooLong ? 'none' : 'initial';
});

Expand All @@ -317,9 +311,6 @@ export class MeterGauge {
.style('display', function () {
const textLength = this.getBBox().width;
const textTooLong = textLength > maxRadius;
if (textTooLong) {
hiddenLabels = true;
}
return valueLabelHidden || smallContainer || textTooLong ? 'none' : 'initial';
});
}
Expand All @@ -335,10 +326,6 @@ export class MeterGauge {
});
}

if (hiddenLabels && isDisplayWarning) {
this.gaugeChart.handler.alerts.show('Some labels were hidden due to size constraints');
}

//center the visualization
const transformX = width / 2;
const transformY = height / 2 > maxRadius ? height / 2 : maxRadius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ export class HeatmapChart extends PointSeries {
};
}

let hiddenLabels = false;
squares
.append('text')
.text((d) => zAxisFormatter(d.y))
Expand All @@ -257,9 +256,6 @@ export class HeatmapChart extends PointSeries {
const textHeight = this.getBBox().height;
const textTooLong = textLength > maxLength;
const textTooWide = textHeight > maxHeight;
if (!d.hide && (textTooLong || textTooWide)) {
hiddenLabels = true;
}
return d.hide || textTooLong || textTooWide ? 'none' : 'initial';
})
.style('dominant-baseline', 'central')
Expand All @@ -278,9 +274,6 @@ export class HeatmapChart extends PointSeries {
const verticalCenter = y(d) + squareHeight / 2;
return `rotate(${rotate},${horizontalCenter},${verticalCenter})`;
});
if (hiddenLabels) {
this.baseChart.handler.alerts.show('Some labels were hidden due to size constraints');
}
}

if (isTooltip) {
Expand Down
Loading

0 comments on commit 7162f16

Please sign in to comment.