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

fix(Charts New): tooltip supports dark theme #465

Merged
merged 1 commit into from
Apr 29, 2020
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
4 changes: 2 additions & 2 deletions packages/charts/src/components/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
import { ChartDataLabel } from '@ui5/webcomponents-react-charts/lib/components/ChartDataLabel';
import { XAxisTicks } from '@ui5/webcomponents-react-charts/lib/components/XAxisTicks';
import { YAxisTicks } from '@ui5/webcomponents-react-charts/lib/components/YAxisTicks';
import { tickLineConfig } from '../../internal/MeasureAxisProps';
import { tickLineConfig, tooltipContentStyle } from '../../internal/staticProps';

const formatYAxisTicks = (tick = '') => {
const splitTick = tick.split(' ');
Expand Down Expand Up @@ -243,7 +243,7 @@ const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<a
label={chartConfig.referenceLine.label}
/>
)}
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} />
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
{chartConfig.zoomingTool && (
<Brush
y={10}
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/components/ColumnChart/ColumnChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useTooltipFormatter } from '../../hooks/useTooltipFormatter';
import { IChartDimension } from '../../interfaces/IChartDimension';
import { IChartMeasure } from '../../interfaces/IChartMeasure';
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
import { tickLineConfig } from '../../internal/MeasureAxisProps';
import { tickLineConfig, tooltipContentStyle } from '../../internal/staticProps';

interface MeasureConfig extends IChartMeasure {
/**
Expand Down Expand Up @@ -252,7 +252,7 @@ const ColumnChart: FC<ColumnChartProps> = forwardRef((props: ColumnChartProps, r
yAxisId={'left'}
/>
)}
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} />
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
{chartConfig.zoomingTool && (
<Brush
y={10}
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/components/ComposedChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { useTooltipFormatter } from '../../hooks/useTooltipFormatter';
import { IChartDimension } from '../../interfaces/IChartDimension';
import { IChartMeasure } from '../../interfaces/IChartMeasure';
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
import { tickLineConfig } from '../../internal/MeasureAxisProps';
import { tickLineConfig, tooltipContentStyle } from '../../internal/staticProps';

const dimensionDefaults = {
formatter: (d) => d
Expand Down Expand Up @@ -333,7 +333,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
xAxisId={layout === 'vertical' ? 'primary' : undefined}
/>
)}
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} />
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition ?? 'top'} onClick={onItemLegendClick} />}
{measures?.map((element, index) => {
const ChartElement = (ChartTypes[element.type] as any) as FC<any>;
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/components/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useTooltipFormatter } from '../../hooks/useTooltipFormatter';
import { IChartDimension } from '../../interfaces/IChartDimension';
import { IChartMeasure } from '../../interfaces/IChartMeasure';
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
import { tickLineConfig } from '../../internal/MeasureAxisProps';
import { tickLineConfig, tooltipContentStyle } from '../../internal/staticProps';

interface MeasureConfig extends IChartMeasure {
/**
Expand Down Expand Up @@ -242,7 +242,7 @@ const LineChart: FC<LineChartProps> = forwardRef((props: LineChartProps, ref: Re
yAxisId={'left'}
/>
)}
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} />
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
{chartConfig.zoomingTool && (
<Brush
y={10}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Bar, BarChart as MicroBarChartLib, Cell, Tooltip, XAxis, YAxis } from '
import { BarChartPlaceholder } from '../BarChart/Placeholder';
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
import { IChartMeasure } from '../../interfaces/IChartMeasure';
import { tooltipContentStyle } from '../../internal/staticProps';

interface MeasureConfig extends Omit<IChartMeasure, 'accessor' | 'color'> {
/**
Expand Down Expand Up @@ -170,7 +171,7 @@ const MicroBarChart: FC<MicroBarChartProps> = forwardRef((props: MicroBarChartPr
/>
))}
</Bar>
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} />
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
</MicroBarChartLib>
</ChartContainer>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/components/PieChart/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Cell, Label, Legend, Pie, PieChart as PieChartLib, Tooltip } from 'rech
import { getValueByDataKey } from 'recharts/lib/util/ChartUtils';
import { IChartMeasure } from '../../interfaces/IChartMeasure';
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
import { tooltipContentStyle } from '../../internal/staticProps';

interface MeasureConfig extends Omit<IChartMeasure, 'accessor' | 'label' | 'color'> {
/**
Expand Down Expand Up @@ -150,7 +151,7 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
/>
))}
</Pie>
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} />
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition} onClick={onItemLegendClick} />}
</PieChartLib>
</ChartContainer>
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/components/RadarChart/RadarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IChartDimension } from '../../interfaces/IChartDimension';
import { IChartMeasure } from '../../interfaces/IChartMeasure';
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
import { ChartDataLabel } from '@ui5/webcomponents-react-charts/lib/components/ChartDataLabel';
import { tooltipContentStyle } from '../../internal/staticProps';

interface MeasureConfig extends IChartMeasure {
/**
Expand Down Expand Up @@ -158,7 +159,7 @@ const RadarChart: FC<RadarChartProps> = forwardRef((props: RadarChartProps, ref:
/>
);
})}
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} />
<Tooltip cursor={{ fillOpacity: 0.3 }} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition} onClick={onItemLegendClick} />}
</RadarChartLib>
</ChartContainer>
Expand Down
1 change: 0 additions & 1 deletion packages/charts/src/internal/MeasureAxisProps.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/charts/src/internal/staticProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ThemingParameters } from '@ui5/webcomponents-react-base/lib/ThemingParameters';

export const tickLineConfig = { stroke: 'transparent' };
export const tooltipContentStyle = { backgroundColor: ThemingParameters.sapBackgroundColor };