-
-
Notifications
You must be signed in to change notification settings - Fork 78
Set global defaults that apply to all graphs within a project #152
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
Comments
Hello, @bluppfisk . Unfortunately, there isn't a way to do this as the code is. What I can recomend, as a quick fix, is creating a service which you can get the default. E.g.: @Injectable
export class DefaultLayoutService {
private defaultLayoutObject = { /* the default data */ };
public getDefaultLayoutObject(layout: object): object {
return Object.assign({}, this.defaultLayoutObject, layout);
}
} then use it in the controller @Component()
export class MyComponent {
public layout: object = {};
constructor(public layoutService: DefaultLayoutService) {
this.layout = layoutService.getDefaultLayoutObject({ /* data which will overwrite the default */});
}
} |
Now, regarding the "global defaults". Do you have an idea in how it could be implemented? Like, declaring a theme globally? |
Thanks for the quick response. I'm no expert on Plotly nor Angular, and it's a little opaque to me as to how the angular wrapper for plotly works, but maybe this works: Wherever you import the module, you could provide some defaults. In Python, Plotly is retrieved through the PlotlyService. I don't know if something like this happens at all under the hood, but the PlotlyService sounds like a good point to set global configs. Is that something? |
I know in other languages (i.e.: python) there are themes: https://plotly.com/python/templates/ |
is this resolved? |
Not as far as I know; I still use the service to get an object with the default config. It's a workaround but it works. |
Is it possible to set global defaults, e.g. the default
layout.colorway
property so that every graph I instantiate in a project obeys that setting? I can't seem to find how to do this.The text was updated successfully, but these errors were encountered: