Quickchart question about bar graphs

Hello Gliders! I’m using a barchart from Quickchart.io and I had a question about how I should get my data in the dataset properly. Here’s the dataset code:

  datasets: [
      {
        type: "line",
        label: "Goal Amount",
        borderColor: "#043f21",
        borderWidth: 3,
        fill: false,
        showLine: false,
        pointRadius: 13,
        pointHoverRadius: 13,
        data: [
          33,
          26,
          29,
          89,
          41,
          70,
          84
        ]
      },
      {
        type: "bar",
        label: "Total Profit",
          display: false,
        backgroundColor: "#51b84d",
        data: [
          42,
          73,
          69,
          94,
          81,
          18,
          87
        ],
        borderColor: "white",
        borderWidth: 0
      }, 
    ]
  },

The data I’d like in the above code would be the goal amounts and the total profit from this table. I’m not sure how I can accomplish it? This is how the table is setup:

For each of the two columns, create a Joined List column using a comma separator.
And then use that joined list column as a replacement in your template. It should look something like this:

label: "Goal Amount",
        borderColor: "#043f21",
        borderWidth: 3,
        fill: false,
        showLine: false,
        pointRadius: 13,
        pointHoverRadius: 13,
        data: [{joined-list-goal-amount}]
2 Likes

Hi.
Maybe this could help:

2 Likes

Thank you :grinning:

2 Likes

This joined list works great! Thank you! However I noticed it only works for the y-axis values, but not the x-axis values. So my template looks like this:

Here’s the reference column:
Screen Shot 2021-11-26 at 8.38.03 AM

Here’s the chart display. It only shows the last month?

Also, is there a way to only show the last X amount of months? As time goes by this chart would extend pretty far on the x-axis unless I can limit it somehow.

As far as the inline list is concerned in the right hand side of the data editor you should be able to “limit the number of items”.

For the chart you should be able to use an If-Then-Else column to narrow down your dates and then point the chart to that if-then-else.

1 Like

hmm, I can’t see any obvious reason why that isn’t working.
One of the downsides of quickcharts with Glide is they can be quite tricky to debug. What I usually do if I have one that isn’t behaving is dump the entire chart URL into a rich text component, and then carefully examine it.

There are a few different ways to do this. Is the Joined List operating through a relation?
Assuming it is, what you could do is apply some logic in the source sheet to filter the relation.
Let’s say you only want data for the past 6 months. A rough and ready way could be:

  • Create a math column with the formula Now - 182, which will give you the date approximately 6 months ago
  • Compare that to the row date using an if-then-else column:
    – If date is on or after 6 months ago, then date
  • Now just build your relation to that if-then-else column, instead of the original column
3 Likes

Thank you both! @Eric_Penn and @Darren_Murphy !!! I managed to get the barchart x-axis labels working (there was some formatting issues with quotation marks in my joined list) as well as the filtering that shows only the last x months of data. Once again, this community of Gliders is awesome!

2 Likes

I just wanted to share what it now looks like as I added a selector to adjust the chart’s x-axis to display more data. Thanks again!



1 Like

Looking good!! Just a quick suggestion… if you make the choice component required it will get rid of the “-“ as an option.

2 Likes

Awesome! Thanks for that tip :+1:

Nice work! :+1:

Also, what Eric said.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.