[ 5 posts ]

JJ G

  • Username: savagenoob
  • Joined: Tue Sep 06, 2011 1:24 pm
  • Posts: 3
  • Offline
  • Profile
Tags:

YUI 2 Charts

Post Posted: Tue Sep 06, 2011 2:24 pm
+0-
Sorry for my nubness, but I need help. When I change the example to read months instead of years, it comes up with an error....
Code:
<script type="text/javascript">
 
   YAHOO.widget.Chart.SWFURL = "includes/yui/charts/assets/charts.swf";
 
   //used to format x axis labels
   YAHOO.example.numberToCurrency = function( value )
   {
      return YAHOO.util.Number.format(Number(value), {prefix: "$", thousandsSeparator: ","});
   }
 
   //manipulating the DOM causes problems in ie, so create after window fires "load"
   YAHOO.util.Event.addListener(window, "load", function()
   {
 
   //--- data
 
      YAHOO.example.annualIncome =
      [
         { Month: <?php echo $monthname5;?>, revenue: 1246852, expense: 1123359, income: <?php echo $totalbroker5;?> },
         { Month: <?php echo $monthname4;?>, revenue: 2451876, expense: 2084952, income: <?php echo $totalbroker4;?> },
         { Month: <?php echo $monthname3;?>, revenue: 2917246, expense: 2587151, income: <?php echo $totalbroker3;?> },
         { Month: <?php echo $monthname2;?>, revenue: 3318185, expense: 3087456, income: <?php echo $totalbroker2;?> },
            { Month: <?php echo $monthname1;?>, revenue: 3318185, expense: 3087456, income: <?php echo $totalbroker1;?> }
      ];
 
      var incomeData = new YAHOO.util.DataSource( YAHOO.example.annualIncome );
      incomeData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
      incomeData.responseSchema = { fields: [ "Month", "revenue", "expense", "income" ] };
 
   //--- chart
 
      var seriesDef =
      [
         {
            xField: "revenue",
            displayName: "Revenue"
         },
         {
            xField: "expense",
            displayName: "Expense"
         },
         {
            type: "line",
            xField: "income",
            displayName: "Income"
         }
      ];
 
      var currencyAxis = new YAHOO.widget.NumericAxis();
      currencyAxis.labelFunction = "YAHOO.example.numberToCurrency";
 
      var mychart = new YAHOO.widget.BarChart( "chart", incomeData,
      {
         series: seriesDef,
         yField: "Month",
         xAxis: currencyAxis
      });
 
   //--- data table
 
      var columns =
      [
         { key: "Month", formatter: "", sortable: true, resizeable: true },
         { key: "revenue", formatter: "currency", sortable: true, resizeable: true },
         { key: "expense", formatter: "currency", sortable: true, resizeable: true },
         { key: "income", formatter: "currency", sortable: true, resizeable: true }
      ];
      var mytable = new YAHOO.widget.DataTable( "datatable", columns, incomeData,
         { sortedBy: { key: "Month", dir: "asc" }
      });
   });
 
</script>


Dont Know what I have to change to make this work...

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 440
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile

Re: YUI 2 Charts

Post Posted: Wed Sep 07, 2011 5:29 am
+0-
Changing the example to use Month instead of year works fine for me. I suspect your issue is with your php blocks though I cannot tell without being able to see live code. Do you have a link that I can take a look at it?

Thanks,
Tripp

JJ G

  • Username: savagenoob
  • Joined: Tue Sep 06, 2011 1:24 pm
  • Posts: 3
  • Offline
  • Profile
Tags:

Re: YUI 2 Charts

Post Posted: Wed Sep 07, 2011 7:16 am
+0-
Well the IE error message shows...

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
Timestamp: Wed, 7 Sep 2011 15:15:16 UTC


Message: 'September' is undefined
Line: 227
Char: 3
Code: 0
URI: https://www.snapmanagerpro.com/SmartChoice/index.php

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 440
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile

Re: YUI 2 Charts

Post Posted: Wed Sep 07, 2011 8:37 am
+0-
Make sure Month values are strings.
Code:
//this will work
{Month: "September",
...

//this will throw a javascript error
{Month: September,
...


Thanks,
Tripp

JJ G

  • Username: savagenoob
  • Joined: Tue Sep 06, 2011 1:24 pm
  • Posts: 3
  • Offline
  • Profile

Re: YUI 2 Charts

Post Posted: Wed Sep 07, 2011 1:27 pm
+0-
Damn. So simple. Thanks
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum