我使用PHPChart创建图表,我在堆栈条形图系列中添加数据标签时遇到问题。像贝娄这样的东西:
这是我的代码:
$line1 = array(4, 2, 9, 16);
$line2 = array(3, 7, 6.25, 3.125);
$pc = new C_PhpChartX(array($line1,$line2),'stackChart'.$chartId);
$pc->add_plugins(array('canvasTextRenderer'));
$pc->set_title(array('text'=> $config['title']));
$pc->set_stack_series(true);
$pc->set_animate(true);
$pc->set_legend(
array(
'renderer' => 'plugin::EnhancedLegendRenderer',
'show'=>true,
'location' => 'e',
'placement' => 'outside',
'yoffset' => 30,
'rendererOptions' => array('numberRows'=>2)
)
);
$pc->set_series_default(
array(
'renderer'=> 'plugin::BarRenderer',
'rendererOptions'=> array('barPadding'=>6,'barMargin'=>40),
'shadow' => true
));
foreach($seriesKeys as $k => $v){
$pc->add_series(array('label' => $config['series'][$v]));
}
//$pc->add_series(array('label'=>'1st Qtr'));
//$pc->add_series(array('label'=>'2nd Qtr'));
$pc->set_xaxes(array(
'xaxis'=>array(
'renderer'=>'plugin::CategoryAxisRenderer',
'ticks' => $config['ticks'],
'label' => $config['label']
)
));
$pc->set_yaxes(array(
'yaxis' => array(
'borderWidth'=>0,
'borderColor'=>'#ffffff',
'autoscale'=>true,
'labelRenderer'=>'plugin::CanvasAxisLabelRenderer',
'label'=>'Number of assignee')
));
$pc->draw();
但是上面的代码绘制了一张图表,就像我上传的图表一样,除了数据标签1,2,3或任何应该显示的数字(这意味着当前和缺席参与者的数量应该显示在系列中)