View unanswered posts | View active topics It is currently Sat Apr 27, 2024 5:02 pm



Reply to topic  [ 2 posts ] 
Barchart with Data from MySQL 
Author Message
New pChart user
New pChart user

Joined: Mon Aug 19, 2013 7:01 pm
Posts: 1
Post Barchart with Data from MySQL
Hello Folks,
i am new with pchart, it is a great thing to realize own Charts.
So now, i have a question regarding to get Data from MySQL.

I want to do a Bar Graph, where i want to show Values Monthly over Years.

This means, the Serie ist the Year, the Absissa is the Month. Something like the Sandbox-Example of the BarGraph.

My Problem is now, that the Data in my MySQL-DB is like this:

Year Month Value
2012 01 312.5
2012 02 229
2012 03 243
2012 04 193
2012 05 202
2012 06 184
2012 07 166
2012 08 209
2012 09 207
2012 10 256
2012 11 234
2012 12 223

But the Sandboxexample of the BarGraph shows me the Data should be like this:
(One Serie is like One Year, each Value of them is a month)

$myData = new pData();
$myData->addPoints(array(19,-37,50,-30,-44,-19,28,33),"Serie1");
$myData->setSerieDescription("Serie1","Serie 1");
$myData->setSerieOnAxis("Serie1",0);

$myData->addPoints(array(17,-29,36,-7,21,-7,-11,46),"Serie2");
$myData->setSerieDescription("Serie2","Serie 2");
$myData->setSerieOnAxis("Serie2",0);

$myData->addPoints(array(24,-27,-24,12,14,39,30,-11),"Serie3");
$myData->setSerieDescription("Serie3","Serie 3");
$myData->setSerieOnAxis("Serie3",0);

$myData->addPoints(array("January","February","March","April","May","June","July","August"),"Absissa");
$myData->setAbscissa("Absissa");


So my question is, how can i read out my Data from MySQL in the right Format for the Bargraph like the Example shows me?

Thank you for your help, if you need more Information please ask.
And sorry for my bad English.

with Regards,
Oliver from Germany


Mon Aug 19, 2013 7:22 pm
Profile
pChart user
pChart user

Joined: Tue Aug 13, 2013 8:02 am
Posts: 5
Post Re: Barchart with Data from MySQL
Hi Oliver
Just a quick question, have you had a look at the pchart documentation for getting data from mysql?
http://wiki.pchart.net/doc.mysql.integration.html
This should give you some good headway into getting the data that you want.
If this does not help, try posting some of the code you use to get the data from mysql, this will enable a lot of users to help you troubleshoot.
Regards


Tue Aug 20, 2013 7:59 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 6 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