actionscript - Flex BarChart Stacked BarSeries labelFunction - Bar Count vs. Stacked Sum -


i have stacked bar chart bars need custom labeling. each bar needs display bar's value preceeded label. support this, have created custom labelfunction various barseries in barchart (see below).

the function rendering labels, in case of stacked bars, label values not displaying want. instead of showing bar's value, showing sum of bars in stack. example, if barset contains 3 bars values 3, 4, , 5, labels being displayed not "3", "4", , "5", "3", "7", , "12".

from this example looks can achieve results want creating separate labelfunction each individual barseries , accessing specific property (e.g. data.item.@foocount). however, i'd prefer having 1 generic function if possible. there property can access in place of xnumber gets me bar's particular value , not sum?

note default label behavior (i.e. not setting labelfunction) displays individual values, not sums... i'm assuming it's possible, without lot of hoops jump through. :)

my custom labelfunction:

  private function setcustomlabel(item:chartitem, series:series):string   {      var data:barseriesitem = barseriesitem(item);     var currentseries:barseries = barseries(series);      return currentseries.displayname + ": " + data.xnumber;    } 

a snippet of of barchart code:

  <mx:barchart id="mychart" showdatatips="true"                height="180" width="100%">        ...        <mx:barset type="stacked">         <mx:barseries displayname="foo count" xfield="foocount"                       labelfunction="setcustomlabel" />         <mx:barseries displayname="bar count" xfield="barcount"                       labelfunction="setcustomlabel" />       </mx:barset>      </mx:series>   </mx:barchart> 

thanks!

i believe want use dataprovider. right now, xnumber stacked series, , not of data coming in.

so, try this:

private function setcustomlabel(item:chartitem, series:series):string   {      var data:barseriesitem = barseriesitem(item);     var currentseries:barseries = barseries(series);      return currentseries.displayname + ": " + data.item[currentseries.xfield];    } 

this not tested, think idea of getting raw data instead of using item displays.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -