PHP Classes

Text Encoding with Data Scaling

Recommend this page to a friend!

      QGoogle Chart  >  All threads  >  Text Encoding with Data Scaling  >  (Un) Subscribe thread alerts  
Subject:Text Encoding with Data Scaling
Summary:Text Encoding with Data Scaling
Messages:14
Author:Dennis Moore
Date:2008-06-12 17:42:48
Update:2008-06-12 20:43:53
 
  1 - 10   11 - 14  

  1. Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Dennis Moore Dennis Moore - 2008-06-12 17:42:48
I am trying to use your class. I am having problems setting the encoding to use text encoding with data scaling. Here is a sample of my code and results:

$graph = new QGoogleChart();
$graph ->setSize(600, 250)
->addEncoding('text')
->setType('line')
->setSubtype('sparkline')
->setAxis(array("x","y"))
->setAxisStyles(array(0, '#0000ff', 12))
->setAxisStyles(array(1, '#ff0000', 14))

->setAxisRanges(array(1,0,50))
->setLineColors(array('#FF0000'))
->setAxisLabels(array_keys($arval))
->setGridLines(array(5, 5))
->addData(array_values($arval))
->render();

echo $graph->getURL();

url:
chart.apis.google.com/chart?cht=ls& ...:|1995|1996|1997|1998|1999|2000|2001|2002|2003|2004|2005|2006|2007|&chxr=1,0,50&chxs=0,0000ff,12|1,ff0000,14&chg=5,5&chd=s:SrljZlnktv09s


  2. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Tom Schaefer Tom Schaefer - 2008-06-12 18:23:20 - In reply to message 1 from Dennis Moore
Your message is a bit short breathed. I do not understand what you problem is. The graph renders data. I tested the code and it works. I do not know, what you are expecting. There are myriads of ways to represent data. Be kind and explain it more precisely.

  3. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Tom Schaefer Tom Schaefer - 2008-06-12 18:27:14 - In reply to message 1 from Dennis Moore
en.wikipedia.org/wiki/Sparkline
Maybe this is a hint for the correct use of sparklines.
Sparklines are a special kind of line charts.
Maybe this helps.

  4. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Tom Schaefer Tom Schaefer - 2008-06-12 18:32:34 - In reply to message 1 from Dennis Moore
Normally sparklines are used this way:
<?php

require_once('GoogleChart.class.php');

$range = range(25,100,8);
shuffle($range);

$graph = new QGoogleChart();
$graph ->setSize(120, 28)
->setType('line')
->setSubtype('sparkline')
//->setAxis(array("x","y"))
->setAxisStyles(array(0, '#000000', 7))
->setAxisStyles(array(1, '#000000', 7))
->setMarkers(array('spark', '#C6D9FD',1,0,5))
->setMarkers(array('spark', '#4D89F9',0,0,1))
//->setGridLines(array(20, 50))
;

$graph ->addData($range)
->addData($range)
->render();

?><img src="<?php echo $graph->getURL()?>"/>


  5. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Tom Schaefer Tom Schaefer - 2008-06-12 18:34:16 - In reply to message 1 from Dennis Moore
Sparkline is a name proposed by Edward Tufte for "small, high resolution graphics embedded in a context of words, numbers, images"[1].

Tufte describes sparklines as "data-intense, design-simple, word-sized graphics"[1]. Whereas the typical chart is designed to show as much data as possible, and is set off from the flow of text (as in the box below), sparklines are intended to be succinct, memorable, and located where they are discussed. As an example: The Dow Jones Index Image:Sparkline_dowjones.svg for 7 February 2006 as a sparkline; it's also in the box below. Their use inline usually means that they are about the same height as the surrounding text.
<img width="189" height="23" border="0" src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/87/Sparkline_dowjones.svg/189px-Sparkline_dowjones.svg.png" alt="Image:Sparkline_dowjones.svg"/>

  6. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Tom Schaefer Tom Schaefer - 2008-06-12 18:39:16 - In reply to message 5 from Tom Schaefer
According to the definition above, you just misunderstood what sparklines are. The scaling of data on axis make no sense in this very case.

  7. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Dennis Moore Dennis Moore - 2008-06-12 19:44:36 - In reply to message 6 from Tom Schaefer
I am having problems whether it is a chart, axis, or sparkline subtype of a line chart. I cannot get the line chart to align with the values on the y axis or x axis. The following are my outputs by just changing the setSubtype method.

Chart: does not render
chart.apis.google.com/chart?cht=l&c ...:|1995|1996|1997|1998|1999|2000|2001|2002|2003|2004|2005|2006|2007|&chxs=0,0000ff,12,1|1,ff0000,14,0&chg=5,5&chd=e:DLCSCeB4B3ByDNHGHeFtIOJIAA

Axis: renders but does not display anything
chart.apis.google.com/chart?cht=lxy ...:|1995|1996|1997|1998|1999|2000|2001|2002|2003|2004|2005|2006|2007|&chxs=0,0000ff,12,1|1,ff0000,14,0&chg=5,5&chd=e:DLCSCeB4B3ByDNHGHeFtIOJIAA

Sparkline: renders and displays but not correctly
chart.apis.google.com/chart?cht=ls& ...:|1995|1996|1997|1998|1999|2000|2001|2002|2003|2004|2005|2006|2007|&chxs=0,0000ff,12,1|1,ff0000,14,0&chg=5,5&chd=e:DLCSCeB4B3ByDNHGHeFtIOJIAA

I am having problems identifying the how the class methods correspond to the google chart api especially with addData and addEncoding.

  8. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Dennis Moore Dennis Moore - 2008-06-12 19:56:19 - In reply to message 6 from Tom Schaefer
Basically, I am building an array from out put of my database query.

Array
(
[1995] => 0
[1996] => 0
[1997] => 0
[1998] => 0
[1999] => 0
[2000] => 14
[2001] => 13
[2002] => 12
[2003] => 8
[2004] => 7
[2005] => 11
[2006] => 101
[2007] => 0
)

I want to create a simple line chart the displays the data by year. Two things happen. The points on the chart do not correspond to the coordinates on the chart. I cannot get a basic lc to render. I am using PHP 5.2.4. I had the hardest time passing a dynamically generated array into the addData method.

  9. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Tom Schaefer Tom Schaefer - 2008-06-12 20:03:41 - In reply to message 7 from Dennis Moore
code.google.com/apis/chart/
Just have a look at the big table
where the interactions are shown. My wrapper class
doesnot check these.
v0.2 will check against these properties for disallowing
render combinations that are not supported by Google Chart API.

For the moment I have no solution for your problem.
May be later.

  10. Re: Text Encoding with Data Scaling   Reply   Report abuse  
Picture of Dennis Moore Dennis Moore - 2008-06-12 20:04:27 - In reply to message 6 from Tom Schaefer
I just noticed that if I select "chart" as a subtype that the output code is incorrect. "cht=l" where it should be "cht=lc"

 
  1 - 10   11 - 14