Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All properties should accept a function and return null should be interpreted as use the default if possible. #41

Open
lestcape opened this issue Feb 17, 2022 · 1 comment

Comments

@lestcape
Copy link

As an example of what i think should be good to have, i will provide the next timeTable definition:

timeTable: {
    renderer: [
        {
            selector: function(object, ctx) {
                return ctx.gantt.displayMode === 'showTasks';
            },
            text: function(activity, ctx) {
                var textRef = config["displayModes"][ctx.gantt.displayMode]["text"];
                return getData(activity, textRef);
            },
            textOverflow: 'noDisplay',
            background: {
                palette: function(activity, ctx) {
                    return ['#5aa8f8', '#4178bc', '#8cd211', '#c8f08f', '#ba8ff7', '#a6266e', '#ff7832'];
                },
                getValue: function(activity, ctx) {
                    var textRef = config["displayModes"][ctx.gantt.displayMode]["text"];
                    return getData(activity, textRef);
                },
            },
        },
    ]
}

In the example, return null for a palette should be interpreted as "use the default palette" instead of display an error, because this allow us to decide dynamically to use the default palette. We have not way to said "use the default palette" from a function right now.

palette: function(activity, ctx) {
    return null
},

Also for compatibility reasons the next definition should be interpreted also as "use the default palette":

palette: null

The next definition should be good to be accepted as a valid one, but right now is not working:

background: function(activity, ctx) {
    return {
        palette: function(activity, ctx) {
            return ['#5aa8f8', '#4178bc', '#8cd211', '#c8f08f', '#ba8ff7', '#a6266e', '#ff7832'];
        },
        getValue: function(activity, ctx) {
            var textRef = config["displayModes"][ctx.gantt.displayMode]["text"];
            return getData(activity, textRef);
        },
    },
},

Allow that background can be a function can simplify in some cases the code.

@delhoume
Copy link
Member

I agree it would be nice to have this implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants