Arraycollection conversion to chart data

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Arraycollection conversion to chart data

    I'm trying to get ArrayCollection mapped to an array using the Blazeds turnkey
    sample code. In the sqladmin example, they are creating a List object in the
    Java code by executing the SQL query and storing it like this:

    // relevant code...

    while (rs.next()) {
    row=new HashMap();
    for (int i = 1; i <= colCount; i++) {
    row.put(rsmd.getColumnName(i), rs.getString(i));
    }
    list.add(row);
    }
    }

    Then they put this result in a dataGrid:

    <mx:DataGrid id="dg" dataProvider="{resultSet}" width="100%" height="100%"/>

    and the following method.

    private function resultHandler(event:ResultEvent):void {
    resultSet = ArrayCollection(event.result);
    }

    I'd like to display the same data in a chart, but I don't know how to do this.
    What I'd like to do is something like this:

    //pseudo code
    Horizontal Axis (x) = Data from Column 1
    Vertical Axis (y) = Data from Column 2

    ..or something like that. Anyone know what class the HashMap/List is sending
    back so that I can convert the info into Dates or numbers or somethow get it to
    show up on the chart?

    I was trying something like this, but it doesn't work:

    var axisArray:ArrayCollection = new ArrayCollection;
    for each (var obj:Object in resultSet) {
    var f:Number = new Number(obj);
    result.addItem(f);
    }
    // axis data provider = axisArray




    Solerous Guest

  2. Similar Questions and Discussions

    1. Refreshing chart data doesnt update chart
      I must be missing something simple here. I have a column chart that is using an array for its dataprovider. However, when I update the underlying...
    2. MS Excel Chart Conversion problem
      I have used "Paste Special" then Paste as a Picture (Metafile) to insert Excel charts into a number of MS Word documents. PDF files are being created...
    3. Pantone colors to RGB conversion chart or palette?
      What is the best method to get the RGB color equivalent numbers from a Pantone color/number. Is clicking on a Pantone color from a palette/swatch...
    4. 012 and 015 eq \r and\n on what conversion chart?
      tr/\012\015//d; So a while back ago, there was someone kind enough to pass me the above snippet of code, which removes returns and newlines from...
    5. RBG to CMYK Conversion Chart
      Not to mention that there are 16.7 *million* colors possible in RGB. That would be some long "chart" :-) Mac
  3. #2

    Default Re: Arraycollection conversion to chart data

    You need to add series to your chart and then assign the data to the series.

    I recommend looking at
    [url]http://www.quietlyscheming.com/blog/charts/chart-sampler/[/url]

    and the charting documentation and examples.

    Thanks,
    Gaurav

    Gaurav J Guest

  4. #3

    Default Re: Arraycollection conversion to chart data

    yes, it seems that I was messing up in assigning the results to the various
    axis definitions. I assumed the data wasn't there, but it really was. I
    didn't need this loop at all:

    var axisArray:ArrayCollection = new ArrayCollection;
    for each (var obj:Object in resultSet) {
    var f:Number = new Number(obj);
    result.addItem(f);
    }

    just assigning the data correctly:

    series1.dataProvider = resultSet;
    series1.xField="TIME";
    series1.yField="VALUE";

    Thanks for the help!


    Solerous Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139