diff --git a/packages/react-charts/src/components/ChartBoxPlot/examples/ChartBoxPlot.md b/packages/react-charts/src/components/ChartBoxPlot/examples/ChartBoxPlot.md index fe4d4194141..851bac2d55e 100644 --- a/packages/react-charts/src/components/ChartBoxPlot/examples/ChartBoxPlot.md +++ b/packages/react-charts/src/components/ChartBoxPlot/examples/ChartBoxPlot.md @@ -124,19 +124,31 @@ class EmbeddedLegend extends React.Component { // Note: Container order is important const CursorVoronoiContainer = createContainer("voronoi", "cursor"); const legendData = [ - { childName: 'cats', name: 'Cats' }, { childName: 'limit', name: 'Limit', symbol: { fill: chart_color_orange_300.var, type: 'threshold' } }, + { childName: 'cats', name: 'Cats' }, + // Force extra space below for line wrapping + { + childName: 'cats', + name: '', + symbol: { fill: 'none' } + }, + { + childName: 'cats', + name: '', + symbol: { fill: 'none' } + }, ]; const labelFormatter = (datum) => { // With box plot data, datum.y will also be an array if (datum && (datum._min || datum._median || datum._max || datum._q1 || datum._q3)) { - return `q1: ${datum._q1}, q3: ${datum._q3}`; + return `Min: ${datum._min}, Max: ${datum._max}\nMedian: ${datum._median}\nQ1: ${datum._q1}, Q3: ${datum._q3}`; } - return `${datum.y !== null ? datum.y : 'no data'}`; + const yVal = Array.isArray(datum.y) ? datum.y[0] : datum.y; + return yVal !== null ? yVal : 'no data'; } return (
@@ -147,19 +159,7 @@ class EmbeddedLegend extends React.Component { labelFormatter(datum)} - labelComponent={ - datum.x} - /> - } + labelComponent={ datum.x} />} mouseFollowTooltips voronoiDimension="x" voronoiPadding={50} @@ -182,15 +182,6 @@ class EmbeddedLegend extends React.Component { > - +
); @@ -218,7 +218,7 @@ This demonstrates how to embed HTML within a tooltip. Combining cursor and voron ```js import React from 'react'; -import { Chart, ChartAxis, ChartBoxPlot, ChartCursorFlyout, ChartCursorTooltip, ChartThemeColor, createContainer } from '@patternfly/react-charts'; +import { Chart, ChartAxis, ChartBoxPlot, ChartCursorTooltip, ChartThemeColor, createContainer } from '@patternfly/react-charts'; class EmbeddedHtml extends React.Component { constructor(props) { @@ -292,8 +292,6 @@ class EmbeddedHtml extends React.Component { labels={({ datum }) => `${datum.y}`} labelComponent={ width > center.x + flyoutWidth + 10 ? offset : -offset}} - flyout={} flyoutHeight={145} flyoutWidth={110} labelComponent={ datum.x} />} diff --git a/packages/react-charts/src/components/ChartTooltip/examples/ChartTooltip.md b/packages/react-charts/src/components/ChartTooltip/examples/ChartTooltip.md index a9274b57602..c1e6ee994ee 100644 --- a/packages/react-charts/src/components/ChartTooltip/examples/ChartTooltip.md +++ b/packages/react-charts/src/components/ChartTooltip/examples/ChartTooltip.md @@ -296,7 +296,7 @@ This demonstrates how to embed HTML within a tooltip. Combining cursor and voron ```js import React from 'react'; -import { Chart, ChartArea, ChartAxis, ChartCursorFlyout, ChartCursorTooltip, ChartGroup, ChartPoint, ChartThemeColor, createContainer } from '@patternfly/react-charts'; +import { Chart, ChartArea, ChartAxis, ChartCursorTooltip, ChartGroup, ChartPoint, ChartThemeColor, createContainer } from '@patternfly/react-charts'; class EmbeddedHtml extends React.Component { constructor(props) { @@ -327,12 +327,25 @@ class EmbeddedHtml extends React.Component { {text.map((val, index) => ( - - {} + + + + { + + } + + {legendData[index].name} @@ -356,8 +369,9 @@ class EmbeddedHtml extends React.Component { labels={({ datum }) => `${datum.y !== null ? datum.y : 'no data'}`} labelComponent={ width > center.x + flyoutWidth + 10 ? offset : -offset}} - flyout={} + // The offset and flyout component are not necessary here, but included for completeness + // centerOffset={{x: ({ center, flyoutWidth, width, offset = flyoutWidth / 2 + 10 }) => width > center.x + flyoutWidth + 10 ? offset : -offset}} + // flyoutComponent={} flyoutHeight={110} flyoutWidth={({ datum }) => datum.y === null ? 160 : 125 } labelComponent={ datum.x} />}