1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

Chart Class: added renderTable() function and js fix for charts inside tabs.

This commit is contained in:
Cameron
2017-04-07 11:12:14 -07:00
parent ecef1f6ffa
commit abb7f66dd7

View File

@@ -218,6 +218,69 @@ class e_chart
return $this;
}
public function renderTable()
{
$head = array();
$body = array();
foreach($this->data as $k=>$v)
{
if($k == 0)
{
foreach($v as $key=> $val)
{
$head[] = $val;
}
continue;
}
foreach($v as $key=> $val)
{
$body[$k][$key] = $val;
}
}
$text = "<table class='table table-condensed table-striped table-bordered'>";
$text .= "<colgroup>";
foreach($head as $th)
{
$text .= "<col class='".eHelper::secureIdAttr($th)."' />";
}
$text .= "</colgroup>";
$text .= "<tr>";
foreach($head as $th)
{
$text .= "<th>".$th."</th>";
}
$text .= "</tr>";
foreach($body as $tr)
{
$text .= "<tr>";
foreach($tr as $td)
{
$text .= "<td>".$td."</td>";
}
$text .= "</tr>";
}
$text .= "</table>";
return $text;
}
/**
* Set the type of graph
* @param string $type - line | bar | pie | radar | doughnut | polar
@@ -395,13 +458,17 @@ class e_chart
});
$('a[data-toggle=\"tab\"]').on('shown.bs.tab', function (e) {
".$fName."();
});
";
e107::js('footer','https://www.google.com/jsapi');
e107::js('footer-inline', $js);
return "<div class='e-graph e-chart' id='".$id."' style='width: ".$width."; height: ".$height."px;'></div>";
return "<div class='e-graph e-chart' id='".$id."' style='width: ".$width."; height: ".$height."px;'></div>";
}