【发布时间】:2014-01-05 16:27:25
【问题描述】:
我正在使用最新版本的 JPGraph,并且我正在尝试更改 graph_api 文件以在组条形图上显示值。这是一段代码,用于显示我的更改(对于那些查看 API 的人,这是在 graph_group 函数中):
$tot = new BarPlot( array_values( $total ) );
$tot->value->show();
$tot->value->SetFormat('%2d');
$tot->value->SetColor('black','black');
$tot->value->SetFont($t_graph_font,FS_BOLD,9);
$tot->SetFillColor('lightblue');
$tot->SetWidth(0.7);
$tot->SetLegend( lang_get( 'legend_total' ) );
$graph->Add($tot);
$p1 = new BarPlot( array_values( $p_metrics['open'] ) );
$p1->SetFillColor( 'yellow' );
$p1->SetWidth( 1 );
$p1->SetLegend( plugin_lang_get( 'legend_opened' ) );
$p1->value->show();
$p1->value->SetColor('white','white');
$p1->value->SetFormat('%2d');
$p1->value->SetFont($t_graph_font,FS_BOLD,8);
$p1->SetFillColor('red');
$p1->SetLegend( lang_get( 'legend_still_open' ) );
$p2 = new BarPlot( array_values( $p_metrics['closed'] ) );
$p2->SetFillColor( 'blue' );
$p2->SetWidth( 1 );
$p2->SetLegend( plugin_lang_get( 'legend_closed' ) );
$p2->value->show();
$p2->value->SetFormat('%2d');
$p2->value->SetColor('black','black');
$p2->SetFillColor('forestgreen');
$p2->SetWidth(0.5);
$p2->SetLegend( lang_get( 'legend_closed' ) );
$gbplot = new GroupBarPlot( array( $p1, $p2 ) );
$gbplot->value->show();
$graph->Add( $gbplot );
根据 API,使用“value->show()”应该显示值。当我添加最后一行(对于 $gbplot)时,图表没有显示。如果我将其注释掉,图表将显示无值。我错过了什么?
【问题讨论】:
-
您不需要使用
$graph->Add()将条形图(或GroupBarPlot)添加到您的图表吗? -
抱歉,我没有发那么远。我将它添加到图表中。我正在更新 sn-p 以解决这个问题。