熔岩散点图无法显示年份

时间:2017-08-16 11:16:40

标签: laravel charts

我试图在这里添加年度明智的记录



$defect_reported_by_year = Lava::DataTable();

	    $defect_reported_by_year->addDateColumn("Year")
	    ->addNumberColumn('Value')
	    ->setDateTimeFormat('Y')
		->addRow(['2011', 20])
		->addRow(['2012', 100])
		->addRow(['2013', 22])
		->addRow(['2014', 34])
		->addRow(['2015', 65]);

		Lava::ScatterChart('defect_reported_by_year', $defect_reported_by_year, [
		    'width' => 1000,
		    'height' => 500,
		    'title' => 'Defects Reported by Year',
		    'legend' => [
		        'position' => 'none'
		    ]
		]);




但输出显示6个​​月的滑动。目前它的出现方式,任何人都可以帮助我只显示2011年,2012年等enter image description here

1 个答案:

答案 0 :(得分:0)

我刚刚通过DateRange以避开范围。

$defect_reported_by_year = Lava::DataTable();

$defect_reported_by_year->addDateColumn("Year")
->addNumberColumn('Value')
->setDateTimeFormat('Y')
->addRow(['2011', 20])
->addRow(['2012', 100])
->addRow(['2013', 22])
->addRow(['2014', 34])
->addRow(['2015', 65]);

//Apply DateRange filter
$defect_reported_by_year->DateRangeFilter('Year', 1, 1, 'Y');

Lava::ScatterChart('defect_reported_by_year', $defect_reported_by_year, [
    'width' => 1000,
    'height' => 500,
    'title' => 'Defects Reported by Year',
    'legend' => [
        'position' => 'none'
    ]
]);

没有测试过这个东西,这可能会对你有帮助。