Charts with their own hands – Open Flash Chart 2
Ob This library I had told (Open Flash Chart – construct graphs). But since then, nearly 8 months and during this time many new version of the library izmenilos. Vyshla Open Flash Chart 2 and it is quite seriously different from the first version. Explain the reasons for introducing the changes, I will not simply quote avtora. Open Flash Chart 1.x was great and worked well. But I made some small mistakes, which over time grew, I became irritated and made the source code is terrible. So I decided that it was time to rewrite the code again and make it beautiful. Now, as the data format used by JSON. This has led to significant changes, and allowed to implement several new vozmozhnostey. Vyhod not made a new version of V 1.x obsolete. You can use both versions simultaneously. Therefore, do not touch your working with the V 1.x code, and new schedules, use the version that you prefer (easier) polzovatsya. Dumayu, the situation is more or less clear, so just give an example of using the second versii. Kak and the first version should be carefully monitor the placement of the library and the law?? ilno point the way to faylam. Struktura sayta. Dopustim we have a domain http://localhost/ Biblioteka folder tests / ofc / lib / and has a strukturu tests / ofc / lib open-flash-chart.swf php-ofc-library / … (all files in the folder php-ofc-library) Primechanie. From the distribution, I copied only the flash movie to create graphics and PHP version biblioteki. Stranitsa, which we'll show graphics – http://localhost/tests/ofc/mygraphs.php. Istochniki dannyh. Dannye can take anywhere from the base , a text file, count. For this example we will create 2 php script (data1.php and data2.php), which will form the arrays of data to graph and convert them into a format JSON. Both place a file in the folder datasrc. T.k. sources of data we have two, but the schedule will be one, then we need as a state which of them should be ispolzovat. Imya script – source of data can be sent along with the URL (in the parameter ofc). T.e. on stranitse http: / / localhost / tests / ofc / mygraphs.php? ofc = datasrc/data1.php my see the schedule of data formed in the script data1.php. A stranitse http: / / localhost / tests / ofc / mygraphs.php? ofc = datasrc/data2.php grafik with data from data2.php. Obratite attention. If the data source wespecify the path to the file (on this page). Teper consider themselves skripty. mygraphs.php it form an array of data $ tmp (lines 4-8). Here I have used is not complicated funktsiyu. Posle this create an object of type bar. I think, is not difficult to guess that it is used to create histograms. And using set values specify an array with the source dannymi. Vtoroy object that we need – open flash chart. His method set title used to set the header graphics and add element – add our gistogrammu. Posledny step. We form the string in JSON format to the data of our schedule (the method toString ()). script data2.php little different. I just changed the function of forming an array of data and type grafika. data2.php Kak see, the library is simple. And on the official site you will find many other interesting primerov. V closing, I want to say a few words about the effectiveness of this biblioteki. T.k. picture with a schedule on the client side (using Flash), then load on the server will be minimal. Obtaining data and transform them into JSON format will require significantly fewer resources than the data acquisition and creation of graphics, for example, by library GD. No whereassame time, the visitor will be sent to the flash animation (open-flash-chart.swf) volume 264kB. For comparison, the same png file showing the schedule will hold 10-30kB. Otsyuda simple conclusion. If your application like Google Analytics, you can use Open Flash Chart you will not only reduce the load on your server, but save bandwidth users, as flash movie is loaded only once. But if you want to show only one or two graphics, it is unlikely that this library will be the most successful vyborom. Esli you do not agree or want something to ask, do not hesitate to open P.S. comments The next time I will continue the theme of graphs and discuss on the use of outside services for these tseley. Interesno pochitat Autsorsing noncore operations. Logos-Audit – Maintenance of personnel records for small and medium biznesa.
Posted: June 22nd, 2009 under Uncategorized.