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

chore: General cleanup #654

Merged
merged 6 commits into from
Aug 24, 2022
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
11 changes: 2 additions & 9 deletions app/charts/area/areas-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import {
useTimeFormatUnit,
} from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import { sortByIndex } from "@/lib/array";
import { estimateTextWidth } from "@/lib/estimate-text-width";
import { useLocale } from "@/locales/use-locale";
import { sortByIndex } from "@/utils/array";
import { estimateTextWidth } from "@/utils/estimate-text-width";
import { makeOrdinalDimensionSorter } from "@/utils/sorting-values";

export interface AreasState {
Expand Down Expand Up @@ -359,13 +359,6 @@ const useAreasState = ({
getCategory: getSegment,
sortOrder: "asc",
});
const cumulativeSum = (
(sum) => (d: Observation) =>
(sum += getY(d) ?? 0)
)(0);
const cumulativeRulerItemValues = [
...sortedTooltipValues.map(cumulativeSum),
];

const yAnchor = 0;

Expand Down
4 changes: 1 addition & 3 deletions app/charts/area/areas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { memo } from "react";

import { AreasState } from "@/charts/area/areas-state";
import { useChartState } from "@/charts/shared/use-chart-state";
import { useTheme } from "@/themes";

export const Areas = () => {
const { bounds, getX, xScale, yScale, colors, series, segments } =
const { bounds, getX, xScale, yScale, colors, series } =
useChartState() as AreasState;
const theme = useTheme();
const areaGenerator = area<$FixMe>()
.defined((d) => d[0] !== null && d[1] !== null)
.x((d) => xScale(getX(d.data)))
Expand Down
4 changes: 0 additions & 4 deletions app/charts/area/chart-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
DataSource,
InteractiveFiltersConfig,
} from "@/configurator";
import { isNumber } from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import {
DimensionMetadataFragment,
Expand Down Expand Up @@ -70,7 +69,6 @@ export const ChartAreasVisualization = ({
observations={observations.data}
dimensions={dimensions}
measures={measures}
fields={chartConfig.fields}
/>
<ChartAreas
observations={observations.data}
Expand All @@ -84,8 +82,6 @@ export const ChartAreasVisualization = ({
) : (
<NoDataHint />
);
} else if (observations && !observations.map((obs) => obs.y).some(isNumber)) {
return <NoDataHint />;
} else if (error) {
return <LoadingDataError />;
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/charts/bar/bars-grouped-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import { Bounds, Observer, useWidth } from "@/charts/shared/use-width";
import { BarFields, SortingOrder, SortingType } from "@/configurator";
import { getPalette, mkNumber } from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import { sortByIndex } from "@/lib/array";
import { useLocale } from "@/locales/use-locale";
import { sortByIndex } from "@/utils/array";

export interface GroupedBarsState {
chartType: string;
Expand Down
4 changes: 0 additions & 4 deletions app/charts/bar/chart-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
FilterValueSingle,
DataSource,
} from "@/configurator";
import { isNumber } from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import {
DimensionMetadataFragment,
Expand Down Expand Up @@ -68,7 +67,6 @@ export const ChartBarsVisualization = ({
observations={observations.data}
dimensions={dimensions}
measures={measures}
fields={chartConfig.fields}
/>
<ChartBars
observations={observations.data}
Expand All @@ -82,8 +80,6 @@ export const ChartBarsVisualization = ({
) : (
<NoDataHint />
);
} else if (observations && !observations.map((obs) => obs.y).some(isNumber)) {
return <NoDataHint />;
} else if (error) {
return <LoadingDataError />;
} else {
Expand Down
4 changes: 0 additions & 4 deletions app/charts/column/chart-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
FilterValueSingle,
InteractiveFiltersConfig,
} from "@/configurator";
import { isNumber } from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import {
DimensionMetadataFragment,
Expand Down Expand Up @@ -80,7 +79,6 @@ export const ChartColumnsVisualization = ({
observations={observations.data}
dimensions={dimensions}
measures={measures}
fields={chartConfig.fields}
/>
<ChartColumns
observations={observations.data}
Expand All @@ -94,8 +92,6 @@ export const ChartColumnsVisualization = ({
) : (
<NoDataHint />
);
} else if (observations && !observations.map((obs) => obs.y).some(isNumber)) {
return <NoDataHint />;
} else if (error) {
return <LoadingDataError />;
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/charts/column/columns-grouped-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import {
useFormatNumber,
} from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import { sortByIndex } from "@/lib/array";
import { useLocale } from "@/locales/use-locale";
import { sortByIndex } from "@/utils/array";
import { makeOrdinalDimensionSorter } from "@/utils/sorting-values";

export interface GroupedColumnsState {
Expand Down
7 changes: 2 additions & 5 deletions app/charts/column/columns-stacked-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import {
useFormatNumber,
} from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import { sortByIndex } from "@/lib/array";
import { useLocale } from "@/locales/use-locale";
import { sortByIndex } from "@/utils/array";
import { makeOrdinalDimensionSorter } from "@/utils/sorting-values";

export interface StackedColumnsState {
Expand Down Expand Up @@ -143,12 +143,11 @@ const useColumnsStackedState = ({
sortData({
data,
getX,
getY,
sortingType,
sortingOrder,
xOrder,
}),
[data, getX, getY, sortingType, sortingOrder, xOrder]
[data, getX, sortingType, sortingOrder, xOrder]
);

// Data for Chart
Expand Down Expand Up @@ -560,14 +559,12 @@ export const StackedColumnsChart = ({
const sortData = ({
data,
getX,
getY,
sortingType,
sortingOrder,
xOrder,
}: {
data: Observation[];
getX: (d: Observation) => string;
getY: (d: Observation) => number | null;
sortingType: SortingType | undefined;
sortingOrder: SortingOrder | undefined;
xOrder: string[];
Expand Down
2 changes: 1 addition & 1 deletion app/charts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
} from "../domain/data";
import { DimensionMetadataFragment } from "../graphql/query-hooks";
import { DataCubeMetadata } from "../graphql/types";
import { unreachableError } from "../lib/unreachable";
import { unreachableError } from "../utils/unreachable";

export const enabledChartTypes: ChartType[] = [
// "bar",
Expand Down
7 changes: 0 additions & 7 deletions app/charts/line/chart-lines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
LineConfig,
LineFields,
} from "@/configurator";
import { isNumber } from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import {
DimensionMetadataFragment,
Expand Down Expand Up @@ -73,7 +72,6 @@ export const ChartLinesVisualization = ({
observations={observations.data}
dimensions={dimensions}
measures={measures}
fields={chartConfig.fields}
/>
<ChartLines
observations={observations.data}
Expand All @@ -87,8 +85,6 @@ export const ChartLinesVisualization = ({
) : (
<NoDataHint />
);
} else if (observations && !observations.map((obs) => obs.y).some(isNumber)) {
return <NoDataHint />;
} else if (error) {
return <LoadingDataError />;
} else {
Expand Down Expand Up @@ -122,7 +118,6 @@ export const ChartLines = memo(function ChartLines({
<ChartSvg>
<AxisHeightLinear /> <AxisTime /> <AxisTimeDomain />
<Lines />
{/* <HoverLine /> <HoverLineValues /> */}
<InteractionHorizontal />
{interactiveFiltersConfig?.time.active && <BrushTime />}
</ChartSvg>
Expand All @@ -131,8 +126,6 @@ export const ChartLines = memo(function ChartLines({

<HoverDotMultiple />

{/* <HoverDot /> */}

<Tooltip type={fields.segment ? "multiple" : "single"} />
</ChartContainer>

Expand Down
41 changes: 0 additions & 41 deletions app/charts/line/hover-line-values.tsx

This file was deleted.

60 changes: 0 additions & 60 deletions app/charts/line/hover-line.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions app/charts/line/lines-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import {
useTimeFormatUnit,
} from "@/configurator/components/ui-helpers";
import { Observation } from "@/domain/data";
import { sortByIndex } from "@/lib/array";
import { estimateTextWidth } from "@/lib/estimate-text-width";
import { useTheme } from "@/themes";
import { sortByIndex } from "@/utils/array";
import { estimateTextWidth } from "@/utils/estimate-text-width";
import { makeOrdinalDimensionSorter } from "@/utils/sorting-values";

export interface LinesState {
Expand Down
2 changes: 0 additions & 2 deletions app/charts/line/lines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import { Fragment, memo } from "react";
import { LinesState } from "@/charts/line/lines-state";
import { useChartState } from "@/charts/shared/use-chart-state";
import { Observation } from "@/domain/data";
import { useTheme } from "@/themes";

export const Lines = () => {
const { getX, xScale, getY, yScale, grouped, colors, bounds } =
useChartState() as LinesState;
const theme = useTheme();

const lineGenerator = line<Observation>()
.defined((d) => getY(d) !== null)
Expand Down
2 changes: 1 addition & 1 deletion app/charts/map/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useMemo, useState } from "react";
import { ViewState } from "react-map-gl";

import { BBox } from "@/configurator/config-types";
import useEvent from "@/lib/use-event";
import useEvent from "@/utils/use-event";

import { AreaLayer, SymbolLayer } from "../../domain/data";

Expand Down
2 changes: 1 addition & 1 deletion app/charts/map/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { useInteraction } from "@/charts/shared/use-interaction";
import { BBox } from "@/configurator/config-types";
import { GeoFeature, GeoPoint } from "@/domain/data";
import { Icon, IconName } from "@/icons";
import useEvent from "@/lib/use-event";
import { useLocale } from "@/src";
import useEvent from "@/utils/use-event";

import "maplibre-gl/dist/maplibre-gl.css";

Expand Down
1 change: 0 additions & 1 deletion app/charts/pie/chart-pie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const ChartPieVisualization = ({
observations={observations.data}
dimensions={dimensions}
measures={measures}
fields={chartConfig.fields}
/>
<ChartPie
observations={observations.data}
Expand Down
Loading