Skip to content

Commit

Permalink
Fixing text color of bar labels in bar chart, which are displayed out…
Browse files Browse the repository at this point in the history
…side of a bar. (#20948)

* Fixing text color for bar labels in bar chart, which are displayed outside of the bar.

* Fixing typo

* Set `outsidetextfont` for all charts.

* Adding changelog.
  • Loading branch information
linuspahl committed Nov 19, 2024
1 parent ad7851f commit f87bf80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/issue-20789.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type = "fixed"
message = "Fixing text color of bar labels in bar chart, which are displayed outside of a bar."

issues = ["20789"]
pulls = ["20948"]
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,15 @@ const usePlotLayout = (layout: Partial<Layout>) => {
}, [colors, interactive, layout, theme]);
};

const usePlotChatData = (chartData: Array<any>, setChartColor: (data: ChartConfig, color: ColorMapper) => ChartColor) => {
const usePlotChartData = (chartData: Array<any>, setChartColor: (data: ChartConfig, color: ColorMapper) => ChartColor) => {
const theme = useTheme();
const { colors } = useContext(ChartColorContext);

return useMemo(() => chartData.map((chart) => {
if (setChartColor && colors) {
const conf = setChartColor(chart, colors);

if (chart.type === 'pie') {
conf.outsidetextfont = { color: theme.colors.global.textDefault };
}
conf.outsidetextfont = { color: theme.colors.global.textDefault };

if (chart?.name === eventsDisplayName) {
const eventColor = colors.get(eventsDisplayName, EVENT_COLOR);
Expand All @@ -206,7 +204,7 @@ const usePlotChatData = (chartData: Array<any>, setChartColor: (data: ChartConfi
const GenericPlot = ({ chartData, layout, setChartColor, onClickMarker, onHoverMarker, onUnhoverMarker, onZoom, onAfterPlot }: Props) => {
const interactive = useContext(InteractiveContext);
const plotLayout = usePlotLayout(layout);
const plotChartData = usePlotChatData(chartData, setChartColor);
const plotChartData = usePlotChartData(chartData, setChartColor);
const onRenderComplete = useContext(RenderCompletionCallback);

const _onRelayout = useCallback((axis: Axis) => {
Expand Down

0 comments on commit f87bf80

Please sign in to comment.