From be21b864fbde7cae7839831a62530a3497354eab Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Fri, 13 May 2022 19:07:50 +0200 Subject: [PATCH 1/6] fix: rename Dendogram to Dendrogram --- README.md | 8 ++++---- ...r.spec.ts => DendrogramController.spec.ts} | 18 +++++++++--------- ...mController.ts => DendrogramController.ts} | 12 ++++++------ src/controllers/TreeController.ts | 10 +++++----- ...ller-spec-ts-dendogram-default-1-snap.png} | Bin ...spec-ts-dendogram-default-tree-1-snap.png} | Bin ...ler-spec-ts-dendogram-directed-1-snap.png} | Bin ...oller-spec-ts-dendogram-radial-1-snap.png} | Bin ...-spec-ts-dendogram-radial-tree-1-snap.png} | Bin ...ler-spec-ts-dendogram-vertical-1-snap.png} | Bin ...pec-ts-dendogram-vertical-tree-1-snap.png} | Bin src/controllers/index.ts | 2 +- src/index.umd.ts | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) rename src/controllers/{DendogramController.spec.ts => DendrogramController.spec.ts} (87%) rename src/controllers/{DendogramController.ts => DendrogramController.ts} (90%) rename src/controllers/__image_snapshots__/{dendogram-controller-spec-ts-dendogram-default-1-snap.png => dendrogram-controller-spec-ts-dendogram-default-1-snap.png} (100%) rename src/controllers/__image_snapshots__/{dendogram-controller-spec-ts-dendogram-default-tree-1-snap.png => dendrogram-controller-spec-ts-dendogram-default-tree-1-snap.png} (100%) rename src/controllers/__image_snapshots__/{dendogram-controller-spec-ts-dendogram-directed-1-snap.png => dendrogram-controller-spec-ts-dendogram-directed-1-snap.png} (100%) rename src/controllers/__image_snapshots__/{dendogram-controller-spec-ts-dendogram-radial-1-snap.png => dendrogram-controller-spec-ts-dendogram-radial-1-snap.png} (100%) rename src/controllers/__image_snapshots__/{dendogram-controller-spec-ts-dendogram-radial-tree-1-snap.png => dendrogram-controller-spec-ts-dendogram-radial-tree-1-snap.png} (100%) rename src/controllers/__image_snapshots__/{dendogram-controller-spec-ts-dendogram-vertical-1-snap.png => dendrogram-controller-spec-ts-dendogram-vertical-1-snap.png} (100%) rename src/controllers/__image_snapshots__/{dendogram-controller-spec-ts-dendogram-vertical-tree-1-snap.png => dendrogram-controller-spec-ts-dendogram-vertical-tree-1-snap.png} (100%) diff --git a/README.md b/README.md index 60bd8fb..4fa9435 100644 --- a/README.md +++ b/README.md @@ -101,25 +101,25 @@ Computes the x,y position of nodes based on a force simulation. It is based on h ### Options -## Dendogram, Tree +## Dendrogram, Tree chart types: `dendogram`, `tree` The tree and dendograms layouts are based on https://github.com/d3/d3-hierarchy. -**Dendogram Horizontal** +**Dendrogram Horizontal** ![dend_h](https://user-images.githubusercontent.com/4129778/65398352-9bc03f80-dd84-11e9-9197-ecb66a872736.png) [![Open in CodePen][codepen]](https://codepen.io/sgratzl/pen/jObedwg) -**Dendogram Vertical** +**Dendrogram Vertical** ![dend_v](https://user-images.githubusercontent.com/4129778/65398355-9bc03f80-dd84-11e9-9ea3-9501a79491fb.png) [![Open in CodePen][codepen]](https://codepen.io/sgratzl/pen/jObedwg) -**Dendogram Radial** +**Dendrogram Radial** ![radial](https://user-images.githubusercontent.com/4129778/65398460-581a0580-dd85-11e9-93b6-b70946f1155f.png) diff --git a/src/controllers/DendogramController.spec.ts b/src/controllers/DendrogramController.spec.ts similarity index 87% rename from src/controllers/DendogramController.spec.ts rename to src/controllers/DendrogramController.spec.ts index 2d84720..c7ef403 100644 --- a/src/controllers/DendogramController.spec.ts +++ b/src/controllers/DendrogramController.spec.ts @@ -1,18 +1,18 @@ import { registry, PointElement, LinearScale } from 'chart.js'; import createChart from '../__tests__/createChart'; -import { DendogramController } from './DendogramController'; +import { DendrogramController } from './DendrogramController'; import nodes from './__tests__/tree'; import { EdgeLine } from '../elements'; describe('dendogram', () => { beforeAll(() => { - registry.addControllers(DendogramController); + registry.addControllers(DendrogramController); registry.addElements(EdgeLine, PointElement); registry.addScales(LinearScale); }); test('default', () => { return createChart({ - type: DendogramController.id as 'dendogram', + type: DendrogramController.id as 'dendogram', data: { labels: nodes.map((d) => d.name), datasets: [ @@ -28,7 +28,7 @@ describe('dendogram', () => { }); test('vertical', () => { return createChart({ - type: DendogramController.id as 'dendogram', + type: DendrogramController.id as 'dendogram', data: { labels: nodes.map((d) => d.name), datasets: [ @@ -47,7 +47,7 @@ describe('dendogram', () => { }); test('radial', () => { return createChart({ - type: DendogramController.id as 'dendogram', + type: DendrogramController.id as 'dendogram', data: { labels: nodes.map((d) => d.name), datasets: [ @@ -67,7 +67,7 @@ describe('dendogram', () => { test('default tree', () => { return createChart({ - type: DendogramController.id as 'dendogram', + type: DendrogramController.id as 'dendogram', data: { labels: nodes.map((d) => d.name), datasets: [ @@ -86,7 +86,7 @@ describe('dendogram', () => { }); test('vertical tree', () => { return createChart({ - type: DendogramController.id as 'dendogram', + type: DendrogramController.id as 'dendogram', data: { labels: nodes.map((d) => d.name), datasets: [ @@ -106,7 +106,7 @@ describe('dendogram', () => { }); test('radial tree', () => { return createChart({ - type: DendogramController.id as 'dendogram', + type: DendrogramController.id as 'dendogram', data: { labels: nodes.map((d) => d.name), datasets: [ @@ -126,7 +126,7 @@ describe('dendogram', () => { }); test('directed', () => { return createChart({ - type: DendogramController.id as 'dendogram', + type: DendrogramController.id as 'dendogram', data: { labels: nodes.map((d) => d.name), datasets: [ diff --git a/src/controllers/DendogramController.ts b/src/controllers/DendrogramController.ts similarity index 90% rename from src/controllers/DendogramController.ts rename to src/controllers/DendrogramController.ts index 4551506..6c4fd92 100644 --- a/src/controllers/DendogramController.ts +++ b/src/controllers/DendrogramController.ts @@ -23,7 +23,7 @@ export interface ITreeOptions { orientation: 'horizontal' | 'vertical' | 'radial'; } -export class DendogramController extends GraphController { +export class DendrogramController extends GraphController { declare options: { tree: ITreeOptions }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types @@ -142,7 +142,7 @@ export class DendogramController extends GraphController { ]); } -export interface IDendogramChartControllerDatasetOptions extends IGraphChartControllerDatasetOptions { +export interface IDendrogramChartControllerDatasetOptions extends IGraphChartControllerDatasetOptions { tree: ITreeOptions; } @@ -150,7 +150,7 @@ declare module 'chart.js' { export interface ChartTypeRegistry { dendogram: { chartOptions: CoreChartOptions<'dendogram'>; - datasetOptions: IDendogramChartControllerDatasetOptions; + datasetOptions: IDendrogramChartControllerDatasetOptions; defaultDataPoint: IGraphDataPoint[]; metaExtensions: Record; parsedDataType: ITreeNode & { angle?: number }; @@ -159,14 +159,14 @@ declare module 'chart.js' { } } -export class DendogramChart extends Chart< +export class DendrogramChart extends Chart< 'dendogram', DATA, LABEL > { - static id = DendogramController.id; + static id = DendrogramController.id; constructor(item: ChartItem, config: Omit, 'type'>) { - super(item, patchController('dendogram', config, DendogramController, [EdgeLine, PointElement], LinearScale)); + super(item, patchController('dendogram', config, DendrogramController, [EdgeLine, PointElement], LinearScale)); } } diff --git a/src/controllers/TreeController.ts b/src/controllers/TreeController.ts index c12404a..169895e 100644 --- a/src/controllers/TreeController.ts +++ b/src/controllers/TreeController.ts @@ -1,15 +1,15 @@ import { Chart, ChartConfiguration, ChartItem, LinearScale, PointElement } from 'chart.js'; import { merge } from 'chart.js/helpers'; import { EdgeLine } from '../elements'; -import { DendogramController, IDendogramChartControllerDatasetOptions } from './DendogramController'; +import { DendrogramController, IDendrogramChartControllerDatasetOptions } from './DendrogramController'; import type { IGraphDataPoint, ITreeNode } from './GraphController'; import patchController from './patchController'; -export class TreeController extends DendogramController { +export class TreeController extends DendrogramController { static readonly id = 'tree'; static readonly defaults: any = /* #__PURE__ */ merge({}, [ - DendogramController.defaults, + DendrogramController.defaults, { datasets: { tree: { @@ -19,14 +19,14 @@ export class TreeController extends DendogramController { }, ]); - static readonly overrides: any = /* #__PURE__ */ DendogramController.overrides; + static readonly overrides: any = /* #__PURE__ */ DendrogramController.overrides; } declare module 'chart.js' { export interface ChartTypeRegistry { tree: { chartOptions: CoreChartOptions<'tree'>; - datasetOptions: IDendogramChartControllerDatasetOptions; + datasetOptions: IDendrogramChartControllerDatasetOptions; defaultDataPoint: IGraphDataPoint; metaExtensions: Record; parsedDataType: ITreeNode; diff --git a/src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-default-1-snap.png b/src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-default-1-snap.png similarity index 100% rename from src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-default-1-snap.png rename to src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-default-1-snap.png diff --git a/src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-default-tree-1-snap.png b/src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-default-tree-1-snap.png similarity index 100% rename from src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-default-tree-1-snap.png rename to src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-default-tree-1-snap.png diff --git a/src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-directed-1-snap.png b/src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-directed-1-snap.png similarity index 100% rename from src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-directed-1-snap.png rename to src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-directed-1-snap.png diff --git a/src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-radial-1-snap.png b/src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-radial-1-snap.png similarity index 100% rename from src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-radial-1-snap.png rename to src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-radial-1-snap.png diff --git a/src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-radial-tree-1-snap.png b/src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-radial-tree-1-snap.png similarity index 100% rename from src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-radial-tree-1-snap.png rename to src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-radial-tree-1-snap.png diff --git a/src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-vertical-1-snap.png b/src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-vertical-1-snap.png similarity index 100% rename from src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-vertical-1-snap.png rename to src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-vertical-1-snap.png diff --git a/src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-vertical-tree-1-snap.png b/src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-vertical-tree-1-snap.png similarity index 100% rename from src/controllers/__image_snapshots__/dendogram-controller-spec-ts-dendogram-vertical-tree-1-snap.png rename to src/controllers/__image_snapshots__/dendrogram-controller-spec-ts-dendogram-vertical-tree-1-snap.png diff --git a/src/controllers/index.ts b/src/controllers/index.ts index 68f5cd5..40dd876 100644 --- a/src/controllers/index.ts +++ b/src/controllers/index.ts @@ -1,4 +1,4 @@ export * from './GraphController'; export * from './ForceDirectedGraphController'; -export * from './DendogramController'; +export * from './DendrogramController'; export * from './TreeController'; diff --git a/src/index.umd.ts b/src/index.umd.ts index 97ac634..c766a43 100644 --- a/src/index.umd.ts +++ b/src/index.umd.ts @@ -1,8 +1,8 @@ import { registry } from 'chart.js'; -import { DendogramController, ForceDirectedGraphController, GraphController, TreeController } from './controllers'; +import { DendrogramController, ForceDirectedGraphController, GraphController, TreeController } from './controllers'; import { EdgeLine } from './elements'; export * from '.'; -registry.addControllers(DendogramController, ForceDirectedGraphController, GraphController, TreeController); +registry.addControllers(DendrogramController, ForceDirectedGraphController, GraphController, TreeController); registry.addElements(EdgeLine); From 6ec192772596e614c88ebbc3ac575bafc1f71710 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Fri, 13 May 2022 19:19:52 +0200 Subject: [PATCH 2/6] fix: rename to dendrogram in a backward compatible way closes #32 --- README.md | 6 +-- samples/directed.html | 6 +-- samples/multi.html | 4 +- samples/radial.html | 2 +- samples/radiallabel.html | 2 +- samples/tree.html | 6 +-- samples/treelabel.html | 4 +- samples/type_test.ts | 2 +- src/controllers/DendrogramController.spec.ts | 16 ++++---- src/controllers/DendrogramController.ts | 39 ++++++++++++++++---- src/controllers/forceDirected.spec.ts | 2 +- src/index.umd.ts | 16 +++++++- 12 files changed, 70 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 4fa9435..5744b44 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![NPM Package][npm-image]][npm-url] [![Github Actions][github-actions-image]][github-actions-url] -Chart.js module for charting graphs. Adding new chart types: `graph`, `forceDirectedGraph`, `dendogram`, and `tree`. +Chart.js module for charting graphs. Adding new chart types: `graph`, `forceDirectedGraph`, `dendrogram`, and `tree`. ![force](https://user-images.githubusercontent.com/4129778/65398353-9bc03f80-dd84-11e9-8f14-339635c1ba4e.png) @@ -103,9 +103,9 @@ Computes the x,y position of nodes based on a force simulation. It is based on h ## Dendrogram, Tree -chart types: `dendogram`, `tree` +chart types: `dendrogram`, `tree` -The tree and dendograms layouts are based on https://github.com/d3/d3-hierarchy. +The tree and dendrograms layouts are based on https://github.com/d3/d3-hierarchy. **Dendrogram Horizontal** diff --git a/samples/directed.html b/samples/directed.html index 108c02c..06d462f 100644 --- a/samples/directed.html +++ b/samples/directed.html @@ -8,8 +8,8 @@
- + - + - +