Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

trelli/multiple scatter plot and pie chart

Hello guys, could we create trelli pie chart? And if not, is that possible to have the code to create this with Deneb module?

I have the same question for multiple Scatter plot .


Thanks a lot,

Jim

  • I coded the facets to dynamically handle the row/column layout, so adding/removing charts within reason should not be an issue.

    Regarding my comment about adjusting those width/height/radius percentage values in deneb, I meant that one would only need to do that if they modify the visual's width and height in the formatting properties (see below screenshot). This is a limitation of faceting in vega-lite; currently the facet cell size cannot dynamically change based on the size of the canvas (yet). I cannot think of a scenario where a user could adjust the visual dimensions but would not have access to being able to update the spec in Deneb...
     

10 Replies

  • Hey Jim, this could certainly be done with Deneb. It could also be done with the native matrix and DAX generated SVGs (similar to your correlation matrix post).

    The latter would be a bit tougher to pull off, so I'd recommend going with Deneb this time. If you provide some data, I'd be happy to crank out a vega-lite spec. 

    • Anonymous's avatar
      Anonymous
      Not applicable
      TypeVoiceResult
      APower10
      AThen5
      AZeld32
      ALink8
      ANintend2
      ASega7
      BPower8
      BThen4
      BZeld6
      BLink8
      BNintend20
      BSega52
      CPower9
      CThen13
      CZeld25
      CLink2
      CNintend2
      CSega3
      DPower10
      DThen20
      DZeld54
      DLink10
      DNintend30
      DSega10
      EPower3
      EThen65
      EZeld9
      ELink24
      ENintend35
      ESega22
      FPower70
      FThen17
      FZeld21
      FLink80
      FNintend7
      FSega10
      GPower9
      GThen90
      GZeld20
      GLink20
      GNintend100
      GSega20
      HPower5
      HThen5
      HZeld120
      HLink5
      HNintend5
      HSega75
      IPower33
      IThen130
      IZeld33
      ILink1
      INintend0
      ISega0
      JPower40
      JThen11
      JZeld22
      JLink11
      JNintend50
      JSega24
      KPower3
      KThen7
      KZeld60
      KLink21
      KNintend12
      KSega22
      LPower70
      LThen10
      LZeld0
      LLink10
      LNintend20
      LSega80
      MPower30
      MThen22
      MZeld25
      MLink1
      MNintend140
      MSega19
      NPower22
      NThen27
      NZeld30
      NLink5
      NNintend30
      NSega6
      OPower22
      OThen33
      OZeld8
      OLink9
      ONintend38
      OSega31
      • giammariam's avatar
        giammariam
        Solution Sage

        Anonymous, while I personally don't love pie charts, I do like your choice of dummy data 😀.

        There's a lot that can be configured and formatted here, but I kept it simple. Let me know if you need any tweaks.

         

        You should be able to copy the spec into Deneb. You'll want to drag in the Type, Voice, and Result fields into the data pane, and remove the url and format properties under the data property in the spec.

        If this gets you going, please consider liking this reply and choosing it as the solution so others can find it. If you need additional help, just let me know. 

         

        Here's the gist

        spec: 

        {
          "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
          "data": {
            "name": "dataset",
            "url": "https://raw.githubusercontent.com/Giammaria/PublicFiles/master/pbi/pbi_community_help/trellis_pie/data/data.tsv",
            "format": {"parse": {"Result": "number"}}
          },
          "transform": [
            {"joinaggregate": [{"op": "distinct", "field": "Type", "as": "type_count"}]},
            {"joinaggregate": [{"op": "sum", "field": "Result", "as": "result_total"}], "groupby": ["Type"]},
            {"calculate": "toString(datum['Result'])+' out of '+toString(datum['result_total'])", "as": "result_out_of"},
            {"calculate": "format(datum['Result']/datum['result_total'],'.0%')", "as": "percentage"}
          ],
          "mark": {"type": "arc"},
          "encoding": {
            "facet": {
              "field": "Type",
              "type": "ordinal",
              "columns": 5,
              "sort": {"field": "Type"}
            },
            "theta": {"field": "Result", "type": "quantitative"},
            "color": {"field": "Voice", "type": "nominal"},
            "tooltip": [
              {"title": "Voice", "field": "Voice"},
              {"title": "Result", "field": "result_out_of"},
              {"title": "Result %", "field": "percentage"}
            ]
          }
        }

         

  • Hey Anonymous. I implemented some changes and have a version working in Power BI.

     

    You want to make sure that the Summarization for the Result field is set to Don't Summarize (see the below screenshot).

     

    Note - you'll need to play with the radius percentages and the spec width and height based on the size of your visual (see below screenshot)

     

    You can download a working .pbix here

    • Anonymous's avatar
      Anonymous
      Not applicable

      It's awesome. But small question: if the users are not report creators and will not be able or will not have the authorizations to modify the code in Deneb, that means that the graph risks having a bad format? It does not automatically adapt in format according to the number of sector graphs we have? It is very disturbing though....

      • giammariam's avatar
        giammariam
        Solution Sage

        I coded the facets to dynamically handle the row/column layout, so adding/removing charts within reason should not be an issue.

        Regarding my comment about adjusting those width/height/radius percentage values in deneb, I meant that one would only need to do that if they modify the visual's width and height in the formatting properties (see below screenshot). This is a limitation of faceting in vega-lite; currently the facet cell size cannot dynamically change based on the size of the canvas (yet). I cannot think of a scenario where a user could adjust the visual dimensions but would not have access to being able to update the spec in Deneb...