convert OFC2 as flex4 swc

Open Flash Chart 2(hereinafter referred to as "ofc2") is a famous open source flash chart library. Unfortunatly, it can not be used in flex project. You probably have known that WebASP has already made a SWC for ofc2, you can go to http://blog.webasp.com.au/post/625615072/open-flash-chart-2-kvasir-as-a-flex-swc-component (I call WebASP version as "ofc2library.swc") access the post. But I met some problems when I used it, so I start to fix those issue, and now I want to share it with flexer, because I build the SWC in Flex SDK 4.1, so I name my SWC as "flex4_ofc2.swc".

Download code and swc,  View Demo(view source code by right mouse button), Please feel free to use it, any problem, you can leave comments on this post.

if you can not see the flash demo, you can directly copy the url: http://www.smithfox.com/myopensource/flex4ofc2/testofc2.swf
The following list enhancment and fixed bug( more detail, you can view source code ) :

1. If you use WebASP ofc2library.swc in Flex4.1, there are some warning say the SWC is not compatible!!. because my flex4_ofc2.swc is built with Flex4.1 SDK, so it has not the issue. 

2. In the WebASP original post, author declares: Pie Chart Tooltip does not working in that component.

Now, I have fixed the issue!! Here, I simply show the root cause and my solution:

Because pie's tooltip need closely follow mouse, so in PieSlice class, the get_tip_pos function invoke localToGlobal  function to accurately calculate the tooltip position according to current mouse point, but other Element need NOT, so I add a "global" flag into ToolTip class to indicate it's position is a global point, and later I invoke globalToLocal  function to restore it as a local point before the common placing the tooltip method.

Maybe, you wonder why ofc2 has no the issue, this is because ofc2 is a flash, that just has only one element in whole stage, so global point equals local point. As you know, in flex, ofc2 just is one of components in stage.

3. Both ofc2 and WebASP's ofc2library.swc embed the JSON deeply, even include data loading and parse. I strip the data loading and parse from the ofc2, thus flex can use more data types as ofc2 data source, to the theory, you can use XML. After that, you can uniformly deal with the IOError event like other flex components' data process.

4. I removed all codes related communication with external Javascript. In flex, we need call AS3 function, but not the external javascript function. I did NOT implement assign Function object to the ofc2's data source. I have no time :(, if somebody interested in it, you can continue my work.

5. It's surprised that there are 4 or 5 Classes occurred compile error in ofc2 code (such as InnerBackground, PointCandle). I think it must be garbage file, because those garbage classes are not referred by any other class, so flash project do not compile them, but in flex library project, all class will join compile although it is an isolated class. 

6. I try to make the ofc2 be transparent, but it will cause more frequently mouse_roll event, and ofc2 became flashing.

7. I found more classes name in “chars.series” package are same with those classes in ”charts” package, it is very easy to cause some explained problem when refectory code. So I append 'Element' String to those “chars.series.xx.xx” classes name, for example, 'Bar' rename as 'BarElement'.

8. ofc2's AS3 source code has no a domain like package root, so you must declare the namespace like xmlns:ofc2chart="*" when you use WebASP ofc2library.swc. It is not too good, and the * namespace often conflict with my test project. So I move all ofc2 source code into “uk.co.teethgrinder” package (“teethgrinder.co.uk” is the ofc2 author site), and specify URI http://teethgrinder.co.uk as the namespace domain, then I can use the my SWC with declaration xmlns:ofc2chart="http://teethgrinder.co.uk"

9. ofc2 cannot deal with #val# variable in tip, I fixed it.

10. WebASP ofc2library.swc size: 517K, my flex4_ofc2.swc size: 132K   :)

11. Change the embed font as a light font

for rotate the label in charts, so the ofc2 embed the Arial font into the swf(or swc). Today I rebuild the my swc project, I found that the new swc file size became more big!!!, track into the code, find

[Embed(systemFont='Arial', fontName='spArial', mimeType='application/x-font')]

Maybe, Window7 Arial font file size is large than WindowsXP's. so I copy another lighter font into the ofc2 as asset, remove the dependens on windows system's font file.

[Embed(source = '/gothic.tff', fontName = 'spArial', mimeType = 'application/x-font')]

Then the swc size reduce to 132K, the old swc size is 267K. just half!!

中文版 Chinese version

smithfox | Monday 28 February 2011 at 3:41 pm | | UI        | Used tags: , , , ,

twelve comments

WebASP

Good effort. I will take a look to your source code and link back to my website as soon as possible. Thanks for mention WebASP.

WebASP, (URL) - 28-02-’11 19:20
guest

Pretty cool.

Seems the source zip ball download link is broken.

guest, - 08-04-’11 13:54
smithfox

I just rechecked the link, it does work!!

smithfox, (URL) - 08-04-’11 14:00
guest

Thx for the prompt response! Sorry, I meant the demo source code download link – http://www.smithfox.com/myopensource/fle..

guest, - 08-04-’11 22:16
smithfox

I removed the file, because the ball included more other unrelated files. actually, the demo only include one mxml file, and 3 json files. :)

smithfox, (URL) - 09-04-’11 15:47
guest

I got a chance to touch the demo code with the latest Flash Builder (Burritos). It worked like a charm. For those who would be interested, both the actionjson.swc (http://github.com/mherkender/actionjson/raw/apparatmemory/actionjson.swc) and the flex4_ofc2.swc will need to be put into the libs folder in your project, besides the 4 files.

smithfox – Thanks for the excellent work. Have you ported the demo explorer over (http://demo.webasp.com.au/ofc-explorer-k.html)? If so, mind posting the source project? TIA!

guest, - 09-04-’11 23:58
smithfox

Now, using flex4_ofc2.swc, the application is in charge of parsing JSON, but not ofc swc, so you can use any method or lib to encode/decode JSON. I use com.brokenfunction.json package.

I did not port the webasp demo explorer, I think my little demo is enough to prove it does work. :)

Thank your prompt us add the swc into the demo project. :)

smithfox, (URL) - 11-04-’11 10:55
smithfox

I updated the the component, reduce swc size from 267K to 132K, for detail to the 11

smithfox, (URL) - 23-04-’11 17:30
Fathah Noor

Hi, can anyone post link to a simple demo how to use this?
Thanks in advance :)

Fathah Noor, (URL) - 14-04-’14 01:20
Gucci iPhone 6 cases

In terms of your user experience, the major differences between the iPad Mini 3 and the Nexus 9, aside from the 1-inch of screen size, is that the iPad has a fingerprint sensor and the Nexus 9 has big, loud speakers powered by HTC’s BoomSound.

Gucci iPhone 6 cases, (URL) - 20-04-’15 17:48
Cheap Chanel Bags

It’s called vertical integration, and it’s a practice that dates back to the 1970s, when steel magnate Henri Recamier married into the Vuitton family and became the first outsider to take over the business.

Cheap Chanel Bags, (URL) - 06-07-’15 18:14
Yeezy Red October

This legendary single day fest usually serves as hip hop’s bellwether of who’s hot and who’s not. Case in point, since Future was a dominate force in the genre this year he gets a plum spot on the lineup

Yeezy Red October, (URL) - 01-06-’16 14:36
(optional field)
(optional field)
为阻止垃圾广告, 请在提交评论前, 回答一个简单问题(Please answer an simple question)
Remember personal info?
Notify
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.