dash-canvas icon indicating copy to clipboard operation
dash-canvas copied to clipboard

I am getting error Invalid argument `data[0].pathOffset` passed into DataTable with ID "canvaas-table". Expected one of type [string, number, boolean].

Open muntakim1 opened this issue 7 months ago • 0 comments

Hello,

error Invalid argument `data[0].pathOffset` passed into DataTable with ID "canvaas-table". Expected one of type [string, number, boolean].

While running the code:

from dash import Dash, html, dash_table, Input, Output, callback
from dash.exceptions import PreventUpdate
from dash_canvas import DashCanvas
import json

app = Dash(__name__)

filename = 'https://raw.githubusercontent.com/plotly/datasets/master/mitochondria.jpg'
canvas_width = 500

columns = ['type', 'width', 'height', 'scaleX', 'strokeWidth', 'path']

app.layout = html.Div([
    html.H6('Draw on image and press Save to show annotations geometry'),
    DashCanvas(id='annot-canvas',
               lineWidth=5,
               filename=filename,
               width=canvas_width,
               ),
    dash_table.DataTable(id='canvaas-table',
              style_cell={'textAlign': 'left'},
              columns=[{"name": i, "id": i} for i in columns]),
    ])


@callback(Output('canvaas-table', 'data'),
              Input('annot-canvas', 'json_data'))
def update_data(string):
    if string:
        data = json.loads(string)
    else:
        raise PreventUpdate
    return data['objects'][1:]


if __name__ == '__main__':
    app.run(debug=True)

muntakim1 avatar Jul 17 '24 05:07 muntakim1