Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
I would guess you can just specify a column and set the chartType property to line, similar to every other chart with a combination of column and line in koolreport's examples for the google charts.
e.g.)
"running_sale"=>array(
"label"=>"Total",
"type"=>"number",
"prefix"=>"$",
"chartType"=>"line",
),
look at the report view for these examples. It's probably the same for any chart that supports the feature. I have not tested this however. Just offering a suggestion.
https://www.koolreport.com/examples/reports/google_charts/pareto_chart/
https://www.koolreport.com/examples/reports/google_charts/combo_chart/
Honestly, I checked googles documentation and used the example columnchart for koolreport and I couldnt get a trendline going either. I tried as seen below and also by naming my columns ( sale, cost, profit ) but neither way worked for me.
ColumnChart::create(array(
"title"=>"Sale Report",
"dataSource"=>$category_amount,
"columns"=>array(
"category",
"sale"=>array("label"=>"Sale","type"=>"number","prefix"=>"$"),
"cost"=>array("label"=>"Cost","type"=>"number","prefix"=>"$"),
"profit"=>array("label"=>"Profit","type"=>"number","prefix"=>"$"),
),
"options"=>array(
"trendlines"=>array(
"0"=>array(
"type"=>"linear",
),
"1"=>array(
"type"=>"linear",
),
"2"=>array(
"type"=>"linear",
)
)
)
));
The JS looked legit.
("ColumnChart","gchart5c74dc3a504261",["category","sale","cost","profit"],[["category","Sale","Cost","Profit"],["Books",{"v":32000,"f":"$32,000"},{"v":20000,"f":"$20,000"},{"v":12000,"f":"$12,000"}],["Accessories",{"v":43000,"f":"$43,000"},{"v":36000,"f":"$36,000"},{"v":7000,"f":"$7,000"}],["Phones",{"v":54000,"f":"$54,000"},{"v":39000,"f":"$39,000"},{"v":15000,"f":"$15,000"}],["Movies",{"v":23000,"f":"$23,000"},{"v":18000,"f":"$18,000"},{"v":5000,"f":"$5,000"}],["Others",{"v":12000,"f":"$12,000"},{"v":6000,"f":"$6,000"},{"v":6000,"f":"$6,000"}]],{"trendlines":[{"type":"linear"},{"type":"linear"},{"type":"linear"}],"title":"Sale Report"},{"package":"corechart","stability":"current","mapsApiKey":""});
and the array matches the function in googlechart.js where the trendlines would fall into options.
function(chartType,chartId,cKeys,data,options,loader)
So its not clear to me why the trendlines are not working either. Sorry! Maybe one of the KR people can assist better.
This options from Andrew is correct:
"options"=>array(
"trendlines"=>array(
"0"=>array(
"type"=>"linear",
),
"1"=>array(
"type"=>"linear",
),
"2"=>array(
"type"=>"linear",
)
)
)
The problem is the data. Trendline will not work if the xAxis column are "text". Trendlines is to find the relationship function between x and y. Both x and y must be number. If x or y is "text", value of it becomes 0, there is no trendlines.
This below example will work:
<?php
ColumnChart::create(array(
"dataSource"=>array(
array("cat","amount"),
array(1,3),
array(2,8),
array(3,10),
array(4,15),
array(5,18),
),
"columns"=>array("cat","amount"),
"options"=>array(
"trendlines"=> array(
0=>array()
)
)
));
?>
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo