Input named parameter arrays in shortcode

I’m trying to use two api’s, one to pull information from and convert it to another one to generate a image. I’d like to use a shortcode like this:

{{< country-count type="pie" labels=["Kenya", "Sudan", "Germany"] >}}

That would generate this:

{
  type: 'pie',
  data: {
    labels: ['Kenya', 'Sudan', 'Germany'],
    datasets: [{
      label: 'Count',
      data: [300, 200, 250] # Retrieved from api using info from labels array
    }]
  }
}

Which I could use to create something like this:


https://quickchart.io/chart?bkg=white&c={ type: 'pie', data: { labels: ['Kenya', 'Sudan', 'Germany'], datasets: [{ label: 'Count', data: [300, 200, 250] }] }}


However, I’m stuck as labels=["Kenya", "Sudan", "Germany"] does not seem to be valid input for a shortcode, I keep getting this error

got quoted positional parameter. Cannot mix named and positional parameters

Is it possible to do what I want?

Try instead:

{{< country-count type="pie" labels="Kenya,Sudan,Germany" >}}

and then you can use split or other string manipulation functions.

Yeah that solves it.
I’ve been trying solutions for 2 days and I guess the correct solution was dead simple

Thanks

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