npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dhtmlx/trial-svelte-gantt

v1.1.2

Published

- Online demo: https://dhtmlx.com/svelte/demos/gantt/#/base/default - Code of demos: https://github.com/web-widgets/svelte-gantt-demos - Minimal project: https://svelte.dev/repl/f2f23aea85094858a36d3c1712282dfc

Downloads

1,321

Readme

Svelte Gantt Demos

  • Online demo: https://dhtmlx.com/svelte/demos/gantt/#/base/default
  • Code of demos: https://github.com/web-widgets/svelte-gantt-demos
  • Minimal project: https://svelte.dev/repl/f2f23aea85094858a36d3c1712282dfc

Supported functionality

Common with DHTMLX Gantt

  • adding/editing/deleting tasks and links
  • tasks, projects and milestones
  • configurable scales and grids
  • configurable tooltips
  • time markers

Unique features

  • svelte widgets can be used for tasks rendering, tooltips and form controls
  • all configuration properties are reactive
  • full svelte sources are provided

Usage

Installation

  • add library to your svelte project
npm install @dhtmlx/trial-svelte-gantt

This will install trial version, for commercial one, use "@dhx/svelte-gantt"

  • place Gantt tag into the desired page
import { Gantt, DefaultTheme } from "@dhtmlx/trial-svelte-gantt";

export default function GanttBasic() {
	return (
		<DefaultTheme>
			<Gantt />
		</DefaultTheme>
	);
}

You can check the demo of mininal project here - https://svelte.dev/repl/f2f23aea85094858a36d3c1712282dfc

Source code of the gantt can be checked in node_modules/@dhtmlx/trial-svelte-gantt/src

Themes

Package contains two predefined themes - Default and Material.

You can apply theme by wrapping Gantt into DefaultTheme or MaterialTheme tags

<div>
	<DefaultTheme>
		<Gantt />
	</DefaultTheme>
	<MaterialTheme>
		<Gantt />
	</MaterialTheme>
</div>

or you can just add theme tag on the page and add skin class to one of Gantt's parent tags

<div>
	<DefaultTheme />
	<MaterialTheme />

	<div class="wx-default">
		<Gantt />
	</div>
	<div class="wx-material">
		<Gantt />
	</div>
</div>

Initialization

You can define scales/columns/tasks/links during Gantt initialization

<Gantt {scales} {columns} {tasks} {links} />

where data may look like next

const scales = [
	{ unit: "month", step: 1, format: "MMMM yyy" },
	{ unit: "day", step: 1, format: "d" },
];

const columns = [
	{ name: "text", label: "Task name", width: "100%" },
	{ name: "start", label: "Start time", align: "center" },
	{ name: "duration", label: "Duration", width: "70px", align: "center" },
	{ name: "add-task", label: "", width: "50px", align: "center" },
];

const tasks = [
	{
		id: 1,
		open: true,
		start_date: "2020-11-06",
		duration: 8,
		text: "svelte Gantt Widget",
		progress: 60,
		type: "project",
	},
	{
		id: 2,
		parent: 1,
		start_date: "2020-11-06",
		duration: 4,
		text: "Lib-Gantt",
		progress: 80,
	},
];

const links = [{ source: 2, target: 1, type: 0 }];

Integration with backend

Check https://github.com/web-widgets/svelte-gantt-demos/blob/master/src/GanttBackend.svelte

Code defines the action handler through save event. This event will be triggered on any update and may be used to save changes to the persistent storage.

In the above example, the RestDataProvider is used https://github.com/web-widgets/gantt-data-provider/blob/master/src/providers/rest.ts You are not limited to this solution, though, and can extend the provided class or define a custom handler.

We provide 2 demo backends, with nodejs and go

  • https://github.com/web-widgets/gantt-go
  • https://github.com/web-widgets/gantt-node

again, you are not limited to this solution. The above RestDataProvider can work with any REST like service and you can implement a fully custom solution ( sockets, graphql, etc. ) through custom save event.

Templates

The next elements can be customized through templates

  • task text
  • sidebar form

check https://github.com/web-widgets/svelte-gantt-demos/blob/master/src/GanttText.svelte

  • tooltip content

check https://github.com/web-widgets/svelte-gantt-demos/blob/master/src/GanttTooltips.svelte

API

Properties

// templates for different elements of gantt
let templates = {};
// array of markers
let markers = [];
// supported task types
let taskTypes = ["task", "project", "milestone"];
// tasks data
let tasks = [];
// links data
let links = [];
// time scales configuration
let scales = [
	{ unit: "month", step: 1, format: "MMMM yyy" },
	{ unit: "day", step: 1, format: "d" },
];
// grid configuration
let columns = [
	{ name: "text", label: "Task name", width: "100%" },
	{ name: "add-task", label: "", width: "50px", align: "center" },
];
// time scale start
let start = null;
// time scale end
let end = null;
// width of scale cell
let cellWidth = 100;
// height of chart bar
let cellHeight = 38;
// height of scale cell
let scaleHeight = 30;
// readonly mode flag
let readonly = false;
// show or hide grid
let grid = true;
// show or hide tooltips
let tooltip = null;
// show or hide borders in the chart area
let borders = "full";

Events

// will be called on any action in the Gantt
let actions = null;
// will be called on any data modification in the Gantt
let save = null;

Actions

Data modifications ( both action and save events )

  • add-link
  • update-link
  • delete-link
  • add-task
  • update-task
  • delete-task

UI State ( action event )

  • data-request
  • hide-details
  • move-task
  • scroll-chart
  • select-task
  • show-details
  • task-toggle
  • update-task-time

Example of event usage

function handler({ action, obj, id }) {
	if (action === "select-task") console.log(`Task ${id} was selected`);
}

<Gantt on:action={handler} />;

Methods

let store;

<Gantt bind:store />;

and now you can use store's API to get or modify data.

interface IStore {
	getTask(id: number): GanttItemData;
	updateTask(id: number, obj: any, noSave: boolean): void;
	updateLink(id: number, obj: any, noSave: boolean): void;
	action(
		id: number,
		action: string,
		obj: StringHash<any>,
		noSave?: boolean
	): number;
}

action method can be used to trigger any of above actions

store.action(taskId, "tasks-toggle");
store.action(linkId, "delete-link");
store.action(null, "add-link", { source: 1, target 2, type: 0 });