Using Repeater to generate dynamic line charts

I have a call to a webservice that returns an array of
arrays. The outside array relates to the "YEAR", and the inside
arrays have 1 element for each "MONTH". I want to create a line
chart that has a line for each year, with the x-axis having months
across the bottom.
I can create this just fine by coding the appropriate number
of mx:LineSeries tags in my code.
However, I have a case where the data that I get back from
the webservice could have up to 5 years (I'm only coding for 3).
So, I'd like to find a way to dynamically generate an mx:LineSeries
instance for each one of these years. I can't seem to get this to
work with using a Repeater.
This code isn't mine (got it from the docs), but it matches
with what i'm trying to do exactly:
<?xml version="1.0"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.charts.events.ChartItemEvent;
import mx.collections.ArrayCollection;
[Bindable]
public var expenses_2005:ArrayCollection = new
ArrayCollection([
{Year: 2005, Expense: "Taxes", Amount: 2000},
{Year: 2005, Expense: "Gas", Amount: 100},
{Year: 2005, Expense: "Food", Amount: 200}
[Bindable]
public var expenses_2006:ArrayCollection = new
ArrayCollection([
{Year: 2006, Expense: "Taxes", Amount: 2500},
{Year: 2006, Expense: "Gas", Amount: 400},
{Year: 2006, Expense: "Food", Amount: 300}
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
expenses_2005,
expenses_2006
]]></mx:Script>
<mx:LineChart dataProvider="{expenses}"
showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{expenses.getItemAt(0)}"
categoryField="Expense" title="Expense"/>
</mx:horizontalAxis>
<mx:verticalAxis>
<mx:LinearAxis displayName="Amount"/>
</mx:verticalAxis>
<mx:series>
<mx:LineSeries xField="Expense" yField="Amount"
displayName="2005" dataProvider="{expenses.getItemAt(0)}"/>
<mx:LineSeries xField="Expense" yField="Amount"
displayName="2006" dataProvider="{expenses.getItemAt(1)}"/>
</mx:series>
</mx:LineChart>
</mx:Application>
How can I now change this to dynamically build the necessary
numbers of LineSeries?

Hi jsevlie,
What I usually do in this case is to create multiple
LineSeries objects in ActionScript as soon as I get in the data.
Here is some code to get you started:
private var theChart:ColumnChart = new ColumnChart;
function drawGraph(){
this.theChart.dataProvider = this.theData;
var ctgAxis:CategoryAxis = new CategoryAxis();
ctgAxis.dataProvider = this.theData;
ctgAxis.categoryField = "0";
this.theChart.horizontalAxis = ctgAxis;
var series:Array = new Array();
for(var i:int=0; i < this.columnSpan; i++){
var colSeries:ColumnSeries = new ColumnSeries();
colSeries.yField = String(i+1);
if(i==0){
colSeries.displayName = "Revenue";
colorSrs(colSeries, 0x3F48F3);
else if(i==1){
colSeries.displayName = "Profit";
colorSrs(colSeries, 0xE9C836);
else{
colSeries.displayName = "Cost";
colorSrs(colSeries, 0x6FB35F);
series
= colSeries;
this.theChart.series = series;

Similar Messages

  • Dynamic Line chart

    Hi every one,
    me new to flex,
    i want to know one thing that can we make line chart to be
    varied dynamically such that it must varie just like in task
    manager the cpu history line varies ,if its possible please give me
    an idea or any code if possible.
    Thanking u,
    namala.

    Hi,
    thanks for the reply,i did the application,i have attached a
    timer to the chart function ,its working fine but whats happening
    is that my application is getting shrinked when more and more
    values are added to it,But my requirement is that my application
    should not shrink,im attaching the code ,please let me know any
    modification that i should do,
    or get me some code.

  • How to create dynamic line chart ?

    Dynamically create line on that graph.if select more than one values from multi select box , it will get id and execute query , draw the one more line on that graph.
    For example:
    oracle
    mysql
    sybase
    SQL server
    These are values in multiselect box.
    Now open the page with default value and show one line on the graph.Now i am going select another one values on multi select box.
    dynamically create another line on the same graph.
    How to do this graph ?

    jsf_VWP5.5.1 wrote:
    Any options in jasper reports ?Since when did jasper reports come into the picture?
    In any case, why don't you ask them, then? They should have some sort idea about it, I would think.

  • How to make use of a different data model for a line chart?

    I have a datamodel which is a sql query. I have a line chart on my template which is using some "Start Time" field as X-Axis. There is a chance that "Start Time" is null. In such cases the plotted point doesn't appear with x-coordinate. But I can't change the X_Axis field to some other not-null attribute due to business requirement.
    I am thinking to create another datamodel which filters all "Start Time"s which are nulls and use that datamodel for the line chart that has "Start Time" as X-axis. But I don't know how to do this as whenever I try to insert a line chart from BIPublisher menu in MS_Word, I am not prompted to select the datamodel.
    Can anybody tell me what I am trying is possible? If so how? If not, how do I have "Start Time" as X-axis without hassles?
    Thanks,
    -Vijay-

    Are you able to extract the data based on the new data model in an XML file? If so, in BI publisher desktop, are you able to load the XML data via Add-Ins ->Data -> Load XML Data?
    If you have been able to load the data successfully, then you need to Select Chart from the Insert Menu. When you do that, you should be able to see the Data layout on the left side of the chart dialog box. Then you should be able to drag and drop fields as necessary to create the chart. Are you having issues doing this part?
    You will not be prompted to select the data model. Hope I haven't misunderstood your question.
    Thanks!

  • Line chart in jsp

    Hai,
    i want to generate a line chart in jsp. can you plz help on this.
    plz dont suggest me any third party tools.
    Thanks in advance.

    Hai,Hie
    i want to generate a line chart in jsp. can you plz
    lz help on this.Yes.
    plz dont suggest me any third party tools.I can and I will: JFreeChart ;-P
    You don't want to use it, that's your perogative, but you'd have to write something yourself. Why would you want to do that when you can just use something that exists? Do you build your own cars from scratch?
    Thanks in advance.you're welcome in retrospect

  • Line chart with 2 different y axis

    hi,
    i have a question on line chart in apex. i'm using apex 4.2. is it possible to generate a line chart with 2 different y axis? here's a sample data to illustrates what i'd like the chart to look like.
    date price percent
    1/1 1 100
    1/2 2 90
    1/3 3 80
    1/4 4 70
    the x-axis will be the date column. the left y-axis would be the price column. and the right y-axis would be the percent column.
    i know i can plot multiple lines in a chart thru different series. but they're based on the same x and y axis range. thanks
    jim

    You beat me to it.
    One of the problems I'm having is that the begining and ending point(s) coincide. So, instead of two completely separate lines, I have an area bounded by the series 1 line on top and the series 2 line on the bottom. Since the points overlay, the values of those points also display one on top of the other. I'll have to see if there is a way to separate the series. I've had 3 separate series before, but never with two y-axis.
    Regards,
    Howard

  • Help! extremely small labels in Line Chart

    Hi all,
    I met a problem that i've been working on for a long time.
    If the SQL returned too many rows (e.g. 200+) to generate the Line Chart, the X/Y axis Labels would be too small to be recognised.
    I tried whatever i can imagine, like generating much fewer labels in the PL/SQL and using a font-size 30+...
    So far, so bad.
    Any suggestion???
    Thanks you so much!!!!

    Hi,
    Actually, there are many possible causes for this issue. Could you please tell me how the category labels come from? In other words, why are they all
    the same? I would like to suggest you post some sample data and your chart settings here. I have created a report with chart which has duplicate horizontal axis labels. To achieve your purpose, I hide all horizontal axis labels, and then use horizontal axis
    title instead of horizontal axis labels. I have uploaded my report as an example:
    With duplicate horizontal axis labels:
    http://cid-854fa6d2b7d88cc7.office.live.com/self.aspx/Work/Old.rdl
    No duplicate horizontal axis labels:
    http://cid-854fa6d2b7d88cc7.office.live.com/self.aspx/Work/New.rdl
    If there is anything unclear, please feel free to ask.
    Thanks,
    Albert Ye

  • Creating a multi series line chart with different data providers

    I have 3 data providers of the same structure i.e ArrayCollection of DataElement and want to use them to create a multiseries line chart. I do not have just 1 dataProvider that can be used but 3 different data providers of the same structure that i want to use each for different series.
    [Bindable] private var orangeSales : ArrayCollection =
                    new ArrayCollection(
                        [ { sales: 101000, month: new Date( '01/01/2008' ) },
                            { sales: 960000, month: new Date( '02/01/2008' ) },
                            { sales: 475000, month: new Date( '03/01/2008' ) },
                            { sales: 425000, month: new Date( '04/01/2008' ) }
                [Bindable] private var appleSales : ArrayCollection =
                    new ArrayCollection(
                        [ { sales: 991000, month: new Date( '01/01/2008' ) },
                            { sales: 140000, month: new Date( '02/01/2008' ) },
                            { sales: 565000, month: new Date( '03/01/2008' ) },
                            { sales: 255000, month: new Date( '04/01/2008' ) }
                [Bindable] private var bananaSales : ArrayCollection =
                    new ArrayCollection(
                        [ { sales: 891000, month: new Date( '01/01/2008' ) },
                            { sales: 147560, month: new Date( '02/01/2008' ) },
                            { sales: 295000, month: new Date( '03/01/2008' ) },
                            { sales: 574000, month: new Date( '04/01/2008' ) }
    I want to create a line chart with orangeSales, appleSales and bananaSales as three different lines on the chart for different dates specified.
    <mx:ColumnChart showDataTips="true" >
            <mx:horizontalAxis>
                <mx:CategoryAxis
                    dataProvider="{orangeSales}"
                    categoryField="month"
                    />
            </mx:horizontalAxis>
            <mx:series>
                <mx:LineSeries displayName="OrangeSales" yField="sales" xField="month" dataProvider="{orangeSales}"/>
                <mx:LineSeries displayName="AppleSales" yField="sales" xField="month" dataProvider="{appleSales}"/>
                <mx:LineSeries displayName="BananaSales" yField="sales" xField="month" dataProvider="{bananaSales}"/>
            </mx:series>
    </mx:ColumnChart>
    Please help!

    Sorry for the confusion. Actually I must be doing some thing wrong like using ColumnChart to display a line chart or something like that.
    I have now realized that a multi series line chart can be built by having a different data provider for each of the LineSeries object.
    So the code below would create a multi series line graph :
    [Bindable] private var orangeSales : ArrayCollection =
                    new ArrayCollection(
                        [ { sales: 101000, month: new Date( '01/01/2008' ) },
                            { sales: 960000, month: new Date( '02/01/2008' ) },
                            { sales: 475000, month: new Date( '03/01/2008' ) },
                            { sales: 425000, month: new Date( '04/01/2008' ) }
                [Bindable] private var appleSales : ArrayCollection =
                    new ArrayCollection(
                        [ { sales: 991000, month: new Date( '01/01/2008' ) },
                            { sales: 140000, month: new Date( '02/01/2008' ) },
                            { sales: 565000, month: new Date( '03/01/2008' ) },
                            { sales: 255000, month: new Date( '04/01/2008' ) }
                [Bindable] private var bananaSales : ArrayCollection =
                    new ArrayCollection(
                        [ { sales: 891000, month: new Date( '01/01/2008' ) },
                            { sales: 147560, month: new Date( '02/01/2008' ) },
                            { sales: 295000, month: new Date( '03/01/2008' ) },
                            { sales: 574000, month: new Date( '04/01/2008' ) }
    I want to create a line chart with orangeSales, appleSales and bananaSales as three different lines on the chart for different dates specified.
    <mx:ColumnChart showDataTips="true" >
            <mx:horizontalAxis>
                <mx:CategoryAxis
                    dataProvider="{orangeSales}"
                    categoryField="month"
                    />
            </mx:horizontalAxis>
            <mx:series>
                <mx:LineSeries displayName="OrangeSales" yField="sales" xField="month" dataProvider="{orangeSales}"/>
                <mx:LineSeries displayName="AppleSales" yField="sales" xField="month" dataProvider="{appleSales}"/>
                <mx:LineSeries displayName="BananaSales" yField="sales" xField="month" dataProvider="{bananaSales}"/>
            </mx:series>
    </mx:ColumnChart>

  • CHART BUILDER ERROR WHEN TRYING TO GENERATE DYNAMIC CHARTS ON A JSP PAGE

    I'm working with J Develop 9.03 on Windows 2000 Professional Edition.
    I'm using the JSP demo files provided with Oracle Chart Builder to generate
    dynamic charts. The user specifies the query parameters, including the date
    range and the query results are returned by means of a line chart (with date on
    the x axis and values on the y axis).
    When trying to compile the project I get the following error messages:
    Error(165,2): class FileOutputStream not found in class _graph
    Error(170,5): class File not found in class _graph
    Error(176,4): exception java.io.IOException is never thrown in the
    corresponding try block
    I checked to see that the chartbuilder library (chartbuilder.jar) files are
    loaded into the project library. It's unusual that the class is not being
    found. I don't understand why. I developed my project using the following steps:
    1. Unzipped Chart Builder installation files into c:\Oraclechartbuilder
    2. Loaded chartbuilder class library
    c:\Oraclechartbuilder\chartbuilder\lib\chartbuilder.jar into J Developer class
    path (by selecting <Project Settings> <Paths> and browsing to the
    chartbuilder.jar file).
    3. Created a new JSP page in J Developer (graph.jsp)
    4. Copied JSP code syntax from the Word Pad demo file and pasted into graph.jsp
    5. Changed the DB connection parameters and static directory location on the
    JSP page.
    6. Compiled the project and received the above errors.
    I would like to know why the classes are not being found and how to fix the problem. Thanks, Jaafar

    Hi mshah101,
    This can happen if the applet is compiled using an higher version of java and the browser is pointing to an older version (even if minor version number is higher)

  • Line chart and vertical line repeats according period

    Hej,
    I have line chart and horizontal axis displays many months, thus is possible to vertical line from horizontal axis be displayed after years period and be color diferent?? My example, start displays January 2007,......finish December2007->DISPLAY VERTICAL LINE as LONG TICK, start January2008....and so on... is possible to set such repeater for line chart...thank for response.

    Hi 1234alex,
    According to your description, you want to create a non-vertical target line in top of bar chart to show different target.
    In Reporting Services, it’s impossible to create a non-vertical target line in top of bar chart. Because StripLines can only return a vertical target line even we put expression to make it dynamically . In this scenario, we can show the target line as values
    and use switch() function to specify different values based on different category. Then we just need to change the chart type for that series only. However, it only support horizontal line chart type in Reporting Services, so we suggest you use column chart
    instead of bar chart. Please refer to detail steps below:
    1. On Chart Data region, set an expression looks like:
         =switch(Fields!month.value=”A”,”4”,
         Fields!month.value=”B”,”8”, 
         Fields!month.value=”C”,”2”,
         Fields!month.value=”D”,”5”)
    2. Right click expression in Chart Data region, choose Change Chart type, select a line chart.
    3. Click Preview, the results look like:
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu

  • Dynamic change color of series in line chart

    Hi
    I would like to be able to dynamically change the color of the individual series in a line chart, based on user preference. It works excellent having dynamic labels on the series using the &item. syntax and a before header computation.
    The same approach for the color does not seem to work. I get errors like undefined entity....
    Any ideas?
    Best regards Jesper

    Very surprisingly the following code (also generated by the macro recording) works ok.
    (I selected the serie inside the chart instead of selecting the serie in the legend)
        ActiveChart.FullSeriesCollection(1).Select
        With Selection.Format.Fill
            .Visible = msoTrue
            .ForeColor.ObjectThemeColor = msoThemeColorAccent3
            .ForeColor.TintAndShade = 0
            .ForeColor.Brightness = -0.25
            .Transparency = 0.3000000119
            .Solid
        End With
    If an MVP or Microsoft official come accross this, I suggest further testing as it is very likely a bug (with the first set of code generated by Excel)

  • How to dynamically add new line series to the line chart in flex?

    i need to add line series dynamically..and each line  series should have a different data provider...

    A chart can have only 1 dataProvider which in my case is an ArrayCollection.
    The chart will update every time the dataProvider changes if you use binding.
    So you have to write a function that periodically populates the ArrayCollection with data from the server and the chart will update automatically.
    'Using line charts' tutorial from Adobe: http://livedocs.adobe.com/flex/3/html/charts_types_08.html#243339

  • How to Generate Chart (line chart, bar chart)!

    I want to generate Graphic Chart using Java,(e.g. line chart, bar chart).
    Is any Class can easy to generate Chart??
    thanks!

    petes1234 wrote:
    meacod wrote:
    Dimpu wrote:
    i need the source code how to generate the graphs using the Java
    Give me teh codes?
    And yes, this thread is old.Also note how the poster here politely requests help along with the use of the word "please". Very instructive. He'll get far here.Indeed, you are wise in the ways of the fool **bows politely**

  • Transforming XML data into SVG line charts using XSLT

    Hi
    I am trying to transform revenue data from an XML file into an SVG line chart. The problem is that I am quite new to XPath and XSLT and whereas I can draw the grid for my chart I struggle drawing the lines using the data from the XML doc.
    The XML look something like the one below, and I would like to have one chart for each product and in each chart having the time on the x-axis and chart the revenue by regions.
    Any help on this is much appreciated.
    Thanks
    Peter
    <?xml version="1.0"?>
    <revenue>
    <caption>
    <heading>My title</heading>
    </caption>
    <date name="01/01/2003">
    <region name="Asia">
    <product_a>30</product_a>
    <product_b>12</product_b>
    <product_c>301</product_c>
    </region>
    </date>
    <date name="02/01/2003">
    <region name="Asia">
    <product_a>32</product_a>
    <product_b>12</product_b>
    <product_c>301</product_c>
    </region>
    <region name="America">
    <product_a>57</product_a>
    <product_b>31</product_b>
    <product_c>457</product_c>
    </region>
    </date>
    <date name="03/01/2003">
    <region name="Asia">
    <product_a>38</product_a>
    <product_b>12</product_b>
    <product_c>301</product_c>
    </region>
    <region name="America">
    <product_a>31</product_a>
    <product_b>9</product_b>
    <product_c>357</product_c>
    </region>
    </date>
    <date name="04/01/2003">
    <region name="Asia">
    <product_a>33</product_a>
    <product_b>12</product_b>
    <product_c>301</product_c>
    </region>
    <region name="America">
    <product_a>43</product_a>
    <product_b>16</product_b>
    <product_c>430</product_c>
    </region>
    </date>
    <date name="05/01/2003">
    <region name="Asia">
    <product_a>36</product_a>
    <product_b>12</product_b>
    <product_c>301</product_c>
    </region>
    <region name="America">
    <product_a>54</product_a>
    <product_b>1</product_b>
    <product_c>561</product_c>
    </region>
    </date>
    </revenue>

    You could try Jeni's XSLT utilities for SVG :
    http://www.jenitennison.com/xslt/utilities/svg-utils.html
    Specifically, the sample code provided, when a couple of SVG charts are being generated from XML data :
    http://www.jenitennison.com/xslt/utilities/svg-example.html
    Hope that helps.

  • Using SQVI to generate report of open and released delivery schedule lines

    All,
    I'm using SQVI  to generate an excel spreadsheet for some buyers to show open released schedule lines because they are a 1 line item per scheduling agreement company.
    I used the logical database MEPOLDB instead of a table joint and pulled fields from EKKO(vendor, SA #,&purchasing group), EKPO(Material Number), EKEH(schedule line type), and EKET(delivery date, scheduled qty,previous qty).
    Does this sound like I'll get the results I want on paper as long as I use the right selection criteria, because the report I'm getting isn't quite what I expect? I am unable to identify which lines are authorized to ship vs. trade-off zone, planning, etc. in the report thus far.

    Hi Mark,
                 I have faced same requirement. I am not sure about transporting to TST and PROD. I done by this way.
    After generating SQVI program in DEV , I assigned that program  to a transaction and tested in DEV. Later i have regenarated SQVI in Production. then I assigned the generated Program to same transaction in DEV. And transported the Tcode assignment of program to Production..
    About authorization , if its not sensitive report, BASIS can restrict at transaction level.
    Regards,
    Ravi.

Maybe you are looking for