frappe / gantt

Open Source Javascript Gantt
https://frappe.io/gantt
MIT License
4.67k stars 1.04k forks source link

Is it possible to set chart colors? #33

Closed jalle007 closed 6 years ago

jalle007 commented 6 years ago

Please, this is fundamental requirements

jalle007 commented 6 years ago

@netchampfaris

can you please help me to setup basic chart like this image

netchampfaris commented 6 years ago

You can add a class to your gantt bar using the custom_class property, and style it using css.

ElijahSink commented 5 years ago

I had to add this to frappe-gantt.js:

draw_bar() {
    this.$bar = createSVG('rect', {
         x: this.x,
         y: this.y,
         width: this.width,
         height: this.height,
         rx: this.corner_radius,
         ry: this.corner_radius,
         class: 'bar' + this.task.custom_class, //added ' + this.task.custom_class'
         append_to: this.bar_group
         });

    animateSVG(this.$bar, 'width', 0, this.width);

    if (this.invalid) {
        this.$bar.classList.add('bar-invalid');
        }
}
ElyGallego commented 4 years ago

I know this is an old issue, but I wanted to share my solution since I couldn't find it anywhere:

let tasks = { id: 1, custom_class: 'cc-red' ... }

// your css file .cc-red g rect { fill: red !important; }