1.0.16 • Published 10 months ago

cw-gantt-chart v1.0.16

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

cw-gantt-chart

An unique way of rendering gantt chart with collapsible rows

cw-gantt-chart is a lightweight yet powerful gantt chart.

banner.png

Features ✨

  • ⚡ Lightweight and performant
  • 🎨 Customizable
  • ❆ Collapsible
  • 📝 Built in data processor
  • ⚡️ Data highlight
  • ⭕️ Error rendering

Basic Usage 🚀

Install the Package

First, install the cw-gantt-chart package using npm or yarn:

npm install cw-gantt-chart
# or
yarn add cw-gantt-chart

After installing, here's a quick example to get you started:

import { GanttChart, DataModel, ChartOptions } from 'cw-gantt-chart';

type InputProps = {
  data: DataModel[],
  options: ChartOptions,
  onClick: (id: string) => void,
};

export const Page = ({ data, options, onClick }: InputProps) => {
  return <GanttChart data={data} chartoptions={options} onClick={onClick} />;
};

Data Model

export type DataModel = {
  id: string, // Unique id to the entity
  startTime: string, // start time of the event in string TZ
  endTime: string, // end time of the event in string TZ
  startms?: number, // OPTIONAL: Staring value
  parentId?: string, // OPTIONAL: To create hierarchy
  duration: number, //Total duration of the event
  label: string, // Title or label for the entitiy
  description?: string, //OPTIONAL: Description to the entity
  color?: string, //OPTIONAL: Color code for the entity
  children?: DataModel[], //OPTIONAL: If not passed, it will be calculated by the library
  muted?: boolean, // OPTIONAL: Flag to denote if an entity is muted
  error?: boolean, //OPTIONAL: Flag to denote if an entity is in error state
};

ChartOptions

export type ChartOptions = {
  width?: number,
  height?: number,
  colorrange?: string[],
  headerColumnWidth?: number,
  background?: string,
  errorColor?: string,
  barThickness?: number,
  className?: string,
  textColor?: string,
  headerColor?: string,
  lineColor?: string,
  hideHeaderColumn?: boolean,
};
NameTypeOptional?DescriptionDefault
widthnumberOPTIONALCanvas width800px
heightnumberOPTIONALanvas height400px
colorrangestring[]OPTIONALColor range for the entities[]
headerColumnWidthnumberOPTIONALFixed header column width75px
backgroundstringOPTIONALBackground colorTransparent
errorColorstringOPTIONALColor of the error element#F26C74
barThicknessnumberOPTIONALThickness of each element10px
classNamestringOPTIONALOverride class nameNONE
textColorstringOPTIONALCanvas text colors#6A8084
headerColorstringOPTIONALHeader color#FFFFFF
lineColorstringOPTIONALAll line colors#1A363F
hideHeaderColumnnumberOPTIONALHide the header columnFALSE

Interactions

On Bar Clicked

OPTIONAL: OnClick event returns the ID of the element.

<GanttChart
  data={data}
  chartoptions={options}
  onClick={(id: string) => alert(`Clicked on ${id}`)}
/>

Playground

Gantt Chart

Screenshorts

TODO

License 📄

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.16

10 months ago

1.0.11

10 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago