Date axis support, allow template to iterate over assoc arrays
parent
5e79220911
commit
2c595b01aa
|
@ -609,15 +609,6 @@ I see 'FUNCTION $m[1]' instead.");
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static function array1($a)
|
||||
{
|
||||
if (is_null($a))
|
||||
return array();
|
||||
if (is_array($a) && !self::is_assoc($a))
|
||||
return $a;
|
||||
return array($a);
|
||||
}
|
||||
|
||||
// FOR[EACH] varref = array
|
||||
// или
|
||||
// FOR[EACH] varref (тогда записывается в себя)
|
||||
|
@ -643,7 +634,7 @@ I see 'FUNCTION $m[1]' instead.");
|
|||
"\$stack[] = $v;
|
||||
\$stack[] = $v_i;
|
||||
\$stack[] = 0;
|
||||
foreach (self::array1($t) as \$item) {
|
||||
foreach (($t ? $t : array()) as \$item) {
|
||||
$v = \$item;
|
||||
$iset";
|
||||
}
|
||||
|
|
19
olap.php
19
olap.php
|
@ -269,7 +269,7 @@ class OLAP
|
|||
'field_count' => $this->nfields,
|
||||
'srcid' => $this->current_srcid,
|
||||
'src' => $this->current_src,
|
||||
'fielddescs' => array_values($this->current_src['fielddescs']),
|
||||
'fielddescs' => $this->current_src['fielddescs'],
|
||||
'group_types' => array_values(self::$group_types),
|
||||
'functions' => array_values(self::$functions),
|
||||
'aggregates' => array_values(self::$aggregates),
|
||||
|
@ -519,7 +519,7 @@ class OLAP
|
|||
// Допишем своё значение поля в начало описаний "дочерних" графиков
|
||||
$my_desc = array(
|
||||
'field' => $this->current_src['fielddescs'][$my['field']]['name'],
|
||||
'func' => self::$functions[$my['func']]['name'],
|
||||
'func' => self::$functions[$my['func']]['name'],
|
||||
'value' => $this->field_format($my['field'], '', '', $k)
|
||||
);
|
||||
foreach ($gr as &$g)
|
||||
|
@ -535,6 +535,8 @@ class OLAP
|
|||
// А вот здесь реально строим данные для графика
|
||||
$gr = array(
|
||||
'desc' => array(),
|
||||
'fieldid' => $my['field'],
|
||||
'funcid' => $my['func'],
|
||||
'field' => $this->current_src['fielddescs'][$my['field']]['name'],
|
||||
'func' => self::$functions[$my['func']]['name'],
|
||||
'data' => array(),
|
||||
|
@ -1011,7 +1013,7 @@ class OLAP
|
|||
}
|
||||
|
||||
// Упрощение вывода JS-графиков - разбивает их на группы
|
||||
static function tpl_jsgraphs($graphs)
|
||||
function tpl_jsgraphs($graphs)
|
||||
{
|
||||
$groups = array();
|
||||
foreach ($graphs as $i => $graph)
|
||||
|
@ -1060,6 +1062,17 @@ class OLAP
|
|||
}
|
||||
if ($group)
|
||||
$groups[] = $group;
|
||||
if ($groups)
|
||||
{
|
||||
$g = $groups[0]['graphs'][0];
|
||||
if ($this->current_src['fielddescs'][$g['fieldid']]['is_time'] &&
|
||||
(!$g['funcid'] || $g['funcid'] == 'ym' || $g['funcid'] == 'ymd'))
|
||||
{
|
||||
$fmt = $g['funcid'] == 'ym' ? '%Y-%m' : '%Y-%m-%d';
|
||||
foreach ($groups as &$g)
|
||||
$g['date_axis'] = $fmt;
|
||||
}
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ var g = [
|
|||
<!-- END -->
|
||||
],
|
||||
x: "{q group.graphs.0.field}<!-- IF group.graphs.0.func --> ({q group.graphs.0.func})<!-- END -->",
|
||||
dateAxis: '{group.date_axis}',
|
||||
titles: [
|
||||
<!-- FOR graph = group.graphs -->{yesno(graph#,',','')}
|
||||
'{q graph.last_desc}'
|
||||
|
@ -199,18 +200,19 @@ function doPlot(logarithmic)
|
|||
axesDefaults: {
|
||||
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
|
||||
tickOptions: {
|
||||
fontSize: '10pt',
|
||||
fontSize: '10pt'
|
||||
}
|
||||
},
|
||||
axes: {
|
||||
xaxis: {
|
||||
label: g[i].x,
|
||||
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
|
||||
renderer: g[i].numeric ? $.jqplot.LinearAxisRenderer : $.jqplot.CategoryAxisRenderer,
|
||||
renderer: g[i].dateAxis ? $.jqplot.DateAxisRenderer : (g[i].numeric ? $.jqplot.LinearAxisRenderer : $.jqplot.CategoryAxisRenderer),
|
||||
sortMergedLabels: true,
|
||||
useStringSort: true,
|
||||
tickOptions: {
|
||||
angle: -30
|
||||
angle: -30,
|
||||
formatString: g[i].dateAxis
|
||||
}
|
||||
},
|
||||
yaxis: {
|
||||
|
|
Loading…
Reference in New Issue