Giter Site home page Giter Site logo

zunnzunn / vue-ganttastic Goto Github PK

View Code? Open in Web Editor NEW
496.0 496.0 126.0 2.3 MB

Simple, interactive and highly customizable Gantt chart component for Vue 3

Home Page: https://zunnzunn.github.io/vue-ganttastic/

JavaScript 1.12% Vue 48.58% HTML 0.95% TypeScript 49.09% Shell 0.27%
gantt gantt-chart gantt-diagram project-management typescript vue vue3 vuejs

vue-ganttastic's Introduction

Vue Ganttastic

Vue Ganttastic logo

Vue Ganttastic is a simple, interactive and highly customizable Gantt chart component for Vue 3.

image

Features

  • Vue 3 support
  • TypeScript support (ships with out of the box type declarations)
  • Interactivity (dynamic, movable and pushable bars)
  • Reactivity / Responsiveness (when changes occur, bars are repositioned accordingly)
  • Customization options (chart/bar styling, slots, event handlers etc.)

Using Vue 2? Check out Vue-Ganttastic v1.

Guide and Docs

For further guides and references, check out the official docs.

Quickstart

Install using

npm install @infectoone/vue-ganttastic

Then, initalize the plugin in the starting point of your app (most likely src/main.js):

import { createApp } from "vue"
import App from "./App.vue"
...
import ganttastic from '@infectoone/vue-ganttastic'
...
createApp(App)
  .use(ganttastic)
  .mount('#app')

This will globally register the components g-gantt-chart and g-gantt-row and you will be able to use those two components right away.

<template>
  <g-gantt-chart
    chart-start="2021-07-12 12:00"
    chart-end="2021-07-14 12:00"
    precision="hour"
    bar-start="myBeginDate"
    bar-end="myEndDate"
  >
    <g-gantt-row label="My row 1" :bars="row1BarList" />
    <g-gantt-row label="My row 2" :bars="row2BarList" />
  </g-gantt-chart>
</template>

<script setup>
  import { ref } from "vue"

  const row1BarList = ref([
    {
      myBeginDate: "2021-07-13 13:00",
      myEndDate: "2021-07-13 19:00",
      ganttBarConfig: {
        // each bar must have a nested ganttBarConfig object ...
        id: "unique-id-1", // ... and a unique "id" property
        label: "Lorem ipsum dolor"
      }
    }
  ])
  const row2BarList = ref([
    {
      myBeginDate: "2021-07-13 00:00",
      myEndDate: "2021-07-14 02:00",
      ganttBarConfig: {
        id: "another-unique-id-2",
        hasHandles: true,
        label: "Hey, look at me",
        style: {
          // arbitrary CSS styling for your bar
          background: "#e09b69",
          borderRadius: "20px",
          color: "black"
        },
        class: "foo" // you can also add CSS classes to your bars!
      }
    }
  ])
</script>

Contributing

Clone the project, make some changes, test your changes out, create a pull request with a short summary of what changes you made. Contributing is warmly welcomed!

To test your changes out before creating a pull request, create a build:

npm run build

To test out the build, you should create a tarball using:

npm pack

Then, place the tarball in some other test project and install the package from the tarball by using:

npm install <name_of_the_package>.tgz

About

License MIT
Author: Marko Žunić, BSc
GitHub Repository

Support the project!

In case you found the library useful, a little tip would be much appreciated!

BTC address:
image

Screenshots

image

image

image

vue-ganttastic's People

Contributors

dependabot[bot] avatar dpschen avatar mikeveerman avatar n0ah-s avatar pedrocanoas avatar zunnzunn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-ganttastic's Issues

Tooltip location

Hi,

Thanks so much for the library!
Ganttastic is working fantastically. I just have a little problem with the tooltip which is only showing up in the top left corner of the browser.
The html element of the tooltip, with the g-gantt-tooltip class is being placed outside of the #app, as a direct child of <body>, is that maybe the issue?

Also, I'm trying to customize the tooltip I can't seem to change it and the g-gantt-chart has the attribute bar-tooltip="[object Object]" with my GanttBarObject :

{
  "bar":{
        "myBeginDate": "2021-08-24 18:00",
        "myEndDate": "2021-08-31 23:00",
        "label": "MY TOOL TIIIP",
        ganttBarConfig: {style: {color:"red", height: "9vh", background: "#404040", opacity: 0.5, immobile: true}}
    }
}

Thanks again!!

Showing month/day time axis instead of day/time

Screenshot 2021-05-20 at 14 48 49
I mean to make changes here. I'm looking how this package could fit my project and I need to show 1 year timeline with months/days as time axis. Maybe this is already possible by changing some settings?

Docs not work

online docs not work FYI

BR

app.d4b712af.js:1 TypeError: Cannot read properties of null (reading 'parentNode')
at remove (app.d4b712af.js:1:57258)
at Object.remove (app.d4b712af.js:1:50036)
at he (app.d4b712af.js:1:47160)
at A (app.d4b712af.js:1:47777)
at he (app.d4b712af.js:1:47048)
at q (app.d4b712af.js:1:48013)
at he (app.d4b712af.js:1:47206)
at A (app.d4b712af.js:1:47777)
at he (app.d4b712af.js:1:47048)
at q (app.d4b712af.js:1:48013)
xc @ app.d4b712af.js:1

e.add(...).isSameOrAfter is not a function

Uncaught (in promise) TypeError: e.add(...).isSameOrAfter is not a function

I've been struggling for weeks with this error. Can't figure out what's causing it. It worked fine before I migrated from barebones Vue 3 to Nuxt 3, but I don't see how that changes anything.

Thankful for any assistance.

Generate new rows

Is it possible to generate new rows dynamically? I've been trying to put all the rows inside the same object using rowBarList as an array of arrays and v-for, it works except the no-overlap property so I can place a bar over another one.

So this code doesn't work:

<g-gantt-row v-for="(rowBar, idx) in rowBarList" :key="idx" label="" :bars="rowBar.bars"></g-gantt-row>

but if I do like this it works:

<g-gantt-row label="" :bars="rowBarList[0].bars"></g-gantt-row>
<g-gantt-row label="" :bars="rowBarList[1].bars"></g-gantt-row>

Do you have any idea? Thanks in advance.

Using vue-ganttastic without moment.js?

Moment js is quite a heavy dependency which I'd like to avoid if possible. I'm wondering how big of a change to the library would be required to make it work without moment js?

If this is something that would be accepted, I'll try to send a PR.

[Bug] upper timeunit error

image

I got time unit header but missing the April.

:chart-start="'2020-03-01 12:00'"
:chart-end="'2020-04-30 12:00'"

locale file missing

When I compile I receive this warning:
Module not found: Error: Can't resolve './locale' in '/Path/to/node_modules/node_modules/vue-ganttastic/dist'
on line 1908 you have this function which requires a locale directory:
function loadLocale(name) { var oldLocale = null; // TODO: Find a better way to register and load all the locales in Node if (!locales[name] && (typeof module !== 'undefined') && module && module.exports) { try { oldLocale = globalLocale._abbr; var aliasedRequire = require; aliasedRequire('./locale/' + name); getSetGlobalLocale(oldLocale); } catch (e) {} } return locales[name]; }

onDragstartBar and onDragendBar events don't work properly

I tried using the movedBars property on the onDragendBar event, however i am not able to since i doesn't actually have the oldStart and oldEnd properties, i have no idea why. To counter this I tried using the onDragstartBar event to save the current state of the GanttChart, however this event doesn't even trigger.
"vue": "^2.6.11",
"vue-ganttastic": "^0.9.32",

TypeError: selfHook.bind is not a function

Hello! I'm pretty new at all this coding thing
I don't know if I'm stupid or or something but I get this error:
I have installed both moment and vue-ganttastic. I have tried to import it in the component and also globally in main.js like this:
main.js

import { createApp } from 'vue' import App from './App.vue' import router from './router' import store from './store' import {GGanttChart, GGanttRow} from 'vue-ganttastic' createApp(App).use(store).use(router).use(GGanttChart).use(GGanttRow).mount('#app')

This is the error in my console:

Uncaught (in promise) TypeError: selfHook.bind is not a function at callSyncHook (runtime-core.esm-bundler.js?5c40:5710) at applyOptions (runtime-core.esm-bundler.js?5c40:5491) at finishComponentSetup (runtime-core.esm-bundler.js?5c40:6309) at setupStatefulComponent (runtime-core.esm-bundler.js?5c40:6245) at setupComponent (runtime-core.esm-bundler.js?5c40:6185) at mountComponent (runtime-core.esm-bundler.js?5c40:3960) at processComponent (runtime-core.esm-bundler.js?5c40:3936) at patch (runtime-core.esm-bundler.js?5c40:3547) at mountChildren (runtime-core.esm-bundler.js?5c40:3736) at mountElement (runtime-core.esm-bundler.js?5c40:3659)

Provide components in the release bundle to allow async loading of a chart

Currently the only supported method of importing the gantt chart components is via app.use(ganttastic). This works but puts the gantt chart components in the final bundle for everyone, bloating the size slightly. It would be great if I could import the components individually like it is done in https://github.com/InfectoOne/vue-ganttastic/blob/474a4fdf4040fd07f7d3b800b129742445ab8721/src/index.ts#L3-L14. Right now that does not work because the release downloaded from npm only contains one bundle with everything and no exports.

Assigning class to g-gantt-bar

Using the command bar.ganttBarConfig.style.background = "#7410ff" I can set the color of a bar when clicked, however I want to control this using a class.
I cannot see the in docs how to assign a class to the div g-gantt-bar
Is class assignment possible?

Build errors with dayjs imports

I am getting the following type of error for each of the dayjs imports at the top of node_modules/@infectoone/vue-ganttastic/dist/library.mjs when npm builds:

ERROR in ./node_modules/@infectoone/vue-ganttastic/dist/library.mjs 3:0-55
Module not found: Error: Can't resolve 'dayjs/plugin/isSameOrAfter' in '{local path}/node_modules/@infectoone/vue-ganttastic/dist'
Did you mean 'isSameOrAfter.js'?
BREAKING CHANGE: The request 'dayjs/plugin/isSameOrAfter' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

A numbers of google searches have led me to add

module: {
    rules: [{
        test: /\.m?js/,
        resolve: {
            fullySpecified: false,
        }
    }]
}

to my webpack.config.js file, but that did not solve the problem.

I'm currently on version 3.2.31 of Vue, and 2.0.2 of vue-ganttastic.

Website is not working

I, i'm looking for a gantt chart plugin for vue.

While i was trying to see if vue-ganttastic was a match for my app, i encountered numberless issues on the website.

Can't navigate between page, lots of errors in the console.

I'm using brave in fedora 37.

Cheers

Bars and Labels not appearing on first load.

Hello,

I have created a very simple gantt chart, and this library seems to show some great promise.

I am creating an application using the Vuetify.js framework, and I can insert the Gantt chart component well enough. For some reason on load, the axes render correctly, but none of the bars themselves actually render.

Screenshot 2022-02-09 at 16 48 04

If I right click on the page, and select Inspect (Using Chrome 98.0.4758.80) the developer tools pop up and suddenly the missing bars and labels render!

Screenshot 2022-02-09 at 16 48 24

There's some feedback in the console which isn't particularly intuitive:
Screenshot 2022-02-09 at 16 48 38

Am I missing something obvious...?

html code for the component:

<g-gantt-chart :chart-start="myChartStart" :chart-end="myChartEnd">
    <g-gantt-row
         v-for="row in rows"
         :key="row.label"
         :label="row.label"
         :bars="row.bars"
         bar-start="myStart"
         bar-end="myEnd"
    >
        <template #bar-label="{bar}">
            <span>{{bar.label}}</span>
        </template>
    </g-gantt-row>
</g-gantt-chart>

And the script:

import { GGanttChart, GGanttRow } from 'vue-ganttastic'
...
data () {
    return {
      myChartStart: '2022-02-16 09:00',
      myChartEnd: '2022-02-18 18:00',
      rows: [
        {
          label: 'Eloise',
          bars: [
            {
              myStart: '2022-02-16 09:00',
              myEnd: '2022-02-16 14:37',
              label: 'R#5566',
              ganttBarConfig: { color: 'white', backgroundColor: '#404040', opacity: 0.5, immobile: true }
            }
          ]

        },
        {
          label: 'John',
          bars: [
            {
              myStart: '2022-02-17 09:00',
              myEnd: '2022-02-17 18:00',
              label: 'R#6744',
              ganttBarConfig: { color: 'white' }
            },
            {
              myStart: '2022-02-18 09:00',
              myEnd: '2022-02-18 14:15',
              label: 'R#6798',
              ganttBarConfig: { color: 'white', handles: true }
            }
          ]
        }
      ],
      ...

Slots not working

Are there examples for how to use the slot components? I am trying to change the bar-tooltip and my code isn't working.

Dragging bars does not seem to work

I'm currently trying to include ganttastic in an existing application. I'm using it something like this:

		<g-gantt-chart
			:chart-start="dateFrom.toString()"
			:chart-end="dateTo.toString()"
			:push-on-overlap="true"
			row-label-width="0"
			:grid="true"
			@dragend-bar="dragged($event)"
		>
			<g-gantt-row
				v-for="(t, k) in theTasks"
				:key="t ? t.id : 'k'+k"
				:label="t.title"
				bar-start="start"
				bar-end="end"
				:bars="[{
					start: t.startDate.toString(),
					end: t.endDate.toString(),
					label: t.title,
					ganttBarConfig: {
						color: colorIsDark(t.getHexColor()) ? 'black' : 'white',
						backgroundColor: t.getHexColor(),
						handles: true,
					}
				}]"
				:highlight-on-hover="true"
			>
			</g-gantt-row>
		</g-gantt-chart>

dateTo and dateFrom are global props with a data object of the range, theTasks is an array of task objects from the app.

The tasks are shown as bars in the application, yet I can't drag them around or resize them.

EDIT: I've added an event listener for @dragend-bar and it looks like the bar is moved, the change is just not reflected in the gantt chart. I guess I need to manually update the bar object to contain the new dates after dragging them?

Error is loaging

Uncaught TypeError: Object(...) is not a function
at eval (library.mjs?fb0a:261:1)
at Module../node_modules/@infectoone/vue-ganttastic/dist/library.mjs

var _hoisted_1$3 = { class: "g-timeaxis" };
var _hoisted_2$1 = { class: "g-timeunits-container" };
var _hoisted_3$1 = { class: "g-timeunits-container" };
ROW 261 var script$5 = /#PURE/ defineComponent({
props: {
chartStart: { type: String, required: true },
chartEnd: { type: String, required: true },
precision: { type: String, required: true },
colors: { type: null, required: true }
},

Drag limit

I'm trying to introduce limits for each bar, i'm doing so by adding a 'dragLimitRight' and 'dragLimitLeft' to the 'ganttBarConfig' of each bar, however this does nothing, am i missing something?

Displaying more than a week causes hours to disappear

https://github.com/InfectoOne/vue-ganttastic/blob/8e76a5974f90b8861a48219494bcd13b52003ba7/src/GGanttTimeaxis.vue#L87

Inside GGanttTimeAxis, on line 87 a turnary statement using moment.day() sets paramters for the GanttHours creating forloop to 0,-1 when using a timespan of 8 days or more

day() should be replaced with something more broad, like dayOfYear()

(Parameters for this occur are when setting this, or a relatively later chartEnd:
myChartStart: "2020-03-02 00:00",
myChartEnd: "2020-03-09 00:00",
)

PS:
(using the following prevents it, because end and start day dont overlap:
myChartStart: "2020-03-02 00:00",
myChartEnd: "2020-03-08 23:059",
)

Cannot drag: TransitionGroup children must be keyed

I looked at the code, but I'm not sure why no examples refer to id'ing specific bar inside rows. What is the best way to fix this?

packages.json version: "@infectoone/vue-ganttastic": "^2.0.2",

Warning message:

[Vue warn]: <TransitionGroup> children must be keyed. 
  at <TransitionGroup name="bar-transition" tag="div" > 
  at <GGanttRow key=1 label="Kevin" bars= 
Array [ {…} ]
  ... > 
  at <GGanttChart chart-start="2022-02-28 05:00" chart-end="2022-02-28 22:00" precision="hour"  ... > 

Template:

<template>
	<g-gantt-chart
		:chart-start="ganttStart"
		:chart-end="ganttEnd"
		precision="hour"
		:highlighted-hours="true"
		bar-start="myStart"
		bar-end="myEnd"
		@dragend-bar="onDragendBar($event)"
	>
		<g-gantt-row
			v-for="row in ganttRows.values"
			:key="row.id"
			:label="row.label"
			:bars="row.barList"
			:highlight-on-hover="true"
		>
			<template #bar-label="{ bar }">
				<span>{{ bar.label }}</span>
			</template>
		</g-gantt-row>
	</g-gantt-chart>
</template>

Script:

<script setup>
const pplStatic = [
	{ id: 1, name: "Kevin" },
	{ id: 2, name: "Jonny" },
]

function onDragendBar(ev){
	console.info(ev)
}

const ganttStart = ref("2022-02-28 05:00");
const ganttEnd = ref("2022-02-28 22:00");
const ganttRows = reactive(
	{
		values: [
		]
	}
)
// Testing
function GanttAddBlankEmp() {

	pplStatic.forEach(element => {
		ganttRows.values.push({
				id: element.id,
				label: element.name,
				barList: [
					{
						myStart: "2022-02-28 09:00",
						myEnd: "2022-02-28 18:00",
						// image: "vue_ganttastic_logo_no_text.png",
						label: "",
						ganttBarConfig: { color: "white", backgroundColor: "#de3b26", bundle: "redBundle" }
					}
				]
			})
	});
}
GanttAddBlankEmp()
</script>

Cannot find module '@infectoone/vue-ganttastic' or its corresponding type declarations.

Hi, I get the following error when importing.
My project uses the latest version of Vue 3.2.31
But unfortunately, this error always comes.
What am I doing wrong?

ERROR in src/main.ts:3:24
TS2307: Cannot find module '@infectoone/vue-ganttastic' or its corresponding type declarations.
1 | import {createApp} from 'vue'
2 | import App from './App.vue'

3 | import ganttastic from '@infectoone/vue-ganttastic';

Change format of secondary time axis

I have tried setting a time unit slot but it doesn't seem to have an effect. What is required in the label and value parts. Could this be added to the documentation please?

@click-bar

It would be nice to have click event so I can see additional data related to the bar object

Cannot integrate with Vue3

I've tried using the component with a Vue3 project setup but I get this error every time:

Uncaught TypeError: selfHook.bind is not a function
    at callHookWithMixinAndExtends (runtime-core.esm-bundler.js?5c40:6032)
    at callSyncHook (runtime-core.esm-bundler.js?5c40:6018)
    at applyOptions (runtime-core.esm-bundler.js?5c40:5777)
    at finishComponentSetup (runtime-core.esm-bundler.js?5c40:6636)
    at setupStatefulComponent (runtime-core.esm-bundler.js?5c40:6567)
    at setupComponent (runtime-core.esm-bundler.js?5c40:6503)
    at mountComponent (runtime-core.esm-bundler.js?5c40:4206)
    at processComponent (runtime-core.esm-bundler.js?5c40:4182)
    at patch (runtime-core.esm-bundler.js?5c40:3791)
    at mountChildren (runtime-core.esm-bundler.js?5c40:3975)

I've copied the boilerplate template and code in the github readme.

Consider dayjs

Dayjs is much lighter than moment and has similar features and api

Nested Rows

Hi.
is there a way to put nested rows in vue-ganttastic? I didn't find in the documentation.

Missing days in header when using the gantt chart with a lot of days

The gantt chart header looks like this for the range in the screenshot: Screenshot_20210520_174435

(The date inputs come from my application)

I'm guessing the days are not shown in the header because there are simply too many which lets them overflow. A previous version of my (very buggy) gantt chart looked like this:
image

I'd like to implement something similar with this library.

Would you accept a PR to add slots to make these things configurable?

Support for multiple bars within a row?

Hi,

Instead of having bar simply overlapping each other, is it possible to have multiple rows within a GGantRow? I think it is easier to explain with a picture below.
Screenshot 2022-10-21 at 01 23 40

Is something like this possible with vue-ganttastic? If not, it would be a very useful feature.

Vue-Ganttastic 2.0 (Vue 3 release) - Announcement

Vue-Ganttastic 2.0

image
Hello everybody! A little heads-up: Vue-Ganttastic v2.0 is in its final development phase. All functionalities of the previous version have already been implemented, as well as some new features. The focus right now is on thorough testing and preparations for shipping as npm package. A yarn package is planned too.

What's new in Vue-Ganttastic 2 ?

Below is a non-exhaustive list of new features, which have already been implemented. Various improvements and additional features are planned for upcoming minor releases.

  • Vue 3 and Typescript support
  • improved implementation using Typescript and powerful features provided by Vue 3 (e.g. Composition API)
  • now using Day.js as the underlying library for date-time manipulation
  • new precision prop for specifying the displayed time units in the time axis. This enables you to properly display the time axis for wider time ranges (e.g. multiple months)
  • slots for customizing how the time units in the time axis are displayed
  • minor improvements of the appearance of row labels

The alpha version is already available as a npm package. For more details, please refer to the README in this branch.

Estimated release date: December 2021 / January 2022

Supporting mobile touch event

First of all, thank you for your wonderful library :)

Wondering if you are planning to support mobile touch event. After a quick look at the code, it seems that the code is already well modularised. The work required would be changing all mouse event drag and drop to something that supports both mobile and desktop. Hovering is not such a big problem in this case.

It seems that the required work could be done with ease by utilising library like vue3-touch-events.

What are your thoughts?

Problem with docs

the online documentation is not working, i've tried to run your project online, but it seems non possible to run docs:dev because i get this error

2:33:19 [vite] Internal server error: Failed to resolve import "@vuepress/client/app" from "docs/.vuepress/.temp/vite-root/index.html?html-proxy&index=0.js". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/mino/Documents/opensource/vue-ganttastic/docs/.vuepress/.temp/vite-root/index.html?html-proxy&index=0.js
  1  |  
  2  |  import '@vuepress/client/app'

the problem of online documentation, i think is connected to

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.