View unanswered posts | View active topics It is currently Sun Apr 28, 2024 5:42 am



Reply to topic  [ 2 posts ] 
Can't create multiple series, what am I missing? 
Author Message
New pChart user
New pChart user

Joined: Mon Jul 30, 2012 10:41 pm
Posts: 2
 Can't create multiple series, what am I missing?
I've spent the afternoon playing with pChart which so far is working, except for the fact that I'm unable to create multiple series. I have temperature from two probes as well as timestamps associated with each reading.

I can graph one series without issue, but when I add the second series it appears to just append the data from the second series onto the end of the first series. Also, using color coding or weight formatting seems to affect all the points, not just the series I tell it to.

Below is the code I'm using. $allReadings[] is an array containing more arrays that represent each dataset. I have verifed that the two datasets have equal amounts of entries. I've spent the last two hours searching for clues on google and going over the examples trying to find what I'm doing wrong, but I can't find it. Can someone point me in the right direction here?

Code:
#       echo "generating graph";

        $myData = new pData();
        $myData->addPoints($allTimestamps[0], "Timestamp");

        $myData->addPoints($allReadings[0], "Probe 1");
        $myData->addPoints($allReadings[1], "Probe 2");

        $myData->setSerieWeight("Probe 2", 2);

        $myData->setAbscissa("Timestamp");
        $myData->setXAxisName("Time");
        $myData->setXAxisDisplay(AXIS_FORMAT_TIME,"H:i");

        $myData->setAxisName(0,"Temperature");
        $myData->setAxisUnit(0," F");

        $myData->loadPalette("/var/www/palettes/navy.color", TRUE);

        $myPicture = new pImage(1400,500,$myData);
        $myPicture->setFontProperties(array("FontName"=>"/var/www/fonts/Forgotte.ttf","FontSize"=>12));

        $myPicture->setGraphArea(60,40,1380,480);

        $myPicture->drawScale(array("LabelSkip"=>59, "CycleBackground"=>TRUE));
        $myPicture->drawSplineChart();

        $myPicture->Render("/var/www/graph.png");


Thanks,
ljb2of3


Mon Jul 30, 2012 10:54 pm
Profile
New pChart user
New pChart user

Joined: Mon Jul 30, 2012 10:41 pm
Posts: 2
 Re: Can't create multiple series, what am I missing? *neverm
*sigh* Turns out pChart is working perfectly... the issue was me being an idiot. It's been so long since I used PHP or any loosely typed language that it was a simple as me forgetting to reset a variable in a loop. My second dataset also contained my first dataset which why it appeared that my second dataset had been appended to the first and that modifying the color of the second one affected the entire line. Because it was! A simple $var = NULL at the end of the loop and everything is happy!


Tue Jul 31, 2012 2:08 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron