Scrolling Large Data Sets in Flex Charts

 

Sometimes you just have too much chart data to display it all at once. The problem with this is that if you bind all the data to your chart, the chart axis labels become too small to read.

I came across this blog post by Joel May (http://www.connectedpixel.com/blog/scrollingcharts), which demonstrated a really neat way to deal with large chart data in Flex by using a component Joel dubbed a “ScrollableAxisRenderer”. Basically, Joel made a skin for a ScrollBar component so that it would fit compactly on a chart’s X or Y axis. He then made a special implementation of IList that wraps the base data provider (i.e. the one with too many elements to display), so that only a small portion of the data would be “visible” to the chart through the wrapper at any one time. Then, Joel programmed the scroll bar so that moving it around would result in scrolling of the large data set, allowing the chart to “see” as much or as little of the data as you want it to. The effect is really cool.

Unfortunately, Joel’s code didn’t work with dynamic data providers. I tried to take his original code and tweak it slightly to handle dynamic data, but it wasn’t as simple as I had hoped since all the classes seemed to be collaborating with different parts of the process. So, borrowing heavily from Joel’s original code, I re-implemented his idea, focusing most of my effort on a solid implementation of the class that masks the large data set. Once this was finished, I got a sample app working using a basic MXML component with embedded ActionScript. Finally, I split out the code in to AS classes so that the custom scroll bar, custom axis renderer, and collection mask had clearly defined responsibilities and worked as proper components.

I got it all working nicely, so I sent it to Joel just now to see if he was okay with me submitting our joint work to FlexLib. There was certainly a lot of interest in a dynamic version of his component on his blog post, but (like many of us with non-work projects) it looks like Joel did not have the time to go back and finish it off. It certainly is a really cool way to handle large data sets in Flex charts, so kudos to Joel for coming up with the idea and cooking it up.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值