m-kovalsky / Tabular

Useful code for tabular modeling and automation.
MIT License
156 stars 61 forks source link

ExportReportObjets.cs: VisualObjects missing elements #13

Open ImkeF opened 2 years ago

ImkeF commented 2 years ago

It looks as if from the non-Standard VisualObjects only the "Label" makes it into the final txt file. All other elements (starting from row 682) don't make it into the final file.

And: For the vcObjects, the extraction path is not correct. The field "FillRule" doesn't exist any more and can simply be deleted. However, even after that fix, those objects won't make it into the txt currently.

ImkeF commented 2 years ago

Update: It's not an issue of making it into the file, but of being extracted. As all these fields are conditional formats now, the parsing has to be adjusted to the different cases and their attributes.

ImkeF commented 2 years ago

So the issue is with color-based attributes who depend on conditional formatting like Labes for example. Each conditional formatting format style requires a different parsing of the measure. The following code works, but I'm not sure if this is the best way, as I don't speak C#.

` // VisualObjects in Labels try { string sc = "Label - Color - Gradient"; foreach (var o2 in configJson["singleVisual"]["objects"]["labels"].Children()) { // labels string tableName = (string)o2["properties"]["color"]["solid"]["color"]["expr"]["FillRule"]["Input"]["Measure"]["Expression"]["SourceRef"]["Entity"]; string objectName = (string)o2["properties"]["color"]["solid"]["color"]["expr"]["FillRule"]["Input"]["Measure"]["Property"]; string objectType = "Measure";

                VisualObjects.Add(new VisualObject {PageName = pageName, VisualId = visualId, VisualType = visualType, CustomVisualFlag = customVisualFlag, ObjectName = objectName, TableName = tableName, ObjectType = objectType, Source = sc});
            }}
            catch {}
            try
            {
            string sc = "Label - Color - FieldValue";
            foreach (var o2 in configJson["singleVisual"]["objects"]["labels"].Children())
                       {
                // labels
                string tableName = (string)o2["properties"]["color"]["solid"]["color"]["expr"]["Measure"]["Expression"]["SourceRef"]["Entity"];
                string objectName = (string)o2["properties"]["color"]["solid"]["color"]["expr"]["Measure"]["Property"];
                string objectType = "Measure";

                VisualObjects.Add(new VisualObject {PageName = pageName, VisualId = visualId, VisualType = visualType, CustomVisualFlag = customVisualFlag, ObjectName = objectName, TableName = tableName, ObjectType = objectType, Source = sc});
            }}
            catch{}    
            try
            {
            string sc = "Label - Color - Rules";
            foreach (var o2 in configJson["singleVisual"]["objects"]["labels"].Children())
            {
                // labels
                string tableName = (string)o2["properties"]["color"]["solid"]["color"]["expr"]["Conditional"]["Cases"][0]["Condition"]["Comparison"]["Left"]["Measure"]["Expression"]["SourceRef"]["Entity"];
                string objectName = (string)o2["properties"]["color"]["solid"]["color"]["expr"]["Conditional"]["Cases"][0]["Condition"]["Comparison"]["Left"]["Measure"]["Property"];
                string objectType = "Measure";

                VisualObjects.Add(new VisualObject {PageName = pageName, VisualId = visualId, VisualType = visualType, CustomVisualFlag = customVisualFlag, ObjectName = objectName, TableName = tableName, ObjectType = objectType, Source = sc});
            }}
                catch{}`

... also sorry for the messy code - I have no idea why the formatting isn't working.

m-kovalsky commented 2 years ago

Hi, thanks for your feedback. Try version 1.5.2

ImkeF commented 2 years ago

Hi Michael, adjustments in the dedicated conditional formatting fit, but there is more: All color attributes in other visual elements are now conditional as well and would have to be adjusted accordingly. If you search for "solid" you will find them like in row 839 (for "Label"), 856 (for "Category Labels") and so on.

m-kovalsky commented 2 years ago

Would you show an example (screenshot of the format pane) of the exact formatting to what you are referring? Thanks

ImkeF commented 2 years ago

Sure: Formatting the background here by a measure called "SecBackgroundColor", but it won't be picked up in the VisualObjects list. Sharing the test file as well (visual is on page "Decomp Tree"): https://thebiccountant-my.sharepoint.com/:u:/g/personal/imke_thebiccountant_onmicrosoft_com/EWTBXBXFk19Ik8rGU08WeCgBXtb-TGx-WBAF891f5QiRfg?e=ofE4fW

image

m-kovalsky commented 2 years ago

Thanks - that helped a lot!. See 1.5.3. This should not only fix the background issue but also borders & shadows (within 'Effects').

ImkeF commented 2 years ago

Thanks, yes, these occurrences are being picked up now!

If you are up to pick further measure occurrences, I could give you a list of more items that haven't been picked up yet (like colors in Data- and Category labels, legends, titles for example). Just let me know please.

Also, used measures in the smart narratives (and text visuals) are not picked up. Structure of these visual seems fairly complicated.

m-kovalsky commented 2 years ago

Try 1.5.4. I looked for all the formatting options and hopefully this covers them all. Smart narratives are fundamentally just text visuals so all the formatting options for text visuals (which I believe are now covered) should be covered for smart narratives as well. Let me know if you find anything else which is missing. Thanks!

DaniilMaslyuk commented 2 years ago

The issue seems to have returned? Please see #14 for details