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

feat: Hide Animation behind feature flag & fix column animations #1042

Merged
merged 2 commits into from
May 16, 2023
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
14 changes: 9 additions & 5 deletions app/charts/column/columns-grouped.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,22 @@ export const ColumnsGrouped = () => {
const y0 = yScale(0);
const renderData: GroupedRenderDatum[] = React.useMemo(() => {
return grouped.map((segment) => {
const key = segment[0];

return {
key: segment[0],
x: xScale(segment[0]) as number,
key,
x: xScale(key) as number,
data: segment[1].map((d) => {
const x = getSegment(d);
const y = getY(d) ?? NaN;

return {
x: xScaleIn(getSegment(d)) as number,
key: `${key}-${x}`,
x: xScaleIn(x) as number,
y: yScale(Math.max(y, 0)),
width: bandwidth,
height: Math.abs(yScale(y) - y0),
color: colors(getSegment(d)),
color: colors(x),
};
}),
};
Expand All @@ -109,7 +113,7 @@ export const ColumnsGrouped = () => {
.selectAll<SVGRectElement, RenderDatum>("rect")
.data(
(d) => d.data,
(d) => d.x
(d) => d.key
)
.call(renderColumn, y0);
}
Expand Down
14 changes: 11 additions & 3 deletions app/charts/column/columns-simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@ export const Columns = () => {
};

return preparedData.map((d) => {
const xScaled = xScale(getX(d)) as number;
const x = getX(d);
const xScaled = xScale(x) as number;
const y = getY(d) ?? NaN;
const yScaled = yScale(y);
const height = Math.abs(yScaled - y0);
const color = getColor(y);

return { x: xScaled, y: yScaled, width: bandwidth, height, color };
return {
key: x,
x: xScaled,
y: yScaled,
width: bandwidth,
height,
color,
};
});
}, [
preparedData,
Expand All @@ -83,7 +91,7 @@ export const Columns = () => {
if (ref.current) {
select(ref.current)
.selectAll<SVGRectElement, RenderDatum>("rect")
.data(renderData, (d) => d.x)
.data(renderData, (d) => d.key)
.call(renderColumn, y0);
}
}, [renderData, yScale, y0]);
Expand Down
7 changes: 5 additions & 2 deletions app/charts/column/columns-stacked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ export const ColumnsStacked = () => {
return {
key,
data: d.map((segment: $FixMe) => {
const x = getX(segment.data);

return {
x: xScale(getX(segment.data)) as number,
key: `${key}-${x}`,
x: xScale(x) as number,
y: yScale(segment[1]),
width: bandwidth,
height: y0 - yScale(segment[1] - segment[0]),
Expand All @@ -48,7 +51,7 @@ export const ColumnsStacked = () => {
.selectAll<SVGRectElement, RenderDatum>("rect")
.data(
(d) => d.data,
(d) => `${d.x}-${d.y}`
(d) => d.key
)
.call(renderColumn, y0);
}
Expand Down
1 change: 1 addition & 0 deletions app/charts/column/rendering-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Selection } from "d3";

export type RenderDatum = {
key: string;
x: number;
y: number;
width: number;
Expand Down
5 changes: 4 additions & 1 deletion app/configurator/components/chart-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
useConfiguratorState,
} from "@/configurator/configurator-state";
import { isStandardErrorDimension, isTemporalDimension } from "@/domain/data";
import { flag } from "@/flags";
import {
HierarchyValue,
PossibleFiltersDocument,
Expand Down Expand Up @@ -777,7 +778,9 @@ const ChartFields = ({
(d) => d.iri === (chartConfig.fields as any)[field]?.componentIri
);

return isMapConfig(chartConfig) && field === "baseLayer" ? (
return field === "animation" &&
!flag("timeslider") ? null : isMapConfig(chartConfig) &&
field === "baseLayer" ? (
<OnOffControlTabField
key={field}
value={field}
Expand Down