That solved my problem.
Thank you very much.

Segunda-feira, 10 de Março de 2014 18:29:37 UTC+1, asgallant escreveu:
>
> You can get a list of the CPUs in the table like this:
>
> SELECT ID FROM <table name> GROUP BY ID ORDER BY ID
>
> and then parse that query to build your select statement.  In PHP, it 
> might look like this:
>
> // $ids is the result from the query
> $cpus = array();
> foreach($ids as $id) {
>     $cpus[] = "SUM(IF(ID = '{$id['id']}', Speed, 0)) as {$id['id']}";
> }
> $sql = 'SELECT TimeStamp, ' . implode(', ', $cpus) . ' FROM <table name> 
> GROUP BY TimeStamp';
>
> On Monday, March 10, 2014 12:30:47 PM UTC-4, Bruno Carvalho wrote:
>>
>> yes, i did find those over the web.
>> But my problem is by exemple, at this moment CPU7 doesn't exist on table 
>> yet, but it will apear on it when i'll power on that CPU.
>> So, i am forced to update the SQL statement each time a CPU is added?
>> Some weeks, there's 2-3 CPU's added, some there's none, and some there's 
>> more...
>>
>> If i have to update the Statement each time i have to add a CPU, the 
>> process of making a chart will become very handy.
>>
>>
>> Segunda-feira, 10 de Março de 2014 17:15:35 UTC+1, asgallant escreveu:
>>>
>>> To get multiple series in the chart, you have to pivot your data so that 
>>> each CPU gets its own column.  MySQL does not have a pivot function, so you 
>>> have to do it manually:
>>>
>>> SELECT TimeStamp, SUM(IF(ID = 'CPU1', Speed, 0)) AS CPU1, SUM(IF(ID = 
>>> 'CPU2', Speed, 0)) AS CPU2, etc... FROM <table name> GROUP BY TimeStamp
>>>
>>> This does require that you know ahead of time what all the values of ID 
>>> can be, but you can acquire this by querying the database before generating 
>>> the pivot query if necessary.
>>>
>>> There are a ton of posts in this forum and on StackOverflow explaining 
>>> how to convert output from a database into a DataTable in a multitude of 
>>> different systems.
>>>
>>> On Friday, March 7, 2014 6:45:52 PM UTC-5, Bruno Carvalho wrote:
>>>>
>>>> Hello,
>>>>
>>>> I have googled alot and the answers i have found didn't satisyed me.
>>>> I have a MySQL table called cpu_speed wish looks like this:
>>>>
>>>> | TimeStamp | ID       | Speed
>>>> | 1394231304 | CPU2 |31.78
>>>> | 1394231497 | global |69.56
>>>> | 1394235469 | CPU1 |38.56
>>>> | 1394235472 | global |59.02
>>>>
>>>> This table can hold values from multiple CPU's.
>>>>
>>>> How can i generate a Graph like this:
>>>>
>>>> https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart
>>>>
>>>> Using those values?
>>>>
>>>> I want a graph line for each CPU.
>>>>
>>>> Best regards.
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to