Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/flat-suns-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@chart-io/core": minor
"@chart-io/react": minor
---

Removes sub-packages @chart-io/types @chart-io/d3 @chart-io/detection
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: pnpm Install
run: pnpm install
- name: pnpm build
run: pnpm build
- name: Chromatic
uses: chromaui/action@v11.20.2
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/push-to-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: pnpm Install
run: pnpm install
- name: pnpm build
run: pnpm build
- name: Deploy
run: pnpm storybook:deploy
env:
Expand Down Expand Up @@ -138,6 +140,8 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: pnpm Install
run: pnpm install
- name: pnpm build
run: pnpm build
- name: Chromatic
uses: chromaui/action@v11.20.2
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:package": "node scripts/choice build",
"changeset": "changeset",
"clean": "rm -rf node_modules && pnpm -r clean",
"dev": "turbo run build --scope=@chart-io/* --no-deps && turbo run dev --no-cache --parallel --continue",
"dev": "turbo run build && turbo run dev --no-cache --parallel --continue",
"graph": "turbo run build --graph=graph.html",
"lint": "turbo run lint",
"publish": "changeset publish",
Expand Down
14 changes: 7 additions & 7 deletions packages/core/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ module.exports = {
requireReturn: false,
},
],
"sort-imports": [
"warn",
{
allowSeparatedGroups: true,
ignoreCase: true,
},
],
// "sort-imports": [
// "warn",
// {
// allowSeparatedGroups: true,
// ignoreCase: true,
// },
// ],
},
};
44 changes: 34 additions & 10 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"description": "@chart-io core rendering engine",
"repository": "git@github.com:IPWright83/chart-io.git",
"author": "\"Ian Wright\" <\"ipwright83+dev@gmail.com\">",
"main": "src/index.ts",
"module": "src/index.ts",
"types": "src/index.ts",
"main": "dist/index.umd.js",
"module": "dist/index.es.js",
"types": "dist/index.d.ts",
"homepage": "https://github.com/IPWright83/chart-io",
"scripts": {
"build": "tsc --noEmit",
"build": "vite build",
"test": "jest --config jest.config.js",
"test:coverage": "jest --config jest.config.js --coverage",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf coverage",
"lint": "eslint src",
"lint": "eslint src --fix",
"types": "tsc --noEmit",
"publish": ""
},
Expand All @@ -30,18 +30,40 @@
],
"dependencies": {
"d3-interpolate-path": "^2.2.3",
"d3-array": "^3.2.2",
"d3-axis": "^3.0.0",
"d3-brush": "^3.0.0",
"d3-color": "^3.1.0",
"d3-ease": "^3.0.1",
"d3-format": "^3.1.0",
"d3-scale": "^4.0.2",
"d3-selection": "^3.0.0",
"d3-shape": "^3.2.0",
"d3-time": "^3.1.0",
"d3-time-format": "^4.1.0",
"d3-timer": "^3.0.1",
"d3-transition": "^3.0.1",
"lodash": "^4.17.21",
"proxy-memoize": "^2.0.4",
"uuid": "^9.0.0"
},
"devDependencies": {
"@chart-io/d3": "workspace:*",
"@chart-io/detection": "workspace:*",
"@chart-io/types": "workspace:*",
"@types/d3-array": "^3.0.4",
"@types/d3-axis": "^3.0.2",
"@types/d3-brush": "^3.0.2",
"@types/d3-color": "^3.1.0",
"@types/d3-ease": "^3.0.0",
"@types/d3-format": "^3.0.1",
"@types/d3-scale": "^4.0.3",
"@types/d3-selection": "^3.0.4",
"@types/d3-shape": "^3.1.1",
"@types/d3-time": "^3.0.0",
"@types/d3-time-format": "^4.0.0",
"@types/d3-timer": "^3.0.0",
"@types/d3-transition": "^3.0.3",
"@swc/core": "^1.3.36",
"@swc/jest": "^0.2.24",
"@testing-library/jest-dom": "^5.16.4",
"@types/d3-selection": "^3.0.4",
"@types/jest": "^29.4.0",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^5.51.0",
Expand All @@ -50,7 +72,9 @@
"jest-environment-jsdom": "29.4.1",
"@reduxjs/toolkit": "^2.5.0",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^3.1.0"
"redux-thunk": "^3.1.0",
"vite": "^5.0.6",
"vite-plugin-dts": "^4.5.4"
},
"peerDependencies": {
"@reduxjs/toolkit": "^2.0.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/d3/index.ts → packages/core/src/d3/barrel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ export * from "d3-brush";
export * from "d3-color";
export * from "d3-ease";
export * from "d3-format";
export * from "d3-scale";
export * from "d3-selection";
export * from "d3-shape";
export * from "d3-time-format";
export * from "d3-time";
export * from "d3-time-format";
export * from "d3-timer";
export * from "d3-transition";
export * from "d3-scale";

2 changes: 2 additions & 0 deletions packages/core/src/d3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as d3 from "./barrel";
export { d3 };
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { IData } from "@chart-io/types";
import type { IData } from "../../types";

import { getDataType } from "../getTypes";
import type { IColumnInfo } from "../types";
import { getDataCardinality } from "./getDataCardinality";
import { getDataPointCount } from "./getDataPointCount";
import { getDataSample } from "./getDataSample";
import { getDataType } from "../getTypes";
import { getNullCount } from "./getNullCount";
import { getTypeSpecificColumnInfo } from "./getTypeSpecificColumnInfo";
import type { IColumnInfo } from "../types";

/**
* Gets information about each of the columns in the dataset
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as d3 from "@chart-io/d3";
import { d3 } from "../../d3";

import { getMaxStringLength } from "./getMaxStringLength";
import type { IColumnInfo } from "../types";
import { Type } from "../Type";
import type { IColumnInfo } from "../types";
import { getMaxStringLength } from "./getMaxStringLength";

/**
* Gets column information specific to the type of the field
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export * from "./constants";
export * from "./d3";
export * as detection from "./detection";
export * from "./renderers";
export * from "./store";
export * from "./utils";
export * from "./constants";
export * from "./themes";
export * from "./types";
export * from "./utils";
6 changes: 2 additions & 4 deletions packages/core/src/renderers/area/canvas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as d3 from "@chart-io/d3";
import type { IBandwidthScale, IColor } from "@chart-io/types";

import type { IRenderProps } from "../../types";
import { d3 } from "../../d3";
import type { IBandwidthScale, IColor, IRenderProps } from "../../types";
import { isNullOrUndefined } from "../../utils";

export interface IRenderCanvasAreaPlotProps
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/renderers/area/focus.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as d3 from "@chart-io/d3";
import { IColor, ICoordinate, IData, IInvertScale, IMouseEventType, INumericValue, IScale } from "@chart-io/types";

import { d3 } from "../../d3";
import type { IDispatch } from "../../store";
import { eventActions } from "../../store";
import { IColor, ICoordinate, IData, IInvertScale, IMouseEventType, INumericValue, IScale } from "../../types";
import { getDistance, isNullOrUndefined } from "../../utils";

export interface IAreaFocusProps {
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/renderers/area/render.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as d3 from "@chart-io/d3";
import { IBandwidthScale, IColor } from "@chart-io/types";

import type { IRenderProps } from "../../types";
import { d3 } from "../../d3";
import type { IBandwidthScale, IColor, IRenderProps } from "../../types";
import { interpolateMultiPath, isNullOrUndefined } from "../../utils";

export interface IRenderAreaPlotProps
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/renderers/area/stacked.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as d3 from "@chart-io/d3";
import { IBandwidthScale, IColor } from "@chart-io/types";

import { d3 } from "../../d3";
import type { IBandwidthScale, IColor, IRenderProps } from "../../types";
import { ensureNoScaleOverflow, interpolateMultiPath } from "../../utils";
import type { IRenderProps } from "../../types";

export interface IRenderStackedAreaPlotProps
extends Omit<IRenderProps, "onClick" | "onMouseOut" | "onMouseOver" | "interactive" | "y"> {
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/renderers/area/stackedCanvas.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as d3 from "@chart-io/d3";
import { IBandwidthScale, IColor } from "@chart-io/types";

import { d3 } from "../../d3";
import type { IBandwidthScale, IColor, IRenderProps } from "../../types";
import { ensureNoScaleOverflow } from "../../utils";
import type { IRenderProps } from "../../types";

export interface IRenderCanvasStackedAreaPlotProps
extends Omit<
Expand Down
15 changes: 7 additions & 8 deletions packages/core/src/renderers/area/stackedFocus.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as d3 from "@chart-io/d3";
import { IColor, ICoordinate, IData, IInvertScale, IMouseEventType, INumericValue, IScale } from "@chart-io/types";

import { d3 } from "../../d3";
import type { IDispatch } from "../../store";
import { eventActions } from "../../store";
import { IColor, ICoordinate, IData, IInvertScale, IMouseEventType, INumericValue, IScale } from "../../types";
import { getDistance } from "../../utils";
import type { IDispatch } from "../../store";

export interface IStackedAreaFocusProps {
/**
Expand Down Expand Up @@ -132,8 +131,8 @@ export function stackedFocus({
// Clean up operations on exit
// prettier-ignore
return () => {
markers.forEach((marker) => dispatch(eventActions.removeMarker(marker)));
horizontalDroplines.forEach((horizontalDropline) => dispatch(eventActions.removeDropline(horizontalDropline)) );
verticalDroplines.forEach((verticalDropline) => dispatch(eventActions.removeDropline(verticalDropline)));
};
markers.forEach((marker) => dispatch(eventActions.removeMarker(marker)));
horizontalDroplines.forEach((horizontalDropline) => dispatch(eventActions.removeDropline(horizontalDropline)));
verticalDroplines.forEach((verticalDropline) => dispatch(eventActions.removeDropline(verticalDropline)));
};
}
9 changes: 4 additions & 5 deletions packages/core/src/renderers/area/stackedTooltip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as d3 from "@chart-io/d3";
import { d3 } from "../../d3";
import type { IDispatch } from "../../store";
import { eventActions } from "../../store";
import {
IColor,
ICoordinate,
Expand All @@ -8,10 +10,7 @@ import {
INumericValue,
IScale,
ITooltipItem,
} from "@chart-io/types";

import type { IDispatch } from "../../store";
import { eventActions } from "../../store";
} from "../../types";
import { getDistance } from "../../utils";

export interface IStackedAreaTooltipProps {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/renderers/area/tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as d3 from "@chart-io/d3";
import { IColor, ICoordinate, IData, IInvertScale, IMouseEventType, INumericValue, IScale } from "@chart-io/types";

import { d3 } from "../../d3";
import type { IDispatch } from "../../store";
import { eventActions } from "../../store";
import { IColor, ICoordinate, IData, IInvertScale, IMouseEventType, INumericValue, IScale } from "../../types";
import { getDistance, isNullOrUndefined } from "../../utils";

export interface IAreaTooltipProps {
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/renderers/bar/focus.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import * as d3 from "@chart-io/d3";
import { IColor, IFocused, IScale, ITheme } from "@chart-io/types";

import type { Selection } from "d3-selection";

import { d3 } from "../../d3";
import type { IDispatch } from "../../store";
import { eventActions } from "../../store";
import { IColor, IFocused, IScale, ITheme } from "../../types";
import { getXYFromTransform } from "../../utils";

export interface IBarFocusProps {
Expand Down Expand Up @@ -39,7 +36,7 @@ export function focus({ dispatch, focused, theme, yScale, grouped = false }: IBa

// Get the appropriate attributes
const { element } = focused;
const selection = d3.select(element) as Selection<any, unknown, null, undefined>;
const selection = d3.select(element) as d3.Selection<any, unknown, null, undefined>;
const fill = selection.style("fill");
const y = +selection.attr("y");
const x = +selection.attr("x");
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/renderers/bar/grouped.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type { Transition } from "@chart-io/d3";
import * as d3 from "@chart-io/d3";
import { IColor, IDatum, INumericValue, IValue } from "@chart-io/types";

import type { IRenderProps } from "../../types";
import { d3 } from "../../d3";
import type { IColor, IDatum, INumericValue, IRenderProps, IValue } from "../../types";
import { ensureBandwidth, getBandwidthAndOffset } from "../../utils";

export interface IRenderGroupedBarPlotProps extends Omit<IRenderProps, "x"> {
Expand Down Expand Up @@ -122,7 +119,7 @@ export function grouped({
.duration(animationDuration / 2)
.delay(animationDuration / 2)
.attr("width", (d) => xScale(d.value as INumericValue) - (xScale.range()[0] as number))
.attr("x", () => xScale.range()[0] as number) as Transition<SVGRectElement, { key: string; value: IValue; }, SVGGElement, IDatum>;
.attr("x", () => xScale.range()[0] as number) as d3.Transition<SVGRectElement, { key: string; value: IValue; }, SVGGElement, IDatum>;

return { update, exit };
}
9 changes: 3 additions & 6 deletions packages/core/src/renderers/bar/render.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type { Selection } from "@chart-io/d3";
import * as d3 from "@chart-io/d3";
import { IColor, IDatum, INumericValue } from "@chart-io/types";

import type { IRenderProps } from "../../types";
import { d3 } from "../../d3";
import type { IColor, IDatum, INumericValue, IRenderProps } from "../../types";
import { ensureBandwidth, ensureValuesAreUnique, getBandwidthAndOffset } from "../../utils";

export interface IRenderBarPlotProps extends IRenderProps {
Expand Down Expand Up @@ -60,7 +57,7 @@ export function render({
const join = d3
.select(layer)
.selectAll(".bar")
.data(data, (d) => d[y]) as Selection<SVGRectElement, IDatum, Element, unknown>;
.data(data, (d) => d[y]) as d3.Selection<SVGRectElement, IDatum, Element, unknown>;

// Exit bars
const exit = join.exit().remove();
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/renderers/bar/stacked.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as d3 from "@chart-io/d3";
import { IColor, IDatum } from "@chart-io/types";

import type { IRenderProps } from "../../types";
import { d3 } from "../../d3";
import type { IColor, IDatum, IRenderProps } from "../../types";
import {
ensureBandwidth,
ensureNoScaleOverflow,
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/renderers/bar/tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IColor, IDatum, IMouseEvent } from "@chart-io/types";

import type { IDispatch } from "../../store";
import { eventActions } from "../../store";
import { IColor, IDatum, IMouseEvent } from "../../types";

export interface IBarTooltipProps {
/**
Expand Down
Loading
Loading