Chart Monster

Members
  • Content count

    4
  • Joined

  • Last visited

About Chart Monster

  • Rank
    Forum Newbie
  1. Again - note that the XML that is created DOES contain the correct info - for instance, $fund_no resolves to it's value in the XML file, It's only in the chart that displays $fund_no instead of the resolved value.
  2. The initial page dynamicchart.php: <?php $fund_no = isset ($_REQUEST['fund_no']) ? $_REQUEST['fund_no'] : 1; $shareclass = isset ($_REQUEST['fund_no']) ? $_REQUEST['fund_no'] : 'A'; $date_as_of = isset ($_REQUEST['date']) ? $_REQUEST['date'] : '2011-07-31'; ?> <html> <head> <script LANGUAGE="Javascript" SRC="FusionWidgets/Charts/FusionCharts.js"></script> <title>FusionCharts - Dynamic Line Chart</title> </head> <body> <div id="chartdiv"></div> <script type="text/javascript"> var myChart = new FusionCharts("FusionWidgets/Charts/RealTimeLine.swf", "myChartId", "600", "400", "0", "0"); myChart.setDataURL("data_dynamic.php?fund_no=$fund_no&share_class=$shareclass&date=$date_as_of"); myChart.render("chartdiv"); </script> </body> </html> The pertinent info for data_dynamic.php: <?php $fund_no = isset ($_REQUEST['fund_no']) ? $_REQUEST['fund_no'] : 1; $shareclass = isset ($_REQUEST['fund_no']) ? $_REQUEST['fund_no'] : 'A'; $date_as_of = isset ($_REQUEST['date']) ? $_REQUEST['date'] : '2011-07-31'; $per_length = isset ($_REQUEST['per_length']) ? $_REQUEST['per_length'] : '10'; // --- The following five lines of code simply open a connection to the MySql database. --- // $doc = new DOMDocument(); $doc->formatOutput = true; $chart = $doc->createElement ('chart'); $doc->appendChild ($chart); function addAttribute ($name, $value) { global $doc; $attr = $doc->createAttribute ($name); $val = $doc->createTextNode ($value); $attr->appendChild ( $val ); return $attr; } $chart->appendChild ( addAttribute ('caption',"Calendar Year Returns, $fund_no vs BM")); $chart->appendChild ( addAttribute ('subcaption', $fund_no .' '. $benchmark1)); $chart->appendChild ( addAttribute ('dataStreamURL','data_dynamic_feed')); $chart->appendChild ( addAttribute ('refreshInterval','3')); $chart->appendChild ( addAttribute ('numberPrefix','$')); $chart->appendChild ( addAttribute ('numberSuffix','M')); $chart->appendChild ( addAttribute ('showValues','0')); $chart->appendChild ( addAttribute ('showRealTimeValue','1')); $chart->appendChild ( addAttribute ('realTimeValuePadding','50')); $chart->appendChild ( addAttribute ('dataStamp',$cdte-$per_length)); $categories = $doc->createElement ('categories'); $chart->appendChild ($categories); $dataset_1 = $doc->createElement ('dataset'); $dataset_2 = $doc->createElement ('dataset'); $dataset_1->appendChild ( addAttribute ('seriesName', $fund_no." NET")); $dataset_2->appendChild ( addAttribute ('seriesName', $benchmark1)); $chart->appendChild ($dataset_1); $chart->appendChild ($dataset_2); echo $doc->saveXML (); ?> The contents of data_dynamic_feed.php: <?php $fund_no = isset ($_REQUEST['fund_no']) ? $_REQUEST['fund_no'] : 1; $shareclass = isset ($_REQUEST['fund_no']) ? $_REQUEST['fund_no'] : 'A'; $date_as_of = isset ($_REQUEST['date']) ? $_REQUEST['date'] : '2011-07-31'; $dataStamp = isset ($_REQUEST['dataStamp']) ? $_REQUEST['dataStamp'] : '1'; ?> &label=<?php echo $dataStamp; ?>&value=<?php echo (4.441 * rand (-5,5)); ?>|<?php echo -0.99 * rand (-5,5); ?>&dataStamp=<?php echo $dataStamp + 1; ?>
  3. When creating my chart, I am using PHP's DOMDocument object to create the XML. I am trying to use variables in the captions/labels - and I have verified the XML that is created has the parsed variables (I launch the data generating script by itself and view source to validate the XML is correct). The chart, however, is displaying the PHP variable names (with the "$" in front too). This happens on the RealTimeLine widget, but does not happen when using MSLine chart (not widget). If I manually type in the text, it shows up on the chart fine (the XML data still looks exactly the same). For my purposes, though, I need to be able to allow people to choose different items and hard coding the values in, isn't practical. I am running this in Chrome (but I have tested in IE8 and it works...or not works as the case may be...the same). I am using a php script to generate the chart (using something very close to the sample real time sample script), it calls a data script that creates the xml, which in turn, calls a feed script that provides the data updates. Everything else is working fine, it's just the labels - (caption, subcaption, dataset seriesNames) for the RealTimeLine widget. When running essentially the same setup (sans feed script as it's not necessary) in the MSLine chart - everything comes through ok. Note that I do create the chart on the MSLine version using the PHP functions provided with FusionCharts. Oh, and I am using the proper JS files for the Widget (although I get the same result using the FusionChart JS file).