Google charts аннотации к бары
Всем добрый день, прошу помощи по графику.Требуется вывести в подсказке информацию из ['operatorname'] и ['date'] . Выводится или то или другое
<?php
$con=mysql_connect("localhost","mysql","mysql") or die("Failed to connect with database!!!!");
mysql_select_db("met", $con);
$sth = mysql_query("select * from `cena` left join `cnc` on `cena`.`cher` = `cnc`.`detal` left join `chertesh` on `cnc`.`detal`=`chertesh`.`id` WHERE `cena`.`operaciya` = `cnc`.`operaciya` and (`detal`= $detal) and (`date` >= '$datastart') AND (`date` < '$dataend') order by cnc.operaciya");
$flag = true;
$table = array();
$table['cols'] = array(
array('label' => 'Операция', 'type' => 'string'),
array('label' => 'Годная продукция', 'type' => 'number'),
array('label' => 'Брак Операторов', 'type' => 'number' ),
array('label' => 'Брак ОТК / Отладка', 'type' => 'number' ),
array('label' => 'Оператор', 'type' => 'string' ),
array('label' => 'Дата', 'type' => 'string' , 'role' => 'tooltip' ),
);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
$temp[] = array('v' => (string) $r['translate']);
$temp[] = array('v' => (int) $r['colvodetal']);
$temp[] = array('v' => (int) $r['brakop']);
$temp[] = array('v' => (int) $r['brakotk']);
$temp[] = array('v' => (string) $r['operatorname']);
$temp[] = array('v' => (string) $r['date']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
?>
<html>
<head>
<body>
<!--Начало графика-->
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable(<?=$jsonTable?>);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1,
{ calc: "stringify",
sourceColumn: 4,
type: "string",
role: "annotation" },
2,3]);
var options = {
title: "График операций на изделие",
width: 1500,
height: 1500,
legend: { position: "none" },
bars: 'horizontal',
};
var chart = new google.visualization.BarChart(document.getElementById("barchart_material"));
chart.draw(view, options);
}
</script>
<div id="barchart_material" style="width: 900px; height: 900px;"></div>
<!--Конец графика-->
Ответы (1 шт):
Автор решения: freakrock
→ Ссылка
Решил вопрос таким образом
var view = new google.visualization.DataView(data);
view.setColumns([0, 1,
{ sourceColumn: 4,
type: "string",
role: "annotation" },
{ sourceColumn: 5,
type: "date",
role: "annotation",
fontSize: 18, },
2,3]);