microsoft / powerbi-desktop-samples

Power BI Desktop sample files for the monthly release. Here you can find the PBIX files used in the monthly release videos.
MIT License
1.48k stars 892 forks source link

Enumeration values are not valid for labelOrientation #57

Closed somedaygone closed 1 year ago

somedaygone commented 1 year ago

When using the enumeration for labelOrientation, it yields an error.

"labelOrientation": "horizontal",
"labelOrientation": "vertical",
image

The Schema should have something like:

                          "labelOrientation": {
                            "type": "string",
                            "enum": [
                              "horizontal",
                              "vertical"
                            ],
                            "title": "Orientation"
                          },

(Not sure if your convention is caps or lower, and not sure which value is 0 and which is 1!)

somedaygone commented 1 year ago

FYI, it looks like this similar issue may apply to other properties like radiusScalingMethod, barShape, orientation, expandCollapseToggleType, and position.

Try doing a find on integer enums:

"type": "integer", "enum"

My search found 34 occurrences that need to be updated for these properties.

yelper commented 1 year ago

The error is correct, 0 and 1 are the only allowed values for label > labelOrientation. A type of "integer" and "enum" means that the values must be integers and also one of the listed values. 0 is vertical, and 1 is horizontal.

If you spot another issue, please let me know. I'll work on making this a bit more descriptive; the values of 0 and 1 are hard to discern. I'll probably end up following the convention described here, but this likely won't make it until the May Desktop release.

somedaygone commented 1 year ago

The whole point of a string enum is because 0 and 1 don't mean anything in this context. Just look at any of the other string enums and you'll see that these should be string enums too. If you can tell without looking it up, keep them as integer, but I have no clue what barShape = 0 could possibly mean. Thankfully almost every other enum is descriptive like this one:

"shadowPositionPreset":{
    "type":"string",
    "enum":[
        "custom",
        "top",
        "topLeft",
        "topRight",
        "center",
        "centerLeft",
        "centerRight",
        "bottom",
        "bottomLeft",
        "bottomRight"
    ],
    "title":"Preset"
},

At a minimum, if you could add descriptions to the schema, it would help. I can find no documentation anywhere for these enums. Maybe in the title like this?

"labelOrientation": {
    "type": "integer",
    "enum": [
        0,
        1
    ],
    "title": "Orientation. 0 is vertial, 1 is horizontal."
},

Though I'd even be happy if you could just give the meanings here for radiusScalingMethod, barShape, orientation, expandCollapseToggleType, and position. I can't find any doc anywhere that gives the values for these.

somedaygone commented 1 year ago

Sorry, just saw the link. Yes, adding a title on each integer would work. I think strings would match what is being used elsewhere, but I'm guessing that requires code changes elsewhere that won't happen for a long time. Thanks for taking this up!

yelper commented 1 year ago

I've prototyped something for the May release, it'll look something like this (have to hover over the value to get the explanation, unfortunately):

image

Schema snippet:

"labelOrientation": {
    "type": "integer",
    "oneOf": [
        {
            "const": 0,
            "title": "Vertical"
        },
        {
            "const": 1,
            "title": "Horizontal"
        }
    ],
    "title": "Orientation"
},
yelper commented 1 year ago

this shipped awhile ago, please let me know if you see any instances of numeric enums that don't have an explanation / English display name!