Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Re: Chart polling doesn't add new columns even though new data is received

Expand Messages
  • Eric Miraglia
    Justin, I m glad you got squared away; thanks for raising the issue. Information about filing bug reports for YUI can be found here:
    Message 1 of 13 , Dec 2, 2008
    • 0 Attachment
      Justin,

      I'm glad you got squared away; thanks for raising the issue.

      Information about filing bug reports for YUI can be found here:


      Regards,
      Eric


      On Dec 2, 2008, at 1:57 PM, Justin Bolter wrote:

      I republished the swf and this seems to be the fix. Thank you for
      acknowledging and fixing the bug for me. Is there an appropriate
      place to report these types of bugs other than the forums?

      Thanks,
      Justin

      --- In ydn-javascript@ yahoogroups. com, "tripp.bridges" <trippb@...> wrote:
      >
      > Hi Justin,
      > My apologies for not getting back to you sooner. I actually responded
      > to another post with the same issue and somehow munged the two
      > together in my head. My bad.
      > 
      > We have plans to release a patch that will address this and other
      > issues before the end of the year but, unfortunately, there is not a
      > feasible workaround to use until then unless you are willing to alter
      > the underlying actionscript code and republish the SWF. 
      > 
      > If you are interested in making these changes yourself, They are
      > outlined below. If you do try this, feel free to ping back if you run
      > into any issues or have questions. 
      > 
      > 
      > Thanks, Tripp
      > 
      > 
      > Code changes below:
      > 
      > This bug exists in the CategoryAxis and the NumericAxis.
      > Here is the fix for the CategoryAxis class. 
      > (com/yahoo/astra/ fl/charts/ axes/CategoryAxi s.as)
      > 
      > 
      > First, add this method to the class:
      > private function getCategoryNames( value:Array) :Array
      > {
      > var names:Array = [];
      > if(value != null && value.length > 0)
      > {
      > for(var i:int = 0; i < value.length; i++)
      > {
      > names.push(value[ i].toString( ));
      > }
      > }
      > return names;
      > }
      > 
      > 
      > Next, change the setter for categoryNames to this:
      > 
      > public function set categoryNames( value:Array) :void
      > {
      > this._categoryNames SetByUser = value != null && value.length > 0;
      > if(this._categoryNa mesSetByUser)
      > {
      > this._categoryNames = [];
      > }
      > else
      > {
      > //ensure that all category names are strings
      > this._categoryNames = getCategoryNames( value);
      > }
      > }
      > 
      > 
      > Finally, in the method, autoDetectCategorie s, change the last line of
      > code from:
      > 
      > this.categoryNames = uniqueCategoryNames .concat() ;
      > 
      > to:
      > 
      > this._categoryNames = getCategoryNames( uniqueCategoryNa mes.concat( ));
      > 
      > For the numeric axis fix, changes will need to be made to:
      > (com/yahoo/astra/ fl/charts/ axes/NumericAxis .as)
      > 
      > In the method, calculateMajorUnit, change the last line of code from:
      > else majorUnit = 0;
      > to:
      > else this._majorUnit = 0;
      > 
      > 
      > 
      > --- In ydn-javascript@ yahoogroups. com, "Justin Bolter" <jbolter@>
      > wrote:
      > >
      > > Tripp,
      > > Have you looked into this bug yet? I am going to have to look for a
      > > new graph solution if this isn't solved or i don't have a workaround
      > soon.
      > > 
      > > Thanks,
      > > Justin
      > > 
      > > 
      > > 
      > > --- In ydn-javascript@ yahoogroups. com, "Justin Bolter" <jbolter@>
      > > wrote:
      > > >
      > > > Thank you for the clear explanation, however I don't seem to
      have any
      > > > luck with this. I defined a new axis and the problem persists. I'm
      > > > going to try this with your code but with a remote datasource that
      > > > returns JSON instead of a JS_ARRAY and see if that is the bug
      that i'm
      > > > running into.
      > > > 
      > > > 
      > > > --- In ydn-javascript@ yahoogroups. com, "Laura Arhire" <larhire@>
      > wrote:
      > > > >
      > > > > The difference is that my example uses an axis for the 0x
      instead of
      > > > a field
      > > > > (check the chart definition where it says yAxis and xField). I
      > > used time
      > > > > axis but i am pretty sure a numeric axis will be the same. I think
      > > > that will
      > > > > work for you as well. I've been able to do a lot using only axes,
      > > > but I've
      > > > > found that trying to reproduce some of those things using fields
      > (like
      > > > > "month" in the generic yahoo example) did not work. The function
      > > > thing was
      > > > > just for the example it was easier to set up that way you do not
      > > > need to use
      > > > > it.
      > > > > 
      > > > > I would just try replacing the fields with axis for the 0x in the
      > > > beginning
      > > > > and checking if the polling works. You need to do the following:
      > > > > 
      > > > > 1) Define an axis (numeric / time axis whatever you need) for
      the 0x
      > > > - you
      > > > > should have 2 axes defined in total
      > > > > 2) Replace the xField in the chart attributes with xAxis and set
      > > > this to the
      > > > > axis you created in (1)
      > > > > 3) Change your series definition from using only {displayName,
      > > > yField} to
      > > > > {displayName, yField, xField} where xField is the value your 0x
      > > > will take
      > > > > (in my case "month").
      > > > > 
      > > > > That should do the trick.
      > > > > 
      > > > > On Tue, Nov 11, 2008 at 1:21 AM, Justin Bolter <jbolter@> wrote:
      > > > > 
      > > > > > ok wait, i see in your example, if I add more lines to the
      data
      > > > > > source, they do show up, so what am I missing in my code? the
      > > > > > datasource must be a function that returns? i need this to be
      > > > > > dynamic, updating by calling a php script... how can i
      incorporate
      > > > > > your idea to fix my code?
      > > > > >
      > > > > > thanks!
      > > > > >
      > > > > > --- In ydn-javascript@ yahoogroups. com
      > > > <ydn-javascript% 40yahoogroups. com>,
      > > > > > "Justin Bolter" <jbolter@>
      > > > > > wrote:
      > > > > >
      > > > > > >
      > > > > > > I'm not sure this is quite what I'm looking for. My problem is
      > > that
      > > > > > > let's say I have six "month" points like in your example. Then
      > > > when I
      > > > > > > generate the new data, i have more than six points, 7 or 8
      > > say. well
      > > > > > > only the first 6 that were originally there are shown, the new
      > > > fields
      > > > > > > do not show up in the x-axis at all or anywhere on the chart.
      > > > > > >
      > > > > > > --- In ydn-javascript@ yahoogroups. com
      > > > <ydn-javascript% 40yahoogroups. com>,
      > > > > > "Laura Arhire" <larhire@> wrote:
      > > > > > > >
      > > > > > > > I've created an example (and remembered what was up with the
      > > > xField
      > > > > > > thing as
      > > > > > > > well). I could not get the polling to work by using fields,
      > > but it
      > > > > > > does work
      > > > > > > > with axes. I've used a function datasource as it was
      > easiest to
      > > > > > > integrate
      > > > > > > > with the polling feature. I don't know if this will help but
      > > here
      > > > > > it is:
      > > > > > > >
      > > > > > > > YAHOO.widget. Chart.SWFURL = "
      > > > > > > >
      > http://yui.yahooapi s.com/2.6. 0/build// charts/assets/ charts.swf";
      > > > > > > >
      > > > > > > > //--- data
      > > > > > > >
      > > > > > > > var date = new Date();
      > > > > > > >
      > > > > > > >
      > > > > > > > YAHOO.example. monthlyExpenses =
      > > > > > > > [
      > > > > > > > { month: date.setMonth( 0), rent: 880.00, utilities:
      894.68 },
      > > > > > > > { month: date.setMonth( 1), rent: 880.00, utilities:
      901.35 },
      > > > > > > > { month: date.setMonth( 2), rent: 880.00, utilities:
      889.32 },
      > > > > > > > { month: date.setMonth( 3), rent: 880.00, utilities:
      884.71 },
      > > > > > > > { month: date.setMonth( 4), rent: 910.00, utilities:
      879.811 },
      > > > > > > > { month: date.setMonth( 5), rent: 910.00, utilities: 897.95 }
      > > > > > > > ];
      > > > > > > >
      > > > > > > > var myDataSource = new YAHOO.util.DataSour ce( function()
      > {return
      > > > > > > > YAHOO.example. monthlyExpenses; });
      > > > > > > > myDataSource. responseType =
      > YAHOO.util.DataSour ce.TYPE_JSARRAY;
      > > > > > > > myDataSource. responseSchema =
      > > > > > > > {
      > > > > > > > fields: [ "month", "rent", "utilities" ]
      > > > > > > > };
      > > > > > > >
      > > > > > > > //--- chart
      > > > > > > >
      > > > > > > > var seriesDef =
      > > > > > > > [
      > > > > > > > { displayName: "Rent", yField: "rent", xField: "month" },
      > > > > > > > { displayName: "Utilities", yField: "utilities", xField:
      > > > > > > "month" }
      > > > > > > > ];
      > > > > > > >
      > > > > > > > YAHOO.example. formatCurrencyAx isLabel = function( value )
      > > > > > > > {
      > > > > > > > return YAHOO.util.Number. format( value,
      > > > > > > > {
      > > > > > > > prefix: "$",
      > > > > > > > thousandsSeparator: ",",
      > > > > > > > decimalPlaces: 2
      > > > > > > > });
      > > > > > > > }
      > > > > > > >
      > > > > > > > YAHOO.example. getDataTipText = function( item, index,
      series )
      > > > > > > > {
      > > > > > > > var toolTipText = series.displayName + " for " + item.month;
      > > > > > > > toolTipText += "\n" + YAHOO.example. formatCurrencyAx isLabel(
      > > > > > > > item[series. yField] );
      > > > > > > > return toolTipText;
      > > > > > > > }
      > > > > > > >
      > > > > > > > var currencyAxis = new YAHOO.widget. NumericAxis( );
      > > > > > > > // currencyAxis. minimum = 800;
      > > > > > > > currencyAxis. labelFunction =
      > > > > > YAHOO.example. formatCurrencyAx isLabel;
      > > > > > > >
      > > > > > > > var timeAxis = new YAHOO.widget. TimeAxis( );
      > > > > > > >
      > > > > > > > YAHOO.example. mychart = new YAHOO.widget. LineChart( "chart",
      > > > > > > > myDataSource,
      > > > > > > > {
      > > > > > > > series: seriesDef,
      > > > > > > > xAxis: timeAxis,
      > > > > > > > yAxis: currencyAxis,
      > > > > > > > dataTipFunction: YAHOO.example. getDataTipText,
      > > > > > > > //only needed for flash player express install
      > > > > > > > expressInstall: "assets/expressinst all.swf",
      > > > > > > > polling: 2000
      > > > > > > > });
      > > > > > > >
      > > > > > > >
      > > > > > > > setTimeout(" refresh() ", 5000);
      > > > > > > >
      > > > > > > > function refresh () {
      > > > > > > > YAHOO.example. monthlyExpenses =
      > > > > > > > [
      > > > > > > >
      > > > > > > >
      > > > > > > > { month: date.setMonth( 1), rent: 880.00,
      > > > > > utilities:
      > > > > > > > 901.35 },
      > > > > > > > { month: date.setMonth( 2), rent: 880.00,
      > > > > > utilities:
      > > > > > > > 889.32 },
      > > > > > > > { month: date.setMonth( 3), rent: 880.00,
      > > > > > utilities:
      > > > > > > > 884.71 },
      > > > > > > > { month: date.setMonth( 4), rent: 910.00,
      > > > > > utilities:
      > > > > > > > 879.811 },
      > > > > > > > { month: date.setMonth( 5), rent: 910.00,
      > > > > > utilities:
      > > > > > > > 897.95 },
      > > > > > > > { month: date.setMonth( 6), rent: 1880.00,
      > > > > > utilities:
      > > > > > > > 894.68 }
      > > > > > > > ];
      > > > > > > > }
      > > > > > > >
      > > > > > > >
      > > > > > > >
      > > > > > > >
      > > > > > > > On Fri, Nov 7, 2008 at 10:20 AM, Laura Arhire <larhire@>
      > wrote:
      > > > > > > >
      > > > > > > > > I've had a similar situation - but could not use the
      polling
      > > > feature
      > > > > > > > > because the project works with DWR which is
      asynchronous so
      > > > I had to
      > > > > > > > > recreate everything by hand and call refreshCHart.
      > > > > > > > >
      > > > > > > > > However, what I did find during trial and error is that
      > if the
      > > > > > > datasource
      > > > > > > > > looks like:
      > > > > > > > >
      > > > > > > > > var seriesDef =
      > > > > > > > > [
      > > > > > > > > { displayName: "Rent", yField: "rent" },
      > > > > > > > > { displayName: "Utilities", yField: "utilities" }
      > > > > > > > > ];
      > > > > > > > >
      > > > > > > > > then the new data will not appear. From what I
      remember, it
      > > > needs
      > > > > > > to look
      > > > > > > > > like:
      > > > > > > > > var seriesDef =
      > > > > > > > > [
      > > > > > > > > { displayName: "Rent", yField: "rent", xField: "month" },
      > > > > > > > > { displayName: "Utilities", yField: "utilities", xField:
      > > > > > > "month" }
      > > > > > > > > ];
      > > > > > > > >
      > > > > > > > > (from the example here:
      > > > > > > > >
      > > > > >
      > > http://developer. yahoo.com/ yui/examples/ charts/charts- quickstart. html)
      > > > > > > > >
      > > > > > > > > I'll try to come up with an example and post it here.
      > > > > > > > >
      > > > > > > > >
      > > > > > > > > On Fri, Nov 7, 2008 at 6:01 AM, tripp.bridges
      > <trippb@>wrote:
      > > > > > > > >
      > > > > > > > >> Hi Justin,
      > > > > > > > >> It looks like you've found a bug. I will need to
      > > > investigate this
      > > > > > > > >> further. I will post back to let you know if I can find a
      > > > > > workaround
      > > > > > > > >> for you.
      > > > > > > > >>
      > > > > > > > >> Thanks,
      > > > > > > > >> Tripp
      > > > > > > > >>
      > > > > > > > >> --- In
      > > > ydn-javascript@ yahoogroups. com<ydn-javascript% 40yahoogroups. com>
      > > > > > > <ydn-javascript% 40yahoogroups. com>,
      > > > > > > > >> "Justin Bolter" <jbolter@>
      > > > > > > > >> wrote:
      > > > > > > > >> >
      > > > > > > > >> > Hi,
      > > > > > > > >> > I have a chart just like the ColumnChart example that
      > does
      > > > > > > polling to
      > > > > > > > >> > a generatedata. php file. The problem is that as I query
      > > > > > > > >> > generatedata. php I keep gathering more and more data
      > > > which also
      > > > > > > means
      > > > > > > > >> > additional items that should be showing up on the
      x-axis.
      > > > > > However,
      > > > > > > > >> > the only thing that seems to update is the number
      in the
      > > > existing
      > > > > > > > >> > columns, no new columns show up. I look at my JSON
      > > > response and
      > > > > > > I can
      > > > > > > > >> > see that I am sending more Results that should show
      > up but
      > > > > > the only
      > > > > > > > >> > thing that is redrawn are the existing columns. Is
      there
      > > > a way
      > > > > > > to get
      > > > > > > > >> > this working? Changing the DataSource while the
      > polling is
      > > > > > going on
      > > > > > > > >> > didn't make a difference. I still only get the updates
      > > > for the
      > > > > > > > >> > columns that were drawn initially when the chart was
      > > created.
      > > > > > > > >> >
      > > > > > > > >> > Thanks,
      > > > > > > > >> > Justin
      > > > > > > > >> >
      > > > > > > > >>
      > > > > > > > >>
      > > > > > > > >>
      > > > > > > > >
      > > > > > > > >
      > > > > > > >
      > > > > > >
      > > > > >
      > > > > > 
      > > > > >
      > > > >
      > > >
      > >
      >


    Your message has been successfully submitted and would be delivered to recipients shortly.