Skip to content

TreatAs pie3 broken (at least in R2024b) #525

@Rolf-MP

Description

@Rolf-MP
    pie3([1, 2, 3], [1, 0, 0])
   p = plotlyfig(myfigure, "offline", false, 'TreatAs', 'pie3')

Throws error

Dynamic field or property name must be a string scalar or character vector.

Error in setfield (line 14)
    s.(deblank(strField)) = varargin{end};    
    ^^^^^^^^^^^^^^^^^^^^^
Error in updatePie3 (line 38)
    obj.layout = setfield(obj.layout,['scene' ...
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in updateData (line 6)
        updatePie3(obj, dataIndex);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in plotlyfig/update (line 625)
                updateData(obj,n);
                ^^^^^^^^^^^^^^^^^
Error in plotlyfig (line 148)
                obj.update;
                ^^^^^^^^^^

This is caused by concatenation of a 'char array' and a "string" resulting in a 1x2 string array instead of a single string of a char array.

In plotly_matlab\plotly\plotlyfig_aux\handlegraphics\updatePie3.m

    %-update scene-%
    obj.layout = setfield(obj.layout,['scene' ...
            obj.PlotOptions.scene_anchor(end)], obj.PlotOptions.scene);
    obj.data{plotIndex}.scene = obj.PlotOptions.scene_anchor;
    obj.data{plotIndex}.legendgroup = obj.PlotOptions.scene_anchor;

It seems it should read something like the below which concatenates two "string"s and also allows for multi digit scenes:

    %-update scene-%
    obj.layout = setfield(obj.layout, "scene" + ...
        regexp(obj.PlotOptions.scene_anchor, "\d+$", "match"), ...
        obj.PlotOptions.scene);
    obj.data{plotIndex}.scene = obj.PlotOptions.scene_anchor;
    obj.data{plotIndex}.legendgroup = obj.PlotOptions.scene_anchor;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions