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

Load .plotly or .json file for display #9

Open
gregmoille opened this issue Mar 18, 2022 · 2 comments
Open

Load .plotly or .json file for display #9

gregmoille opened this issue Mar 18, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@gregmoille
Copy link

Hi,

At the moment I believe there is only the possibility of displaying Plotly with embedded code inside the dataviewjs. Plotly allows to save a serialized version of their plot (JSON format, with .plotly) extension and was wondering if we could make it possible to load such file for display. This would simply a lot the notes I believe

something like should work I believe

function readTextFile(file, callback) {
    var rawFile = new XMLHttpRequest();
    rawFile.overrideMimeType("application/json");
    rawFile.open("GET", file, true);
    rawFile.onreadystatechange = function() {
        if (rawFile.readyState === 4 && rawFile.status == "200") {
            callback(rawFile.responseText);
        }
    }
    rawFile.send(null);
}

readTextFile("PlotlyFileSomehwere.plotly", function(text){
    var data = JSON.parse(text);
    dv.paragraph(data);
    window.renderPlotly(this.container, data)
});
@Dmytro-Shulha
Copy link
Owner

Hello!

That is correct - as of now, charts can only be created via plotly and dataviewjs code blocks.
With dataviewjs block, it is already posible to load and draw plots from any file (but I haven't tested your code yet).

I support your idea to simplify this process and I see two approaches to that:

  • by providing additional block processor (plotly-file or something)
  • by providing user a single function for loading and rendering file

Other ideas and suggestions are appreciated.

@Dmytro-Shulha
Copy link
Owner

Also, as a sidenote, I think users should have a way to define their own custom functions that they would reuse across their plotly charts. Maybe in settings menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants