{if $all_zeroes}
[`Not enough sales data to build cohort chart for the selected period.`]
{/if}
{* Too easy to shoot yourself in the foot *}
{if $table_data} {strip} {if $group_by == 'quarters'} {$header_str = "[`Quarter %s`]"} {elseif $group_by == 'months'} {$header_str = "[`Month %s`]"} {elseif $group_by == 'weeks'} {$header_str = "[`Week %s`]"} {else} {$header_str = "[`Day %s`]"} {/if} {foreach $table_data as $row} {/foreach} {/strip} {$index = 0} {foreach $table_data as $reg_date => $row} {$index = $index + 1} {foreach array_keys($table_data) as $col_date}{strip} {if empty($row[$col_date@index])} {else} {$stats = $row[$col_date@index]} {$percent = 100-$stats.percent_of_max} {$_bg_style = "linear-gradient(to bottom, transparent 0%, transparent {number_format($percent,2)}%, {$stats.color} {number_format($percent,2)}%, {$stats.color} 100%)"} {if !empty($request_options.type) && $request_options.type == "roi" && (round($stats.metric) <= 100)} {$_image_url = "{$wa_url}wa-apps/shop/img/patterns/white-pattern.png"} {$_bg_style = "background: url('{$_image_url}'), {$_bg_style};"} {else} {$_bg_style = "background: {$_bg_style};"} {/if} {/if} {/strip}{/foreach} {/foreach}
{sprintf($header_str, $row@index + 1)}[`Total`]
{$table_headers[$reg_date]} {if in_array(ifset($request_options.type), ['sales', 'profit', 'clv'])} {wa_currency_html($stats.metric, $def_cur)} {elseif ifset($request_options.type) == 'roi'} {round($stats.metric)}% {else} {round($stats.metric, 2)} {/if} {strip} {if in_array(ifset($request_options.type), ['sales', 'profit', 'clv'])} {wa_currency_html($table_totals[$reg_date], $def_cur)} {elseif ifset($request_options.type) == 'roi'} {round($table_totals[$reg_date])}% {else} {round($table_totals[$reg_date], 2)} {/if} {/strip}
{/if}