Google Charts Plugin

Certified Lead Developer

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.

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    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*/
            
          ),
          
        }
      )
    )

  • 0
    Certified Lead Developer
    in reply to Harsha Sharma

    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.

  • 0
    Certified Lead Developer
    in reply to Dai Williams

    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.

Reply Children
  • 0
    Certified Lead Developer
    in reply to Dai Williams
    You would need to +1 the array to get the actual row.

    thats correct! I also noticed the index mismatch just after sending the code here. 

    Meanwhile I tried a candlestick chart as well and looks like similar code as above can help get the selected row and thus we can retrieve id of the data selected. Adding the code here for reference 

    a!localVariables(
      local!data: {
        {
          Col0: "Mon",
          Col1: 20,
          Col2: 28,
          Col3: 38,
          Col4: 45
        },
        {
          Col0: "Tue",
          Col1: 31,
          Col2: 38,
          Col3: 55,
          Col4: 66
        },
        {
          Col0: "Wed",
          Col1: 50,
          Col2: 55,
          Col3: 77,
          Col4: 80
        },
        {
          Col0: "Thu",
          Col1: 77,
          Col2: 77,
          Col3: 66,
          Col4: 50
        },
        {
          Col0: "Fri",
          Col1: 68,
          Col2: 66,
          Col3: 22,
          Col4: 15
        }
      },
      googleCandlestickChartField(
        label: "Test",
        chartColumnData: {
          {
            type: "string",
            id: "Col0",
            rowDataKey: "Col0"
          },
          {
            type: "number",
            id: "Col1",
            rowDataKey: "Col1"
          },
          {
            type: "number",
            id: "Col2",
            rowDataKey: "Col2"
          },
          {
            type: "number",
            id: "Col3",
            rowDataKey: "Col3"
          },
          {
            type: "number",
            id: "Col4",
            rowDataKey: "Col4"
          }
        },
        chartRowData: { local!data },
        onSelection: {
          a!save(
            ri!var,
            index(
              local!data,
              tointeger(save!value.row) + 1,
              tointeger(save!value.column) + 1,
              {}
            )
          )
        }
      )
    )

  • 0
    Certified Lead Developer
    in reply to Harsha Sharma

    Great bit of collaboration here Harsha :) ... thank you!