Skip to main content
Known Participant
December 8, 2023
Question

Column chart categories only showing first one.

Hello,

The categories of column char showing one 1st at its index. The column chart is as follows:

series:


  local!columnSeries:a!forEach(
    items:local!months,
    expression: a!localVariables(
      a!chartSeries(
        label: fv!item,
        data: a!localVariables(
          local!count_usage:where(local!months=cast(typeof(local!months), fv!item), 0),
          if(
            length(local!count_usage)=0,
            0,
            index(index(local!localCbProcessess.data, "id_count", {}), local!count_usage, 0)
          )
        )
      )
    )
  )

Column Chart field:

 a!columnChartField(
                          categories: local!months,
                          series: local!columnSeries,
                          xAxisTitle: "Months",
                          yAxisTitle: "Usage",
                          stacking: "NONE",                         
                          colorScheme: "CLASSIC"
                        )

categories data sanp:

the chart is not showing all the categories

Can anyone help me out.

2 replies

davidj137213
Brainy
December 8, 2023

I've made some test. Try this. Only with one chartSeries, tell me if this is valid

a!localVariables(
local!months: {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"},
local!localCbProcessess: {23, 32, 12, 5, 9, 14, 7, 12, 21, 43, 21, 10},

{
a!sectionLayout(
label: "Section",
contents: {
a!columnChartField(
categories: local!months,
series: a!chartSeries(
label: local!months,
data: local!localCbProcessess
),

yAxisTitle: "Usage",
showLegend: false,
showTooltips: true
)
}
)
}
)

annap0005
Participating Frequently
December 9, 2023

do not use foreach to create chartSeries, use that to create data,

Ex.

local!columnSeries: a!chartSeries(
label: "Count",
data: a!forEach(
local!months,
a!localVariables(
local!count_usage: wherecontains(
fv!item,
touniformstring(local!data.month)
),
if(
length(local!count_usage) = 0, 0, sum( index( local!data.id_count, local!count_usage, { 0 }) )
)
)
)
)