Skip to main content
June 9, 2025
Solved

Google Charts Plugin

  • June 9, 2025
  • 5 replies
  • 0 views

Hi, 

I am doing some research in to the Google Chart Plugin ...

https://community.appian.com/b/appmarket/posts/google-charts-component-plug-in?CommentId=209280fe-6dcb-45e6-9bf7-81336dc6e24d

Would anyone know if an item on a chart could be stored in to a variable?

I can see there is an onSelection parameter, I am curious as to how an item from a chart could be saved down such as an ID to enable further drilldown behaviour?

Thanks.

    Best answer by harshas2775

    The onSelection parameter is storing the row and column id of the selected dataset in chart. You can try the below code to understand the behaviour of the attribute. Since its a pie chart thus column is always null. Hope it helps! 

    a!localVariables(
      local!data: {
        { Tasks: "Work", Hours: 11 },
        { Tasks: "Eat", Hours: 2 },
        { Tasks: "Commute", Hours: 2 },
        { Tasks: "Sleep", Hours: 7 },
        { Tasks: "Hobbies", Hours: 2 }
      },
      googlePieChartField(
        label: "Test",
        chartColumnData: {
          {
            type: "string",
            id: "Tasks",
            rowDataKey: "Tasks"
          },
          {
            type: "number",
            id: "Hours",
            rowDataKey: "Hours"
          }
        },
        chartRowData: { local!data },
        onSelection: {
          a!save(
            ri!var,
            index(local!data, save!value.row, {})/*save!value*/
            
          ),
          
        }
      )
    )

    5 replies

    harshas2775
    June 9, 2025

    The onSelection parameter is storing the row and column id of the selected dataset in chart. You can try the below code to understand the behaviour of the attribute. Since its a pie chart thus column is always null. Hope it helps! 

    a!localVariables(
      local!data: {
        { Tasks: "Work", Hours: 11 },
        { Tasks: "Eat", Hours: 2 },
        { Tasks: "Commute", Hours: 2 },
        { Tasks: "Sleep", Hours: 7 },
        { Tasks: "Hobbies", Hours: 2 }
      },
      googlePieChartField(
        label: "Test",
        chartColumnData: {
          {
            type: "string",
            id: "Tasks",
            rowDataKey: "Tasks"
          },
          {
            type: "number",
            id: "Hours",
            rowDataKey: "Hours"
          }
        },
        chartRowData: { local!data },
        onSelection: {
          a!save(
            ri!var,
            index(local!data, save!value.row, {})/*save!value*/
            
          ),
          
        }
      )
    )

    daiwAuthor
    June 9, 2025

    Thank you Harsha! I managed to get the taskId stored in a local varaible through indexing and saving directly in the selection variable without a!save, but as a secondary local variable. But with your code you get the full row data ... thank you so much for your help.

    daiwAuthor
    June 9, 2025

    Just one slight change, the row setup on the plugin is a zero based array, Appian starts the row count at one so is out of step. You would need to +1 the array to get the actual row.