我正在使用 PChart 创建线性图表。除了绘制的实际线条的质量之外,一切都很顺利。
当然,抗锯齿并没有关闭,甚至是显式开启。
这是实际图像的示例,所有这些步骤看起来都很难看。
有没有办法让画的线条更平滑,而不需要踩踏?
使用的代码:
public function linearTwoAxis($data, $fileName, $startColor = 0)
{
$pData = new \pData();
$i = 0;
foreach ($data as $key => $row)
{
$serie = $this->translator->trans("pages.reportDefault.$key");
$pData->addPoints($row, $serie);
$pData->setSerieOnAxis($serie, $i);
$pData->setSerieWeight($serie, 1);
$pData->setAxisName($i, $serie);
$pData->setPalette($serie, $this->colors[$startColor++]);
$pData->setAxisDisplay($i, AXIS_FORMAT_METRIC);
$i++;
}
$monthNames = array_keys($row);
$pData->setAxisPosition(1, AXIS_POSITION_RIGHT);
$pData->addPoints($monthNames, "Labels");
$pData->setAbscissa("Labels");
$pChart = new \pImage(750, 200, $pData);
$pChart->setFontProperties(array(
"FontName" => $this->fonts_dir . "arial.ttf",
"FontSize" => 8)
);
$pChart->setGraphArea(50, 10, 700, 150);
$pChart->Antialias = TRUE;
$pChart->drawScale(["Mode" => SCALE_MODE_START0]);
$pChart->drawLineChart();
$pChart->drawLegend(325,180,array("Style"=>LEGEND_BOX,"Mode"=>LEGEND_HORIZONTAL, "BoxWidth"=>30,"Family"=>LEGEND_FAMILY_LINE,"Alpha" => 0));
$pChart->render($this->target_dir . $fileName);
return $this->target_dirname . $fileName;
}