0

I am using pChart2.0 to generate a very simple Chart by the example code. The pChart data set to add the points is in the following format

$MyData->addPoints(array("Type A","Type B","Type C"),"Types");

I have the following php array to use dynamic values

$type[0] = "Type A";
$type[1] = "Type C";
$type[2] = "Type D";

I tried it to use it like

$data = print_r($type, ',');
$MyData->addPoints(array($data),"Types");

Also tried implode function, but somehow pChart is not accepting the data-set and not generating the Chart. Any suggestions please ?

qammar
  • 79
  • 2
  • 10

1 Answers1

0

Okay, I just sorted it out, the data-set should be provided in following format, without the array (as it is already in array)

$MyData->addPoints($type,"Types");

if you are using the associate array , with key, value pairs, then this can be done like

$MyData->addPoints(array_values($type),"Types");

So this might help someone doing something similar with pChart.

qammar
  • 79
  • 2
  • 10