Tôôm

No data to display?

Recommended Posts

Hi,

Trying to make a simple multi-line chart and get "No data to display" message.

I don't understand why, can you help me with code below please?
What's wrong?

$arrData = array(
        "chart" => array(
            "theme" => "candy",
			"showValues"=> "1"
        ),
	 	"dataset" => array()
    );

$score_chart["P1"]=array("30", "60", "120", "240", "480", "160");
$score_chart["P2"]=array("-15", "-30", "-60", "", "-240", "-80");

foreach($score_chart as $player=>$player_score) {
	$datavalues=array();
	foreach($player_score as $value) array_push($datavalues, array("value" => $value));
	array_push($arrData["dataset"], array("seriesname" => $player, "data" => $datavalues));
	unset($datavalues);
}

$jsonEncodedData = json_encode($arrData);

$Chart = new FusionCharts("msline", "Scores" , "100%", "400", "chart-container", "json", $jsonEncodedData);

$Chart->render();

Fusioncharts seems amazing, can not wait to use it

Share this post


Link to post
Share on other sites

Hi,

 

Thanks for getting in touch.

 

While creating the dataSource of "msline" chart type, you are not creating the "categories" object which is why you are getting the "No data to display" error message on the chart.

The series values of the dataset object gets plotted against the x-axis labels defined in the "categories" object. If the labels are not defined the values cannot get plotted, hence you are getting the error.

Sample(with categories) : http://jsfiddle.net/fusioncharts/rx2p5m1r/

Sample(without categories) : http://jsfiddle.net/8ptfcqwk/3/

 

MSLine chart reference link : https://www.fusioncharts.com/dev/chart-guide/standard-charts/multi-series-charts#multiseries-line-chart-5

 

Thanks,

Akash.

Share this post


Link to post
Share on other sites

Thanks so much now it works.

It seems no to be needed in single line chart.
I missed this information in the API Reference and I was thinking to have an error message.

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now