Skip to content

Commit

Permalink
Merge pull request #748 from visualize-admin/fix/metadata-axis-height…
Browse files Browse the repository at this point in the history
…-linear

fix: Metadata is now correctly displayed for Grouped and Stacked column charts
  • Loading branch information
bprusinowski authored Sep 29, 2022
2 parents 2ed88c8 + fb94cc4 commit 8cbfc9a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/charts/column/columns-grouped-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface GroupedColumnsState {
segments: string[];
colors: ScaleOrdinal<string, string>;
yAxisLabel: string;
yAxisDescription: string | undefined;
grouped: [string, Observation[]][];
getAnnotationInfo: (d: Observation) => TooltipInfo;
showStandardError: boolean;
Expand Down Expand Up @@ -339,6 +340,7 @@ const useGroupedColumnsState = (
}

const yAxisLabel = getLabelWithUnit(yMeasure);
const yAxisDescription = yMeasure.description || undefined;

// Group
const grouped = useMemo(() => {
Expand Down Expand Up @@ -478,6 +480,7 @@ const useGroupedColumnsState = (
getSegment,
getSegmentLabel,
yAxisLabel,
yAxisDescription,
segments,
colors,
grouped,
Expand Down
5 changes: 4 additions & 1 deletion app/charts/column/columns-stacked-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
sum,
} from "d3";
import keyBy from "lodash/keyBy";
import sortBy from "lodash/sortBy"
import sortBy from "lodash/sortBy";
import React, { ReactNode, useCallback, useMemo } from "react";

import {
Expand Down Expand Up @@ -77,6 +77,7 @@ export interface StackedColumnsState {
segments: string[];
colors: ScaleOrdinal<string, string>;
yAxisLabel: string;
yAxisDescription: string | undefined;
chartWideData: ArrayLike<Observation>;
allDataWide: ArrayLike<Observation>;
grouped: [string, Observation[]][];
Expand Down Expand Up @@ -352,6 +353,7 @@ const useColumnsStackedState = (
}

const yAxisLabel = getLabelWithUnit(yMeasure);
const yAxisDescription = yMeasure.description || undefined;

const yScale = scaleLinear().domain(yStackDomain).nice();

Expand Down Expand Up @@ -530,6 +532,7 @@ const useColumnsStackedState = (
getSegment,
getSegmentLabel,
yAxisLabel,
yAxisDescription,
segments,
colors,
chartWideData,
Expand Down
4 changes: 4 additions & 0 deletions app/charts/shared/axis-height-linear.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { select, Selection } from "d3";
import { useEffect, useRef } from "react";

import { AreasState } from "@/charts/area/areas-state";
import { GroupedColumnsState } from "@/charts/column/columns-grouped-state";
import { StackedColumnsState } from "@/charts/column/columns-stacked-state";
import { ColumnsState } from "@/charts/column/columns-state";
import { LinesState } from "@/charts/line/lines-state";
import { ScatterplotState } from "@/charts/scatterplot/scatterplot-state";
Expand All @@ -24,6 +26,8 @@ export const AxisHeightLinear = () => {
const { yScale, yAxisLabel, yAxisDescription, bounds } = useChartState() as
| AreasState
| ColumnsState
| GroupedColumnsState
| StackedColumnsState
| LinesState
| ScatterplotState;

Expand Down

1 comment on commit 8cbfc9a

@vercel
Copy link

@vercel vercel bot commented on 8cbfc9a Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

visualization-tool – ./

visualization-tool-git-main-ixt1.vercel.app
visualization-tool-alpha.vercel.app
visualization-tool-ixt1.vercel.app

Please sign in to comment.