I'm trying to create a simple line chart that has a data set similar to the following :
[year:2018,month:1,count:1];[year:2018,month:2,count: 54][year:2018,month:3,count:123] [year:2019,month:1,count:347]; [year:2019,month:4,count:503]; [year:2019,month:5,count:52]Basically showing my for each year how many widgets were ordered for each month. Some months return null when we've not sold any widgets.However no matter what I do I'm getting stuck at my series and either everything s displayed on one month, or nothing at all.I'm sure it's a missing for each loop in the series but no luck so far.
Discussion posts and replies are publicly visible
load( local!data: { { year: 2018, month: 1, count: 1 }, { year: 2018, month: 2, count: 54 }, { year: 2018, month: 3, count: 123 }, { year: 2019, month: 1, count: 347 }, { year: 2019, month: 4, count: 503 }, { year: 2019, month: 5, count: 52 } }, local!months: { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }, local!years: union( local!data.year, local!data.year ), local!yearsData: a!forEach( items: local!years, expression: local!data[wherecontains( fv!item, tointeger( local!data.year ) )] ), a!lineChartField( label: "Example:", categories: local!months, series: { a!forEach( items: local!yearsData, expression: a!chartSeries( label: local!years[fv!index], data: with( locaL!currentValue: fv!item, a!forEach( items: local!months, expression: if( isnull( cast( typeof( 1 ), locaL!currentValue[wherecontains( fv!index, tointeger( local!currentValue.month ) )].count ) ), 0, cast( typeof( 1 ), locaL!currentValue[wherecontains( fv!index, tointeger( local!currentValue.month ) )].count ) ) ) ) ) ) }, xAxisTitle: "Month", yAxisTitle: "year", showLegend: true ) )
Nice!