Flex 3 Dashboard with DYNAMIC XML CHARTS

Yes, you read that right! After much searching and reading, I have FINALLY figured out how to get the pie and bar charts in the Flex 3 Dashboard working with dynamically generated XML fed from a CFC. It took a while and I’m pretty proud of myself for getting it done! It works like a charm - the application reads the values from pre-compiled XML files to give the initial pie or bar chart values. When the page is loaded, it fires off a CFC which generates the drill-down data in XML (using CFXML) from the SQL Server 2000 instance on the web server. The XML files are created with CFXML and CFFILE, writing to a directory with nameconflict=”overwrite” specified. The Flex 3 Dashboard then goes to that directory and pulls the appropriate XML file needed to display the pie or bar chart drill down data. How does the Flex 3 Dashboard know which XML file to load, you ask? Well, I’m passing in the value of the pre-defined drill down XML file as an attribute of the original XML file loaded at run-time. It’s honestly not as hard as I thought it was going to be, but this is my first real application in Flex 3 and I’m pretty happy that it works.

I don’t think I can post the code, but I would be glad to help anyone that asks, if I can.

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

Hi Bradley, I was wondering if you had a bit of time to help explain how you did this…I puzzled trying to get this working myself.

this is awesome. i am trying to do something similar as well. just wondering, do you hardcode/define all the columns/series? or is there a way of dynamically passing those values from the xml?

Hi bradley,
I am completly new to flex and very new to programming, I came across the flex 3 dashboard and was able to generate xml data fom my as400 server. I am able to see the data in the charts. The problem that I am having is with the drill down. I was wondering if you could point me in the right direcction. Any help is greatly appreciated.

EdgarV

Hey guys, sorry for not answering sooner, I’ve been busy at work.

@david - where specifically are you having trouble?

@EdgarV - the drilldown function is controlled from 2 files in the /src/qs/charts/effects/ folder in the assembly. If you’ve downloaded the dashboard from Adobe (or wherever you found it), then you will have the assemblies. One is for drilldown and one is for drillup. You shouldn’t need to do anything to those files though (I didn’t, anyway).

The only file that I really modified pretty heavily was PieChartContent.mxml, which is in /src/com/esria/samples/dashboard/view. In that page, I have all of the logic for creating and reading the XML into Flex 3 variables, then putting those variables to use within the application and allowing for the drilldown of the specific data points.

Let me know where you are having problems, and I’ll do my best to address your issues.

Brad

@ k3n - once the XML is read into the variable, you can do whatever you want with it, yeah. I am not defining anything as far as columns/series, that is all read and created dynamically from the XML files.

Brad

Hi bradley,
thank you for the reply, the problem that I am having with the drill down is that I would like to get the drill down from another xml file, right now it comes from the same xml file and then it distributes the values randomly.
So what I am looking to acomplush is for example you have the first xml file creates the monthly sales, and the second xml file would bring in the values for each day. Not really sure how to tackle that one.

thanks for any advice!!

hi,

is there a way to read from XML without using HTTPService?

There’s a FileReference but it requires the runtime to be AIR. any other way?

@edgarv - You can poke around in the MXML file that creates the chart to find the references to the XML file that generates the drill down effects. Once you have that, you can replace it with your own, as long as the MXML knows what you’re talking about in your custom drill down file. Make sense?

@shix - You can read the XML file into your application through the file system, or you can do it via Web Services. It’s your call, really (personal preference and/or requirement of the application).

Leave a comment

(required)

(required)