Skip to content

Commit

Permalink
fix: Resolved another circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-knight authored and markmcdowell committed Jul 13, 2022
1 parent 5921432 commit 8ac704c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
14 changes: 2 additions & 12 deletions packages/core/src/Chart.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ScaleContinuousNumeric, scaleLinear } from "d3-scale";
import { ScaleContinuousNumeric } from "d3-scale";
import * as React from "react";
import { ChartCanvasContext, chartCanvasContextDefaultValue, ChartCanvasContextType } from "./ChartCanvas";
import { ChartConfig } from "./utils/ChartDataUtil";
import type { ChartConfig } from "./utils/ChartDataUtil";

export type ChartContextType = Omit<ChartCanvasContextType<number | Date>, "chartConfig"> & {
chartConfig: ChartConfig;
Expand Down Expand Up @@ -111,14 +111,4 @@ export const Chart = React.memo((props: React.PropsWithChildren<ChartProps>) =>
);
});

export const ChartDefaultConfig = {
flipYScale: false,
id: 0,
origin: [0, 0],
padding: 0,
yPan: true,
yPanEnabled: false,
yScale: scaleLinear(),
};

Chart.displayName = "Chart";
15 changes: 12 additions & 3 deletions packages/core/src/utils/ChartDataUtil.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { extent } from "d3-array";
import { ScaleContinuousNumeric, ScaleTime } from "d3-scale";
import { ScaleContinuousNumeric, scaleLinear, ScaleTime } from "d3-scale";
import flattenDeep from "lodash.flattendeep";
import * as React from "react";

import { ChartDefaultConfig, ChartProps } from "../Chart";
import type { ChartProps } from "../Chart";

import { functor, getClosestItem, isNotDefined, isObject, last, mapObject, shallowEqual, zipper } from "./index";

Expand Down Expand Up @@ -31,6 +30,16 @@ export interface ChartConfig {
mouseCoordinates?: { at: string; format: () => unknown };
}

export const ChartDefaultConfig = {
flipYScale: false,
id: 0,
origin: [0, 0],
padding: 0,
yPan: true,
yPanEnabled: false,
yScale: scaleLinear(),
};

export function getChartOrigin(origin: any, contextWidth: number, contextHeight: number) {
const originCoordinates = typeof origin === "function" ? origin(contextWidth, contextHeight) : origin;

Expand Down

0 comments on commit 8ac704c

Please sign in to comment.