Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   Flex (http://www.flasher.ru/forum/forumdisplay.php?f=84)
-   -   График с данными с сервера (http://www.flasher.ru/forum/showthread.php?t=132962)

locust19 24.11.2009 13:58

График с данными с сервера
 
Я совсем новичек. и меня шеф пригружает.

Нужно установить соединение с сервером и считать данные(c php), после чего встроить их в график..
накидайте коротко пример.

Спасибо

iflamberg 24.11.2009 14:38

ахренеть, "накидайте коротко пример".
Загружаем результат выполнения php-скрипта c помощью URLLoader. Строим график с помощью degrafa или другой библиотеки. Если есть конкретные вопросы - гуглим, если ответ не найден - задаем на форуме.

locust19 24.11.2009 15:15

вот сам график.. как указать путь на сервер с php и считать цыфры. к примеру
Дата 20.11.2009 Посетителей 983

Код:

<mx:Panel title="Column Chart" x="10" y="10">
    <mx:ColumnChart id="myChart" showDataTips="true">
      <mx:horizontalAxis>
          <mx:CategoryAxis
              dataProvider="{expenses}"
              categoryField="Date"
          />
      </mx:horizontalAxis>
      <mx:series>
          <mx:ColumnSeries
              xField="Date"
              yField="user"
              displayName="user"
          />

      </mx:series>
    </mx:ColumnChart>
    <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
</mx:Application>


iflamberg 24.11.2009 15:37

Тебе нужно использовать HTTPService.

и поставь себе tour de flex
- там куча примеров и с чартингом и с загрузкой данных из вне.

locust19 24.11.2009 15:42

спасибо

Добавлено через 2 часа 27 минут
всеравно не получается что неправильно?

Код:

<?xml version="1.0"?>
<!-- charts/BasicColumn.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">


  <mx:HTTPService id="httpRSS" url="http://localhost/andre/text.php">
</mx:HTTPService>
       

  <mx:Panel title="Column Chart">
    <mx:ColumnChart id="myChart" dataProvider="{httpRSS.lastResult.Catalog.MonthId}" showDataTips="true">
      <mx:horizontalAxis>
          <mx:CategoryAxis dataProvider="{Besucher}" categoryField="Month"/>
      </mx:horizontalAxis>
      <mx:series>
          <mx:ColumnSeries
              xField="Month"
              yField="Besucher"
              displayName="Besucher"
          />

      </mx:series>
    </mx:ColumnChart>
    <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>

       
</mx:Application>

Код:

<?xml version="1.0" encoding="utf-8"?>

<Catalog>
<Month MonthId="Jan">
<Besucher>10</Besucher>
</Month>
<Month MonthId="Feb">
<Besucher>100</Besucher>
</Month>
<Month MonthId="Mar">
<Besucher>50</Besucher>
</Month>
</Catalog>


fljot 24.11.2009 19:04

Код AS3:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        applicationComplete="init()">
 
        <mx:Script>
                <![CDATA[
                        private function init():void
                        {
                                httpRSS.send();
                        }
                ]]>
        </mx:Script>
 
 
  <mx:HTTPService id="httpRSS" url="assets/flasher_data.xml" resultFormat="e4x" />
 
  <mx:Panel title="Column Chart">
    <mx:ColumnChart id="myChart" dataProvider="{httpRSS.lastResult.Month}" showDataTips="true">
      <mx:horizontalAxis>
          <mx:CategoryAxis dataProvider="{myChart.dataProvider}" categoryField="@MonthId"/>
      </mx:horizontalAxis>
      <mx:series>
          <mx:ColumnSeries
              xField="@MonthId"
              yField="Besucher"
              displayName="Besucher"
          />
 
      </mx:series>
    </mx:ColumnChart>
    <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
 
 
</mx:Application>


locust19 24.11.2009 20:27

ну все равно не работает. Совсем ума не приложу Скрипт для чтения есть. все вроде на своем месте-- А скрипт запустить не надо отдельно с таблицы?

Добавлено через 15 часов 41 минуту
Говорит, что невыходит соединить данные?! "Data binding will not be able to detect assignments to "dataProvider"."

на эту строку
Код:

<mx:CategoryAxis dataProvider="{myChart.dataProvider}" categoryField="@MonthId"/>
Бред - у людей работает у меня нет. я наконец-то нашел более подобный пример и справился с ним:confused:

Код:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="testData.send()">
        <mx:Script>
                <![CDATA[
                import mx.rpc.events.ResultEvent;
               
                //XML List for loaded XML file. Must be bindable!
                [Bindable]private var testInfo:XMLList;
               
                private function xmlHandler(evt:ResultEvent):void{
                        //Sets testInfo's root as the student. Everything else referenced in respect to this.
                        testInfo = evt.result.Monat;
                }
               
                private function changeData(dataSet:String):void{
                        //Determine which set should be loaded
                        switch (dataSet){
                                case ('set1'):
                                        //Set URL target to Test Data 1
                                        testData.url ="statistic.xml";
                                        break;
                                default:
                                        //If somehow it's neither, just leave it be
                                        break;
                        }
                        //Send out new URL Request to refresh chart
                        testData.send();
                }
               
                ]]>
        </mx:Script>
       
        <!--Effect for when chart data changes-->
        <mx:SeriesInterpolate id="changeEffect" duration="2000"/>
       
        <!--Loads the url an XML file and then sends it to the xmlHandler function in E4X format-->
        <mx:HTTPService url="assets/test-data.xml" id="testData" result="xmlHandler(event)" resultFormat="e4x"/>
               
        <!--Contains page components. Design only-->
        <mx:VBox horizontalAlign="center">
               
                <!--Panel effects design only-->
                <mx:Panel horizontalAlign="center" title="College Test Score Data">
                       
                        <!--The Chart 'testChart'-->
                        <mx:ColumnChart dataProvider="{testInfo}" id="testChart" showDataTips="true">
                                <mx:horizontalAxis>
                                        <mx:CategoryAxis dataProvider="{testInfo}" categoryField="name"/>
                                </mx:horizontalAxis>
                                <mx:series>
                                        <mx:ColumnSeries showDataEffect="{changeEffect}" xField="name" yField="anzahl" displayName="Besucheranzahl"/>
                                </mx:series>
                        </mx:ColumnChart>
                       
                        <!--Display Controls-->
                        <mx:HBox height="30" horizontalAlign="center">
                                <mx:Button  label="Ansehen" click="changeData('set1')"/>
                        </mx:HBox>
                       
                </mx:Panel>
               
                <!--Legend for Chart Data-->
                <mx:Legend dataProvider="{testChart}"/>
               
        </mx:VBox>
       
</mx:Application>

Код:

<?xml version="1.0" encoding="utf-8"?>
<statistik>
        <Monat>
                <name>Jan</name>
                <anzahl>1350</anzahl>
        </Monat>
        <Monat>
                <name>Feb</name>
                <anzahl>1000</anzahl>
        </Monat>
        <Monat>
                <name>Dec</name>
                <anzahl>1200</anzahl>
        </Monat>
</statistik>



Часовой пояс GMT +4, время: 21:54.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.