ksuriana

how to add a link in caption

Recommended Posts

Hi,

 I need to add a link, in caption.. I was  able to get this working in Fusion Free Charts using,

 

<a href='javascript:exportStuff("10","20","30");'> Export </a>

 

<a href='javascript:exportStuff("10","20","30");'>   Export      </a>

 

But instead of printing the link, it is showing the following in sub-caption

<a href='javascript:exportStuff("10","20","30");'> Export </a>

 
Can someone let me know how to fix this issue..

Share this post


Link to post
Share on other sites
Guest Sumedh

Hello,

 

Due to security and performance reasons, providing links for chart caption is not possible with FusionCharts XT version.

Share this post


Link to post
Share on other sites

I am not sure if it would be possible to add database data to caption?/

 

$strXML = "<chart caption='Airborne Allergens Levels' subcaption= 'Toledo, OHIO Last Count on: '

 

$strQuery7 = "SELECT DATE_FORMAT(date, '%W [%M %d, %Y]') AS Formated_date FROM Counts WHERE date = (SELECT MAX(date) FROM Counts)";
$result7 = mysql_query($strQuery7) or die(mysql_error());
 
 
So that my caption would read:
 
"Airborne Allergen Levels
Toledo, Ohio Last Count on: Saturday October 5, 2013"
 
I can get an echo statement to print 'Formated_date' correctly outside the Chart but not within caption, subcaption or other areas in the chart
 
I tried echo and other tricks but have not been successful..Help is appreciated
Edited by safadig

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

FusionCharts XT, "caption" and "subCaption" attributes of <chart> element are taking value as string.

 

So, as per your requirement, you could fetch the "Formated_date" value and assign it to a string variable and then concatenate that with the  "$strXML" while building the chart XML.

 

Ref. Code:

$subCap = "Saturday October 5, 2013"; //Need to be fetched from database

$strXML = "<chart caption='Airborne Allergens Levels' subcaption= 'Toledo, OHIO Last Count on: " . $subCap .  " '>";

Hope this helps!

Share this post


Link to post
Share on other sites

Expanding on my project..trying to get an HBullet.swf chart on single data result but getting error that Chart type not supported. Thanks for the help..

 

<?php
  include("./includes/FusionCharts.php");
  include("./includes/DBConn.php");
?>
<html>
    <head>
       <title>HBullet Chart</title>
<script type="text/javascript" src="Fusion/Charts/FusionCharts.js"></script>
 
 
    </head>
    <body>
       
<?php
// Connect to the Database
$link = connectToDB();
 
//Generate the graph element
   
 
   $strXML = "<chart lowerLimit='0' upperLimit='100' caption='testchart' showValue='1'>";
   
   $StrXML = "<colorRange>";
     $StrXML = "<color minValue='0' maxValue='50' color='A6A6A6'/>";
      $StrXML ="<color minValue='50' maxValue='500' color='CCCCCC'/>"; 
      $StrXML ="<color minValue='500' maxValue='5000' color='E1E1E1'/>"; 
  $StrXML .="</colorRange>"; 
   
 
    $strQuery = "select brick1 FROM Counts WHERE date = (SELECT MAX(date) FROM Counts)";        
    $result = mysql_query($strQuery) or die(mysql_error());
  
        
   
 
if ($result) {
while ($row_strQuery = mysql_fetch_assoc($result)){
        $strXML .="<value>";
        
               $strXML .="<set value='" . $row_strQuery['brick1'] . "'/>";
      $strXML .='</value>';
   } 
 
           
  
   
   
 
 
 
   
   
   //Finally, close <graph>element
   
   $strXML .="</chart>";
 
   //Create the chart with data from $strXML
   FC_SetRenderer("javascript");
  echo renderChart("Fusion/Widgets/HBullet.swf", "", $strXML, "brick1", "400", "400",false,true,true);
  
    ?>
 
  </body>
</html>

Share this post


Link to post
Share on other sites

Hi,

 

Check if you have the following files in your Widgets folder :

 

1. FusionCharts.js

2. FusionCharts.HC.js

3. FusionCharts.HC.Widgets.js

4. jquery.min.js

 

Also, check if have provided the name and path of the chart properly in your code ie. check if all files of FusionCharts are present in "Fusion/Widgets/ folder.

 

If all the above given steps are fine, then please clear your browser cache and check again.

 

Hope this helps.

Share this post


Link to post
Share on other sites

Thanks That helped ..but now getting "invalid data" source shows database link working fine..My guess, I am missing something in the color $StrXML rendering... Thanks

 

$strXML = "<chart lowerLimit='0' upperLimit='100' caption='BulletChart' subcaption='' numberprefix='' numbersuffix='' showValue='1'>";
   
   $strXML .= "<colorrange>";
$strXML .= "<color minvalue='0' maxvalue='20' color='A6A6A6'/>";
$strXML .= "<color minvalue='20' maxvalue='50' color='CCCCCC'/>";
$strXML .= "<color minvalue='50' maxvalue='100' color='E1E1E1'/>";
  $StrXML .="</colorrange><value><target>"; 
   $strXML .="<set target='95'/>";
 $strXML .='</target>';
   
 
    $strQuery = "select * FROM tables";        
    $result = mysql_query($strQuery) or die(mysql_error());
  
        
   
if ($result) {
while ($row_strQuery = mysql_fetch_assoc($result)){
                
               $strXML .="<set value='" . $row_strQuery['test1'] . "'/>";
      $strXML .='</value>';
   } 
 
  
   $strXML .="</chart>";

Share this post


Link to post
Share on other sites

Updated but still "Invalid data error"..

 

<?php
  include("./includes/FusionCharts.php");
  include("./includes/DBConn.php");
?>
<html>
    <head>
       <title>Graph</title>
<script type="text/javascript" src="Fusion/Widgets/FusionCharts.js"></script>
<meta charset='utf-8'>
 
    </head>
    <body>
       
<?php
// Connect to the Database
$link = connectToDB();
 
//Generate the graph element
   
 
 
 
   $strXML = "<chart lowerLimit='0' upperLimit='100' caption='Dr. Safadi' showValue='1'>";
   
   $strXML .= "<colorRange>";
$strXML .= "<color minValue='0' maxValue='20' color='3BFF46'/>";
$strXML .= "<color minValue='20' maxValue='50' color='FFF057'/>";
$strXML .= "<color minValue='50' maxValue='100' color='FF0000'/>";
$StrXML .="</colorRange><target>";
$strXML .="<set target='98'/>";
$strXML .="</target>"; 
  
 
        
$strQuery = "select brick1FROM Counts";        
    $result = mysql_query($strQuery) or die(mysql_error());
  
        
   
if ($result) {
while ($row_strQuery = mysql_fetch_assoc($result)){
                $strXML .="<value>"; 
               $strXML .="<set value='" . $row_strQuery['brick1'] . "'/>";
      $strXML .="</value>";
   } 
   
    
   
 
 
 
   
   
   //Finally, close <graph>element
   
   $strXML .="</chart>";
 
   //Create the chart with data from $strXML
   FC_SetRenderer("javascript");
  echo renderChart("Fusion/Widgets/HBullet.swf", "", $strXML, "brick1", "60%", "20%",false,true,false);
  
    ?>
 
  </body>
</html>

Share this post


Link to post
Share on other sites

here is the source code from above. Data seem to pull OK. It seems the problem is with colorrange..

<html>
<head>
<title>Graph</title>
<script type="text/javascript" src="Fusion/Widgets/FusionCharts.js"></script>
<meta charset='utf-8'>
    
</head>
<body>

<!-- START Code Block for Chart brick1-->
<div id="brick1Div">Chart</div>
<script type="text/javascript" ><!--
    // Instantiate the Chart
    if ( FusionCharts("brick1") && FusionCharts("brick1").dispose ) FusionCharts("brick1").dispose();
    var chart_brick1 = new FusionCharts( { "swfUrl" : "Fusion/Widgets/HBullet.swf", "width" : "60%", "height" : "20%", "renderAt" : "ragweedDiv", "renderer" : "javascript", "dataFormat" : "xml", "id" : "ragweed", "dataSource" : "<chart lowerLimit='0' upperLimit='100' caption='Dr. Safadi' showValue='1'><colorRange><color minValue='0' maxValue='20' color='3BFF46'/><color minValue='20' maxValue='50' color='FFF057'/><color minValue='50' maxValue='100' color='FF0000'/><set target='98'/></target><value><set value='34'/></value></chart>" } ).render();
// --></script>
<!-- END Script Block for Chart brick1 -->

         </body>
</html>

Share this post


Link to post
Share on other sites

Hey,

 

"Invalid Data" message occur when the XML data is malformed. The above XML output should be as below:

<chart lowerLimit='0' upperLimit='100' caption='Dr. Safadi' showValue='1'>
<colorRange>
<color minValue='0' maxValue='20' color='3BFF46'/>
<color minValue='20' maxValue='50' color='FFF057'/>
<color minValue='50' maxValue='100' color='FF0000'/>
</colorRange>
<target>98</target>
<value>34</value>
</chart>

Can you try generating the XML in the above format and render the chart?

 

For more information on Horizontal Bullet XML format, please refer to the following link: http://docs.fusioncharts.com/widgets/Contents/Bullet/Create.html

 

Hope this helps.

Share this post


Link to post
Share on other sites

I can get my Bullet chart to render fine (including my database data value and target BUT WITHOUT the color range. As soon as I place the <colorRange> I get the invalid data error.

I tried different versions of the I place after the <chart> $StrXML

 

A)
 
$strXML = "<chart paletteThemeColor='669933' palette='2' lowerLimit='0' upperLimit='100' caption='Dr_Safadi' showValue='0'>";
    
$strXML .= "<colorRange>";
$strXML .= "<color minValue='0' maxValue='20' />";
$strXML .= "<color minValue='20' maxValue='50' />";
$strXML .= "<color minValue='50' maxValue='100' />";
$StrXML .="</colorRange>";
 
 
B)
 
$strXML = "<chart lowerLimit='0' upperLimit='100' caption='Dr_Safadi' showValue='1'>";
   
   $strXML .= "<colorRange>";
$strXML .= "<color minValue='0' maxValue='20' code='3BFF46'/>";
$strXML .= "<color minValue='20' maxValue='50' code='FFF057'/>";
$strXML .= "<color minValue='50' maxValue='100' code='FF0000'/>";
$StrXML .="</colorRange>";
 
I tried code instead the word color. I tried with palette instead of individual color but still
 
Thanks

Share this post


Link to post
Share on other sites

FIXED!!!

I had to add <colorrange> after my DB queries and not before

 

Hope this can be of help for others that may face this problem...

 

 

Thanks for the help

 

Ghassan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now