我试图用jpgraph创建一个简单的图形(这对我来说是一个新东西,我用他们网站上的条形图示例)并且想要y轴返回整个/四舍五入的数字。 所以我搜查了网页,发现我必须使用textint。jpgraph textint y轴返回0f而不是数字
所以,现在我已经有了这两条线:
$graph->SetScale("textint");
$graph->yaxis->SetTickPositions(array(0,1,2,3,4,5);
但不知何故,而不是返回一个整数的我现在得到0F关于y轴的每一步。 我只是想不通为什么它会导致成0F :( 是否有人对我有神奇的答案吗?我在做什么错左右,使其结果存入值0F?
更多代码:
$graphSettings = [
'tick_positions' => [0, 1, 2, 3, 4, 5],
'tick_labels' => ['Q1 2017', 'Q2 2017', 'Q3 2017', 'Q4 2017', 'Q1 2018'],
];
$graphs = [];
foreach ($questions as $key => $question) {
$graphs[] = $this->generateGraph($graphSettings, $question, $key);
}
public function generateGraph($settings, $question, $key) {
$data1y = $question['bar_plots']; // height of bars
// Create the graph. These two calls are always required
$graph = new \Graph(500, 200, 'auto');
$graph->SetScale("textint");
$theme_class = new \UniversalTheme;
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions($settings['tick_positions']); // array y numbers, array y between dashes
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels($settings['tick_labels']);
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// Create the bar plots
$b1plot = new \BarPlot($data1y);
// ...and add it to the graPH
$graph->Add($b1plot);
$b1plot->SetColor("white");
$b1plot->SetFillColor("#41b6e6");
// Return the graph
$contentType = 'image/png';
ob_start();
$graph->Stroke();
$image_data = ob_get_clean();
$str = "data:$contentType;base64," . base64_encode($image_data);
return $str;
}
编辑: 我而改变高度SETT只注意到现在开始显示我期望的数字(现在500乘以180而不是500乘以200)。这是插件本身的错误吗?