1.0.7 • Published 9 months ago

@creowis/gantt-chart v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

@creowis/gantt-chart

An unique way of rendering gantt chart with collapsible rows

@creowis/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 @creowis/gantt-chart package using npm or yarn:

npm install @creowis/gantt-chart
# or
yarn add @creowis/gantt-chart

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

import { GanttChart, DataModel, ChartOptions } from '@creowis/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.7

9 months ago

1.0.6

9 months ago

1.0.2

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago