我正在尝试将辅助 Y 轴绘制到与他们所谓的帕累托图相同的图表上 预期图表 我找不到办法解决它。我尝试在 gihub 存储库上搜索文档和演示示例,但没有找到任何帮助
但是一直显示如下 我当前的图表
任何帮助或提示将不胜感激
这是我的代码
$dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'ErrorFrequency!$C$1', null, 1),
];
$xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'ErrorFrequency!$B$2:$B$'.($this->rowIndex-1), null, $totalRowsCount),
];
$dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'ErrorFrequency!$C$2:$C$'.($this->rowIndex-1), null, $totalRowsCount),
];
$series = new DataSeries(
DataSeries::TYPE_BARCHART,
DataSeries::GROUPING_CLUSTERED,
range(0, count($dataSeriesValues) - 1),
$dataSeriesLabels,
$xAxisTickValues,
$dataSeriesValues
);
// second axis
$dataSeriesLabels2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'ErrorFrequency!$E$1', null, 1),
];
$dataSeriesValues2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'ErrorFrequency!$E$2:$E$'.($this->rowIndex-1), null, $totalRowsCount),
];
// Build the dataseries
$series2 = new DataSeries(
DataSeries::TYPE_LINECHART,
DataSeries::GROUPING_STANDARD ,
range(0, count($dataSeriesValues2) - 1),
$dataSeriesLabels2,
[],
$dataSeriesValues2
);
$series2->setPlotDirection(DataSeries::DIRECTION_VERTICAL);
$plotArea = new PlotArea(null, [$series,$series2]);
$legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Pareto Chart - Error Types (20% of errors cause 80% of issues)');
$yAxisLabel = new Title('Error Counts');
$secondaryYAxisLabel = new Title('Secondary Axis Label');
$yaxis = new Axis();
$xaxis = new Axis();
$yaxis->setAxisOptionsProperties('low', null, null, null, null, null, -20, 20, null, null);
$xaxis->setAxisOptionsProperties('low', null, null, null, null, null, 0, 0, null, null);
// Create the chart
$chart = new Chart(
'chart',
$title,
$legend,
$plotArea,
true,
DataSeries::EMPTY_AS_GAP,
null, // xAxisLabel
$yAxisLabel, // yAxisLabel
null, // xAxis
null, // yAxis
null, // majorGridlines
null, //minor Gridlines
$secondaryYAxisLabel
);
$chart->setTopLeftPosition('I3');
$chart->setBottomRightPosition('Z25');
$worksheet = $this->spreadsheet->getActiveSheet();
$worksheet->addChart($chart);
嗯,似乎还不支持辅助轴! 所以我必须采取解决方法来解决它