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

Provide an API using composition DP to build graphs #11763

Open
denis-migdal opened this issue May 7, 2024 · 0 comments
Open

Provide an API using composition DP to build graphs #11763

denis-migdal opened this issue May 7, 2024 · 0 comments

Comments

@denis-migdal
Copy link

Feature Proposal

Hi,

I wonder if it could be possible to provide an API using composition DP to build graphs in order to improve code extensibility, reuse, and readability.

For example :

class MyCurve extends ??? {
     attach(chart) {
        chart.data.datasets.push({...});
        // ... potentially changes other options.
     }
     detach() {
        //...
     }
}

mychart.addCurve( new MyCurve() ); // call MyCurve.attach(mychart)
mychart.addAxis( new AxisLabelWhatever('x', ['Toto', 'titi']) );

Indeed, in big graphs, configurations can quickly become a big chunk, hard to read.
Providing an API using composition DP would enable to better split big chunks of configurations, and facilitate code reusing/extensibility.

This would also enable to easily move curves (or other elements) from one graph to another, e.g. for a GUI graph editor or whatever.

Possible Implementation

In a project I started (a PoC for an HTML binding of Chart.js), I use compositions DP with HTML elements :
https://github.com/denis-migdal/ChartsHTML

The JS code behind uses a composition DP, so this is a PoC for a possible implementation.

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

No branches or pull requests

1 participant