Builing ColumnChart with HTTPService
Newbie. Can't find good code example. Would like to build a
ColumnChart with data returned from an HTTPService request. The
HTTPService request is bringing in an XML file. Here's the XML
data:
<receivables>
<rec-item projectId="11111" projectNumber="12111"
arGt30="0" bucket="181-270" oldestAr="5200" />
<rec-item projectId="22222" projectNumber="13111"
arGt30="26000" bucket="> 270" oldestAr="17000" />
<rec-item projectId="33333" projectNumber="14111"
arGt30="15000" bucket="None" oldestAr="7000" />
<rec-item projectId="44444" projectNumber="15111"
arGt30="7000" bucket="91-180" oldestAr="5200" />
<rec-item projectId="55555" projectNumber="16111"
arGt30="9200" bucket="Current" oldestAr="11000" />
<rec-item projectId="66666" projectNumber="17111"
arGt30="32000" bucket="31-60" oldestAr="12500" />
</receivables>
Let's assume your HTTPService has an id of "srv" and you've
set resultFormat="e4x". When the result comes back, you can
reference it as srv.lastResult. That maps to the
<receivables> element in your XML value.
However you have a problem: rec-item is not a good name
because of the hyphen. It throws a huge wrench into the works. So
let's assume you change this to <recItem>
srv.lastResult.recItem is then an XMLList which is like
Array, but each element of this XMLList is one <recItem>
node. You can now use this data in a ColumnChart:
<mx:ColumnChart dataProvider="{srv.lastResult.recItem}"
...>
<mx:series>
<mx:ColumnSeries xField="@bucket" yField="@arGt30" ...
/>
... (other series)
</mx:series>
</mx:ColumnChart>
Since you are using E4X, the @ syntax makes it easy to get at
the atttributes of each XML element.
That is: srv.lastResult.recItem[0].@projectId == "11111"
Similar Messages
-
Displaying External Web Page With HTTPService
Hi,
Does anyone know how to display an external web page with
HTTPService? I have an application here that I am trying to display
certain portions of the web page. Has anyone done this before
without feeding items of the web page into RSS?
Thanks in advance.
AliceHi,
Does anyone know how to display an external web page with
HTTPService? I have an application here that I am trying to display
certain portions of the web page. Has anyone done this before
without feeding items of the web page into RSS?
Thanks in advance.
Alice -
Calling and re-calling with httpservice
Here is a strange thing I ran into today. I have a program
which queries a DB through an aspx script called with httpservice.
A user clicks on a name, the query runs, and populates a form with
data from the database. The user can then edit the information and
submit the form to another script which makes changes to the DB.
That is all working except that when the user clicks on the same
name again, the old information is returned. I have verified that
the DB is being altered with the submit script. If I close the
application and reopen it and select the user again, then the
modified data is there. Is there something I am missing the
httpservice call? I've tried setting the array used for the result
data to null. I even put just a text field on the page and printed
the results of the query to it. It shows the old data too. It seems
like it's not actually running the query again like it should, but
rather taking the values from some place in memory until I close
the app and reopen it. Any ideas?
Relevant parts of my code are posted.OK...I've figured out that it is not actually calling the
page again. I had my aspx page log an entry each time the page was
called and for some reason, even though I am using the send(), it
does not actually go out and resend the data to the page. Anyone
know why? -
ColdFusion Script not work with Httpservice
At first I use PHP to generate xml output on page then use
the data to my httpservice with resultformat e4x. Everything is
fine. But now I want to use coldfusion script since I'm planning to
use ColdFusion as my web server. I have this script located on my
server and generate the data in XML file then the XML file is used
in my web, loaded through httpservice.
My PHP code was like this :
<?php
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "" );
define( "DATABASE_NAME", "MyCinema" );
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME,
DATABASE_PASSWORD) or die(mysql_error());
mysql_select_db( DATABASE_NAME );
$Query = "SELECT * FROM film";
$Result = mysql_query( $Query );
$Return = "<movies>";
while ( $film = mysql_fetch_object( $Result ) )
$Return .= "<film><judul>".$film->JUDUL.
"</judul><deskripsi>".$film->DESKRIPSI.
"</deskripsi><genre>".$film->GENRE.
"</genre><produser>".$film->PRODUSER.
"</produser><produksi>".$film->PRODUKSI.
"</produksi><homepage>".$film->HOMEPAGE.
"</homepage><durasi>".$film->DURASI.
"</durasi><url>".$film->URL."</url></film>";
$Return .= "</movies>";
mysql_free_result( $Result );
print ($Return);
?>
And now I try to get the same result using coldfusion script.
At first I dont write the XML to file, I just cfoutput it just like
I do with PHP just print result but it doesnt work out with my
HTTPservice. Until I try to write it to XML file then coding my
httpservice to read directly from that XML file. here is my
coldfusion code.
<cfcomponent>
<cffunction name="a" returnType="Void" output="true"
access="remote">
<cfprocessingdirective suppresswhitespace="Yes">
<cfquery name="GetFilm" datasource="myCinemaData">
SELECT b.* FROM playing a, film b
WHERE a.kode_film=b.kode_film AND a.start >
<cfqueryPARAM value = "#DateFormat(Now())#"
CFSQLType = "CF_SQL_STRING">
</cfquery>
<cfxml variable="userXML">
<movies>
<cfloop query="GetFilm">
<cfoutput>
<film>
<judul>#GetFilm.JUDUL#</judul>
<deskripsi>#GetFilm.DESKRIPSI#</deskripsi>
<genre>#GetFilm.GENRE#</genre>
<produser>#GetFilm.PRODUSER#</produser>
<produksi>#GetFilm.PRODUKSI#</produksi>
<homepage>#GetFilm.HOMEPAGE#</homepage>
<durasi>#GetFilm.DURASI#</durasi>
<url>#GetFilm.URL#</url>
</film>
</cfoutput>
</cfloop>
</movies>
</cfxml>
</cfprocessingdirective>
<cffile action="write"
file="#expandPath(".")#\userXML.xml" output="#userXML#">
</cffunction>
</cfcomponent>
Because I need to create the XML files first I try to execute
this coldfusion script first using webservice before I execute my
Httpservice but the XML file creation is slower than the execution
of my httpservice afterthat so it shows an error that my XML file
isn't not available. What can i do? I've tried to show the output
using cfoutput and run that script directly on my httpservice just
like the way I use print result on PHP but it produce an
error.... I try to execute this coldfusion script first using
webservice before I execute my Httpservice but the
XML file creation is slower than the execution of
my httpservice afterthat so it shows an error
that my XML file isn't not available.
Then it might help to apply a named lock to ensure that the
Httpservice runs only after the web service call is complete. For
example, apply an exclusive named lock on the code that calls the
web service and a readonly lock of the same name to the Coldfusion
code that interacts with the Httpservice. -
Help with httpService returnFormat "object"
Problem:
My flex httpservice returns an xml file in the "object"
resultFormat.
How could I get the count of all childNodes of an object in
that returned object tree.
For example, in the xml file below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<reporting>
<series>
<title>Edge Page Views, in Page Views per
Second</title>
<xLabel>startdatetime</xLabel>
<y1Label>sum(pageviews)</y1Label>
<data>
<x>1216233600</x>
<y1>79.605</y1>
</data>
<data>
<x>1216233900</x>
<y1>78.076</y1>
</data>
</series>
<series>
<title>Total Bandwidth, in Mbits per
Second</title>
<xLabel>startdatetime</xLabel>
<y1Label>sum(egress_bytes_mbps)</y1Label>
<y2Label>combined_midgress_bytes_mbps</y2Label>
<y3Label>ovh_bytes_mbps</y3Label>
<y4Label>sum(ingress_bytes_mbps)</y4Label>
<data>
<x>1216233600</x>
<y1>36.160352</y1>
<y2>66.48362700000001</y2>
<y3>66.48362700000001</y3>
<y4>96.01235200000002</y4>
</data>
<data>
<x>1216233900</x>
<y1>34.260794</y1>
<y2>62.10649799999999</y2>
<y3>62.10649799999999</y3>
<y4>88.902323</y4>
</data>
<data>
<x>1216234200</x>
<y1>35.329617</y1>
<y2>62.77339099999999</y2>
<y3>62.77339099999999</y3>
<y4>89.30751</y4>
</data>
</series>
</reporting>
The first series element has 4 children
I am able to get the number of data elements as:
"resultObj.reporting.series[0].data.length"
How do I effectively retreive:
"resultObj.reporting.series[0].childNodes().length"
Apparently this does'nt work, I also tried Nodes, children().
Any documentation or help with this would be awesome
Thanks a ton
PranayCan someone please help me understand this error maybe?
I would appreciate it
[MessagingError message='Destination 'the destination of an
xml file' either does not exist or the destination has no channels
defined (and the application does not define any default
channels.)']
what are channels? -
To populate a tree with httpService
Hi,
i don't arrive to populate my tree with an httpService.
Here is the code
<mx:Tree width="30%" height="100%" id="arboChambre"
labelField="@name"
dataProvider="{restree.lastResult.chambres.type}"
labelFunction="displayNodeName" />
and the script in <mx:Script>
private function displayNodeName( item:Object ) : String {
var node:XML = XML(item);
return node.@name;}
the xml returned by httpservice
<?xml version='1.0' encoding='utf-8' ?>
<chambres>
<type name="standart">
<chambre name="chambre1"/>
<chambre name="chambre2"/>
<chambre name="chambre3"/>
<chambre name="chambre4"/>
<chambre name="chambre5"/>
</type>
<type name="superieur junior">
<chambre name="chambre9"/>
<chambre name="chambre10"/>
</type>
</chambres>
And in my application i see only five icons files but not
directory and not name of the files (or directory ....)
Can you say me where is my mystake.Thank for your answers and sorry for my english
here is my httpservice definition in my file.mxml
quote:
<mx:HTTPService id="restree" url="
http://lesite.com/index.php"
useProxy="false" method="POST" >
<mx:request xmlns="">
<action>
getTree
</action>
</mx:request>
</mx:HTTPService>
If i don't want to use lasResult , i think that i must call
the data in AS3 but it's difficult for me to understand the
documentation in english ;I tried to use URLLoader but when i
compile i have a lot of mistake.
is it the good way to use URLLoader in <mx:script>???
thank you -
HTTP POST with XML with HTTPService
Hi,
I need to be able to send an HTTP POST request to a server I
have on Tomcat. In the body of the POST Request I need to have the
following:
<setView domain="someDomain" view="macro" />
We have tried the following using the HTTPService, but with
no such luck
<mx:HTTPService id="setViewHTTPService" url="{serverURL}"
resultFormat="object" contentType="application/xml"
method="POST">
<mx:request>
<setView domain="abc" view="xyz" />
</mx:request>
</mx:HTTPService>
Is there a way for us to specify the body of the HTTP Post
using HTTPService, or a different class for that matter.var variables:URLVariables = new
URLVariables("name=Franklin");
//or variables.name = "Franklin";
var request:URLRequest = new URLRequest();
request.url = "
http://www.[yourdomain
request.method = URLRequestMethod.POST;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
try
loader.load(request);
catch (error:Error)
trace("Unable to load URL");
function completeHandler(event:Event):void
trace(event.target.data.welcomeMessage);
This is in the help documentation and what I generally use. -
I'm new to flex (and actionscript really) and I am having a
problem with the program I'm writing.
My httpservice object is throwing a httpFault with a message
that says:
[MessagingError message='Destination 'the destination of an
xml file' either does not exist or the destination has no channels
defined (and the application does not define any default
channels.)']
I know the xml file exists... i've tried a few others as
well... honestly I don't know what the channel bit means (I've
looked a few things from google about the same error and didn't
have an understanding of what was being said)
I've attached my code, I am not sure what I am suppose to do.
I am trying to update a list with data stored in the
ArtistList class which is my model, the php file at
http://localhost/bearcube2/artists.php
outputs xml...I've also tried just plain xml files on the web and
locally, i get the same error message
I want to declare the httpService in actionscript and not the
mxml because I plan on having user input send more GET requests,
but I haven't gotten that far yet.
Sorry If I'm missing something simple, but I've been trying
to find what im doing wrong for a while and since I'm new to flex I
figure I just don't understand how to use something.
Thanks for any helpCan someone please help me understand this error maybe?
I would appreciate it
[MessagingError message='Destination 'the destination of an
xml file' either does not exist or the destination has no channels
defined (and the application does not define any default
channels.)']
what are channels? -
Flex component with HTTPService
OK, so I'm a Flex newbie so forgive me if I'm missing the
obvious.
I created a Flex component that references a HTTPService to
populate a DataGrid with data. As a standalone .mxml file, it works
fine. When I place it into a Flex application where the component
is referenced, the grid shows up, but I get no data. I've tried
referencing the HTTPService in the application itself, no luck.
I've tried referencing the service in a creationComplete function
on the application page, no luck. I'm sure there's just some little
snippet that allows the service to run in the component...the
component looks fine when I run it, I just don't get any
data.Thanks--actually I figured it out--I was overlooking
something obvious. However, I have a new issue that I would
genuinely appreciate assistance on.
I am building a Flex app where I have 4 custom components.
Each component calls a web service to pull data in. I am using an
MXML application file to bring in each component with an additional
component where the user can select a date range and submit that
range to the various web services. So what I need to do is make the
date fields public variables and then append those variables to the
web service calls as name/value pairs.
No matter what I do, I cannot seem to get the other
components to recognize the date variables as public vars. I've
written them out as variables as part of a public function, tried
to make them bindable, nothing works...
So for example, this is a simplified version of my date range
component (using only one date), assuming I've named the component
datebar.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Script>
<![CDATA[
public function clickHandler():void
var sdate:String = start_date.text;
]]>
</mx:Script>
<mx:ApplicationControlBar width="100%" height="30">
<mx:DateField id="start_date" />
<mx:Button label="refresh" click="clickHandler();" />
</mx:Label>
</mx:ApplicationControlBar>
</mx:Canvas>
Then in another component using a web service, I place:
<mx:HTTPService
id="os_downloads"
url="
http://publishingdynamics.com/service.asmx?start_date={datebar.sdate}"
useProxy="false">
Where {datebar.sdate} is the variable I'm referencing to get
a value from. I get a constant error doing this. I've tried several
varitions. I can successfully create a public variable in the same
manner not using a form value and get the component to display that
variable using the same syntax, where I reference the source
component like: {datebar.myvar} so I know the namespace referene
works.
Admittedly I'm not a very good ActionScripter... -
AdvancedDataGrid with HTTPService
Hi All,
I have problem with AdvancedDataGrid by using
HTTPService.Actually i don't know how to get the data from xml file
and display in AdvancedDataGrid but i know how to get the data from
xml file and display in DataGrid.
Here XML file structure is different.......
How to get and display the data in AdvancedDataGrid.If u have
a example please send it to me.
here am posting my code.....
MXML code ..................
<?xml version="1.0"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
creationComplete="salesRequest.send();">
<mx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
import mx.rpc.events.ResultEvent;
[Bindable] public var salesDP:XMLListCollection;
private function salesResultHandler(event:ResultEvent):void{
salesDP = new XMLListCollection(event.result.Category);
]]>
</mx:Script>
<mx:HTTPService id="salesRequest" useProxy="false"
resultFormat="e4x"
result="salesResultHandler(event)" url="adg.xml"/>
<mx:AdvancedDataGrid width="100%" height="100%">
<mx:dataProvider>
<mx:HierarchicalData source="{salesDP}"/>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="@Category"
headerText="Category"/>
<mx:AdvancedDataGridColumn dataField="@Product"
headerText="Product"/>
<mx:AdvancedDataGridColumn dataField="@InStock"
headerText="In Stock"/>
<mx:AdvancedDataGridColumn dataField="@OnOrder"
headerText="On Order"/>
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Application>
XML file........
<?xml version="1.0″ encoding="utf-8″ ?>
<Category Category="Poultry">
<Category Category="Chicken">
<Product Product="skinless breasts"
InStock="565 lbs" OnOrder="1000 lbs"/>
<Product Product="thighs"
InStock="385 lbs" OnOrder="700 lbs"/>
<Product Product="nuggets"
InStock="230 lbs" OnOrder="400 lbs"/>
</Category>
<Category Category="Turkey">
<Product Product="whole turkeys"
InStock="1565 lbs" OnOrder="2000 lbs"/>
<Product Product="turkey burger"
InStock="1365 lbs" OnOrder="1200 lbs"/>
<Product Product="turkey ham"
InStock="640 lbs" OnOrder="700 lbs"/>
</Category>
</Category>
Thanks in advance,
Premadas.See my Flex Cookbook post:
Populating
an AdvancedDataGrid from an XML file using HTTPService
Or see my blog post, which seems like where you got the data
anyway:
Using HTTPService to
Populate an AdvancedDataGrid -
Tree Doesnt populate the whole data with HTTPService request
Hi,
I am working with the tree control which populates the tree
with the HTTPService request.
Step1. Make a HTTPService Request and fetch the top level
entries.
Step2. When ever the user opens an treeItem by clicking on
the Triangular icon besides the tree item
Make a HTTPService, fetch the data, on the callback method
append the Datasource with the new data for the item to open.
problem is the tree branch gets populated with partial data
instead of the full data where as the DataSource has the full data.
Step3. when ever the user clicks on the item
Make a HTTPService, fetch the data, on the callback method
append the Datasource with the new data for the item to open.
Now the tree item gets populated with the correct data.
tried every thing to refresh the tree....private function refreshTree():void{
tree.expandItem(rootNode, false);
tree.expandItem(rootNode, true);
this helped -
Hi there, I have developed an application that has a Buy Now
Button to the PayPal website. I used the HTTPService to verify the
purchased at PayPal:
<mx:HTTPService id="paymentRequest" url="
http://www.paypal.com/cgi-bin/webscr"
useProxy="false"
method="POST" resultFormat="text"
result="getResultOk(1,event)" fault="getResultOk(0,event)"
showBusyCursor="true">
<mx:request xmlns="">
<cmd>_notify-synch</cmd>
<tx>{tx.toString()}</tx>
<at>{at.toString()}</at>
</mx:request>
</mx:HTTPService>
When this application web site is redirected back from the
PayPal shopping cart, a tx number is read and the application calls
paymentRequest.send() to do the verification process but then i got
this error:
Error sending data!!
[FaultEvent fault=[RPC Fault faultString="Security error
accessing url"
faultCode="Channel.Security.Error" faultDetail="Destination:
DefaultHTTP"]
messageId="E46E9181-EA3E-8B41-5869-62767B67BD60"
type="fault" bubbles=false cancelable=true eventPhase=2]
However, if i hard coded the tx number and execute the
application locally, it works fine it is sending to PayPal and i do
get either the "SUCCESS" or "FAIL" message back... So i wonder if
anyone can please help me here? Why when this application is put on
web server and being accessed from the server's url the HTTPService
call is not sending??
Many thanks.
RichieHi Richie,
your application can only access data from servers, which
allow access per crossdomain.xml or from your server. That´s a
security thing which comes with the flash player. ( if paypal
didn´t allow access to their content your can´t access )
The flexbuilder/debug enviroment runs in a trusted sandbox,
which allows access. This is a big different between the debug and
the release enviroment, which should at least be made configurable
by Adobe (for the flex builder).
best regards,
kcell -
Strungling with HttpService and web page.
Hello all,
I'm testing the httpService with flex 4.
I try to access a web page that is an ashx page that returns an xml, the content type of the page is application/xml.
From my mxml view I use this script to get the data:
protected function findByName(name:String):void{
srv.send();
<s:HTTPService id="srv"
url="http://xx.xx.xx.xx/FlexHttpBinding/getemployees.ashx"
result="data=srv.lastResult.list.employee"
method="POST"
contentType="application/xml"
/>
I did setup the IIS7 website to accept anonymous access, so that should be ok.
With this I get the error: 2032Stream Error.
The url is correct so no idea what happens here.
Any ideas ?Hi peart!
I have not installed it either. I have tried with several compressed files:
eclipse-jee-europa-linux-gtk.tar.gz
wtp-all-in-one-sdk-R-2.0-200706260303-linux-gtk.tar.gz
eclipse-SDK-3.3-linux-gtk.tar.gz. After extracts I update and installs WTP.
All ways fails.
Too try add "-Djava.library.path=.:/home/pilli/eclipse:/usr/share/java/swt" eclipse.ini file.
I can works with jsp file with jsp editor, but when i try edit with web page editor, a jsf visual editor, eclipse breaks.
I use KDE.
Thanks! -
Problem with httpservice.length
Hi,
I have written a httpservice which will return a dataset to
me, now i am trying to loop that http service i have written the
below code
<mx:httpservice id="something" url="........default.aspx"
/>
var i:int = 0
for (i = 0;
i<something.lastresult.newdataset.table.length; i++)
if there is only one record in the httpservice then it is
giving me the result as null and if there are 2 records if is
displaying only 1 row
can anybody find me a solution for this problem
regards
RajeevYou can find string length first. Subtract length by 4, Then use like new = str+4(len), use condense if required.
-
Columnchart with horizontal line representing setpoint
Hi,
I have a simple column chart. I want to be able to draw a single thin line horizontally across the chart to represent a setpoint. How can I accomplish this?
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{Month:"Jan", Profit:2000, Expenses:1500},
{Month:"Feb", Profit:1000, Expenses:200},
{Month:"Mar", Profit:1500, Expenses:500}
]]></mx:Script>
<mx:Panel title="Column Chart">
<mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis
dataProvider="{expenses}"
categoryField="Month"
/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries
xField="Month"
yField="Profit"
displayName="Profit"
/>
<mx:ColumnSeries
xField="Month"
yField="Expenses"
displayName="Expenses"
/>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{myChart}"/>
</mx:Panel>
</mx:Application>
Thanks in advanceThanks, I thought of that but...This line needs to span the width of the graph at all times. also it will be a variable passed in and I want the line to rise or fall across the entire graph based on that value, like a gridline.
Maybe you are looking for
-
Is it a Bug in ORACLE 8i????
I am using Oracle 8.1.7(Japanese) on Win2k professional (Japanese) and developing a multilingual application. * I have some columns of NVARCHAR2 datatype. * NLS_Lang entry of registry is right now NA. * Database procedures When i use insert or any ot
-
Adobe Acrobat XI Miniaturseiten einbetten?
Hallo, wir erstellen PDF-Dateien-Zusammenstellungen aus verschiedenen Quellen, zumeist Pläne, die gescannt oder vektorisiert sein können. Diese Dateien können schon des Öfteren 500MB bzw. 100 Pläne überschreiten. Über die Seitenminiaturen kann man ei
-
%iowait is more than 50 always in TOP. What is the reason?
Dear All, In my server i have 2 databases APAC and AIX. In my top command the iowait % is more than always. So how can i find which DB casuing this and from which session this IO wait is happening. Please let me know how to tune to reduce this IO wai
-
Acrobat creating searchable image PDF
I have a PDF made from images of a set of scanned pages; I also have the text of those pages in a Word document. I could make a searchable PDF of the images by using Acrobat's OCR and correction tools, but this would be a long and imprecise process
-
"Primitive Type Returned", when I try to configure the data return type.
I am basically following this tutorial, Getting started with ColdFusion and Flash Builder 4 beta, but instead of using the database provided, I am using SQL Server 2008. I am now stuck on the part titled, "Configuring the data return type". In step