Comments (2)
Split a progress bar into two progress bars
from gantt-schedule-timeline-calendar.
To do this, you need to write your own progress bar plugin. Below is the code of the original progress bar for you to follow.
import type { Vido } from 'gantt-schedule-timeline-calendar';
import type DeepState from 'deep-state-observer';
export const pluginPath = 'config.plugin.ProgressBar';
export interface Options {
enabled?: boolean;
className?: string;
}
function getOptions(options: Options) {
return {
enabled: true,
className: 'gstc__chart-timeline-items-row-item-progress-bar',
...options,
};
}
class ProgressBar {
private vido: Vido;
private state: DeepState;
private options: Options;
private className: string;
constructor(options: Options, vido: Vido) {
this.options = getOptions(options);
this.vido = vido;
this.state = vido.state;
this.className = this.options.className;
this.PluginProgressBarSlot = this.PluginProgressBarSlot.bind(this);
this.destroy = this.destroy.bind(this);
this.state.update('config.slots.chart-timeline-items-row-item.inner', (slots) => {
if (!slots.includes(this.PluginProgressBarSlot)) slots.push(this.PluginProgressBarSlot);
return slots;
});
}
public destroy() {
this.state.update('config.slots.chart-timeline-items-row-item.inner', (slots) => {
return slots.filter((slot) => slot !== this.PluginProgressBarSlot);
});
this.vido.api.pluginDestroyed('ProgressBar');
}
public PluginProgressBarSlot(vido: Vido, props: any) {
let width;
const styleMap = new vido.StyleMap({ width: '0px' });
vido.onChange((newProps) => {
props = newProps;
if (!props || !props.item) {
styleMap.style.width = '0px';
return;
}
const itemData = vido.api.getItemData(props.item.id);
if (!itemData || typeof props.item.progress === 'undefined') {
styleMap.style.width = '0px';
return;
}
if (!props.item) return;
const item = props.item;
const progress = typeof item.progress === 'undefined' ? 100 : item.progress;
width = itemData.width - (itemData.width / 100) * progress;
width -= itemData.position.right - itemData.position.actualRight;
if (width < 0) width = 0;
styleMap.style.width = width + 'px';
});
return (content) =>
props && props.item && typeof props.item.progress !== 'undefined'
? this.vido.html`
<div class="${this.className}" style=${styleMap.directive()}></div>${content}
`
: null;
}
}
export function Plugin(options: Options = {}) {
return function initialize(vidoInstance: Vido) {
const currentOptions = vidoInstance.state.get(pluginPath);
if (currentOptions) {
options = vidoInstance.api.mergeDeep({}, options, currentOptions);
}
const progressBar = new ProgressBar(options, vidoInstance);
vidoInstance.api.pluginInitialized('ProgressBar');
return progressBar.destroy;
};
}
If you need to add click event or something you need to modify the template:
<div class="${this.className}" style=${styleMap.directive()} @click=${yourClickHandler(props.item)}></div>${content}
You can read lit-html template documentation.
from gantt-schedule-timeline-calendar.
Related Issues (20)
- The data I returned comes with a specific parameter, can the data border be dashed HOT 1
- Split a progress bar into two progress bars HOT 1
- Updated chart items, how to update the view HOT 3
- 3.33.16 move out stacking items not update row height HOT 11
- Scroll multiplier doesn't work with float numbers and looks laggy HOT 5
- Unhandled typeerror out of nowhere reading 'dataIndex' HOT 2
- when the start date and end date is same the progress bar is not visible HOT 5
- Connection error HOT 1
- How to scroll to position vertically in coding?
- How to change the current column width by dragging the date cell like excel?
- Issue with Rendering Component After Upgrading GSTC to Latest Version HOT 2
- How to entegrate this plugin features to my .net core mvc html page ?
- How to disable selection for scrolling by grid drag on touch devices? HOT 4
- error is here HOT 1
- How to use gantt-schedule-timeline-calendar in a redux application? HOT 2
- Time bookmarks are not rendered correctly when mounting multiple components HOT 2
- Is there a weekly view? HOT 2
- Does it support multiple languages HOT 1
- Distribution size is too big HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gantt-schedule-timeline-calendar.