rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.48k stars 101 forks source link

clog-plotly #324

Closed pierceglenn12345 closed 4 months ago

pierceglenn12345 commented 4 months ago

I am not great at understanding where/how to properly ask of this, but...

How are you getting your json code together for passing through to (clog-plotly:new-plot-plotly ...?). I have tried writing python to build a graph, then outputting json and adding to the function above like (using run-python in emacs):

import plotly.express as px import plotly as pl fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.show

=> 'data': [{'alignmentgroup': 'True', 'hovertemplate': 'x=%{x}
y=%{y}', 'legendgroup': '', 'marker': {'color': '#636efa', 'pattern': {'shape': ''}}, 'name': '', 'offsetgroup': '', 'orientation': 'v', 'showlegend': False, 'textposition': 'auto', 'type': 'bar', 'x': array(['a', 'b', 'c'], dtype=object), 'xaxis': 'x', 'y': array([1, 3, 2]), 'yaxis': 'y'}], 'layout': {'barmode': 'relative', 'legend': {'tracegroupgap': 0}, 'margin': {'t': 60}, 'template': '...', 'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'x'}}, 'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'y'}}} })>

I push this into CL as: (clog-plotly:new-plot-plotly target "[{'alignmentgroup': 'True', 'hovertemplate': 'x=%{x}
y=%{y}', 'legendgroup': '', 'marker': {'color': '#636efa', 'pattern': {'shape': ''}}, 'name': '', 'offsetgroup': '', 'orientation': 'v', 'showlegend': False, 'textposition': 'auto', 'type': 'bar', 'x': array(['a', 'b', 'c'], dtype=object), 'xaxis': 'x', 'y': array([1, 3, 2]), 'yaxis': 'y'}]" "{'barmode': 'relative', 'legend': {'tracegroupgap': 0}, 'margin': {'t': 60}, 'template': '...', 'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'x'}}, 'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'y'}}}")

This results in an empty clog-plotly "panel"?, so it isn't working. Is there a better way to go about this? I realize I am not up to speed on how plotly works, so my question is more along the lines of how one would go from having common lisp list data, to a plotly chart. Again, this is more of a workflow question about staying in common lisp land more than having to jump into python to get json made. Maybe I need to create a library for taking lisp data and, through something like cl-jonathan output json I can then push right into the two parameters for (clog-plotly:new-plot-plotly ...?). Maybe even integrate lisp-stat and dataframes? Looking for thoughts/idea's. Love the project btw.

PS - Is there an IRC channel for the project? Discord? etc?

rabbibotton commented 4 months ago

Mainly we discuss clog here in the discussion area.

https://plotly.com/javascript/ for details on what goes in to the json.

As for the json, I just paste it in

(clog-plotly::new-plot-plotly target
"[
        {
            type: 'scatter',
            x: [1, 2, 3],
            y: [3, 1, 6],
            marker: { 
                color: 'rgb(16, 32, 77)'
            }
        },
        {
            type: 'bar',
            x: [1, 2, 3],
            y: [3, 1, 6],
            name: 'bar chart example'
        }
    ]"
"{
        title: 'simple example',
        xaxis: {
            title: 'time'
        },
        annotations: [
            {
                text: 'simple annotation',
                x: 0,
                xref: 'paper',
                y: 0,
                yref: 'paper'
            }
        ]
    }")

Of course you could generate the json using various CL json packages

pierceglenn12345 commented 4 months ago

Okay. Thanks for the input. I will move over to discussions.