Sign in to follow this  
Rahul Kumar

multiseries param using addDatasetsFromDatabase

Recommended Posts

i am trying to set the color of a multiseries line. is there anything wrong with the following? the line always comes up with a standard blue color and i cannot seem to control the line attributes.

 

$FC4->addDatasetsFromDatabase($result1,"hr1","sumofyield1","color=880000;");

i pass this using php,js with a

Thanks. Below is the code:

 

<?php

  //This file contains the db connection

  include("dbconn.php");

  //We've included FusionCharts_Gen.php, which contains FusionCharts PHP Class to help us easily embed the charts.

  include("FusionCharts_Gen.php");

  //This page generates the XML data for the Line Chart contained in

  //Default.php.

  //Connect to the Database

  $link = connectToDB();

  # Create a Line chart object. This size is overwritten in the HTML

  $FC4 = new FusionCharts("MSLine","850","650");

  # Set Relative Path of the FusionCharts swf file.

  $FC4->setSwfPath("FusionCharts/");

  #Store chart attributes in a variable

  $strParam="

caption=morning versus evening yield per milking by cattle_id - multiseries;

subcaption=sub caption;

xaxisname=date;

yaxisname=yield;

rotateNames=0;

yAxisValuesStep =1;

yAxisMaxValue=10;

labelStep = 1;

adjustDiv=1;

showValues=1;

decimalprecision=1;

alternateHGridColor=333333;

alternateHGridAlpha=20;

divLineColor=333333;

divLineAlpha=90;

divLineIsDashed=1;

canvasBorderColor=666666;

baseFontColor=999999;

lineThickness=2;

anchorRadius=2;

anchorAlpha=50;

bgColor=333333,000000,333333;

captionPadding=20;

canvasPadding=0;

chartTopMargin=60;

chartRightMargin=50;

bgAlpha=100;

bgSWFAlpha=100;

canvasBgAlpha=90;

canvasBgColor=000000,222222;

numDivLines =8;";

 

  #Set chart attributes

  $FC4->setChartParams($strParam);

 

  // Fetch all factory records using SQL Query

  // Store chart data values in 'sumofyield' column/field and category names in 'milking_date'

  $strQuery = "SELECT date(milking_date) as md, Sum(milking_yield) AS sumofyield FROM milking GROUP BY date(milking_date) ORDER BY milking_date";  

 

$strQuery1 = "SELECT hour(milking.milking_date) as hr1, date(milking.milking_date) as md1, (Sum(milking.milking_yield)) AS sumofyield1 FROM milking where (HOUR(milking.milking_date) <= 12) GROUP BY milking.milking_date ORDER BY milking.milking_date";

 

$strQuery2 = "SELECT hour(milking.milking_date) as hr2, date(milking.milking_date) as md2, (Sum(milking.milking_yield)) AS sumofyield2 FROM milking where (HOUR(milking.milking_date) > 12) GROUP BY milking.milking_date ORDER BY milking.milking_date";

  $result = mysql_query($strQuery) or die(mysql_error());

  $result1 = mysql_query($strQuery1) or die(mysql_error());

  $result2 = mysql_query($strQuery2) or die(mysql_error());

  //Pass the SQL Query result to the FusionCharts PHP Class function

  //along with field/column names that are storing chart values and corresponding category names

  //to set chart data from database

//  $strParam2="color=880000";

 

  $FC4->addCategoryFromDatabase($result,"md");

  $FC4->addDatasetsFromDatabase($result1,"hr1","sumofyield1","color=880000;");

  $FC4->addDatasetsFromDatabase($result2,"hr2","sumofyield2");

  mysql_close($link);

  //Set Proper output content-type

  header('Content-type: text/xml');

  //Just write out the XML data

  //NOTE THAT THIS PAGE DOESN'T CONTAIN ANY HTML TAG, WHATSOEVER

  print $FC4->getXML();

?>

 

Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

 
1. You could try using addColors("880000") function (need to remove color="880000" from addDatasetsFromDatabase)?
 
-OR-
 
2. $colorList[0] = "color=880000";
  addDatasetsFromDatabase($result1,"hr1","sumofyield1",$colorList);
 
Note: $colorList is an array type and $colorList[0] means parameters for first dataset.
 

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
Sign in to follow this