Loading...
 
Skip to main content
{$facets|var_dump}
{$chart|var_dump}

{if not empty($facets)}

{if empty($container)}
{$containerClass = 'row'}
{else}
{$containerClass = $container.class}
{/if}
{$i = 0}

<div class="{$containerClass}"> {foreach $facets as $facet}
{if count($facet.options) gt 0}
{if not isset($chart$i.class)}{$chart$i.class = 'col-sm-12'}{/if}

<div class="{$chart$i.class|escape}"> <label class="h3">
{if not empty($chart$i.title)}
{$chart$i.title|escape}
{else}
{$facet.label|replace:' (Tree)':''|tr_if|escape}
{/if}
</label>
{$values = []}
{$labels = []}
{foreach from=$facet.options key=value item=label}
{if strpos($label, 'trackeritem:0 ') !== false}
{continue}
{/if}
{if preg_match('/(.*?)\s+((\d+))/', $label|escape, $matches)}
{$labels[] = $matches1}
{$values[] = $matches2}
{/if}
{/foreach}

{if not isset($chart$i.type)}{$chart$i.type = 'bar'}{/if}
{if not isset($chart$i.id)}{$chart$i.id = 'chart_'|cat:$i}{/if}
{if not isset($chart$i.size)}
{$chart$i.size = ,}
{else}
{$chart$i.size = ':'|explode:$chart$i.size}
{/if}

{if not isset($chart$i.colors)}
{$col = []}
{else}
{$col = ':'|explode:$chart$i.colors}
{/if}

{if not empty($chart$i.hcolors)}
{$hcol = ':'|explode:$chart$i.hcolors}
{else}
{$hcol = $col}
{/if}

{$datasets = 'data' => $values,
'backgroundColor' => $col
}
{if $hcol}{$datasets.hoverBackgroundColor = $hcol}{/if}
{if $chart$i.title}{$datasets.label = $chart$i.title|escape}{/if}

{$data = ['data' => ['labels' => $labels,'datasets' => $datasets]]}

{$options = 'responsive' => true, 'maintainAspectRatio' => false}{* some handy defaults (not working as expected) *}
{$data.options = $options}

{* ```
{$data|var_dump}


*} 
 {wikiplugin _name='chartjs' type=$chart<a class="wiki"   href="$i" rel="">$i</a>.type id=$chart<a class="wiki"   href="$i" rel="">$i</a>.id width=$chart<a class="wiki"   href="$i" rel="">$i</a>.size<a class="wiki"   href="0" rel="">0</a> height=$chart<a class="wiki"   href="$i" rel="">$i</a>.size<a class="wiki"   href="1" rel="">1</a> debug=1} 
 {$data|json_encode} 
 {/wikiplugin}

 </div> {/if} 
 {$i = $i + 1} 
 {/foreach}

 </div>{/if}