Я пытаюсь создать линейную линейную или линейную диаграмму в Excel, используя PhpSpreadsheet.Я не могу получить Ось Y в нужном месте.Будь то линейная или гистограмма, ось Y отображается в случайных точках на графике.Вот мой код, взятый в основном из примера кода.
// Set the Labels for each data series we want to plot
$label=$sheetname."!\$H\$1";
$dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, $label, null, 1),
];
// Set the X-Axis Labels
$xrange=$sheetname."!\$C\$2:\$C\$".$lastrow;
$xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, $xrange, null, $lastrow),
];
// Set the Data values for each data series we want to plot
$data=$sheetname."!\$H\$2:\$H\$".$lastrow;
$dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, $data, null, $lastrow),
];
// Build the dataseries
$series = new DataSeries(
DataSeries::TYPE_BARCHART, // plotType
DataSeries::GROUPING_CLUSTERED, // plotGrouping
range(0, count($dataSeriesValues) - 1), // plotOrder
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
// Set the series in the plot area
$plotArea = new PlotArea(null, array($series));
// Set the chart legend
$legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Labor');
$xAxisLabel = new Title('Part Number');
$yAxisLabel = new Title('Minutes');
// Create the chart
$chart = new Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
$xAxisLabel, // xAxisLabel
$yAxisLabel // yAxisLabel
);
// Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A17');
$chart->setBottomRightPosition('N34');
// Add the chart to the worksheet
$sheet->addChart($chart);
Приведенный выше код создает следующую диаграмму: Пример
У меня та же проблема с линейным графикомтакже.Как я могу заставить значения Оси Y переместиться в нужное место на левой стороне?