Sunshinecharts deployment tutorial (the simplest flex charts)

Source: Internet
Author: User
Tags tld

Recently, it is not available because of the company's project requirements and too many bugs in open-source report controls. Therefore, a flexchart is encapsulated to make it easier to use. It can be used in 3 minutes, And the scalability is good. This report control is open-source. You are welcome to download and use it.
First download the sunshinecharts package:

Http://ken-javaframeword.googlecode.com/files/SunshineCharts.war

Download the Java framework 2.5.2:

Http://ken-javaframeword.googlecode.com/files/javaFramework2_5_2.jar

Core SWF file of the sunshinecharts.swf report;

Chartstag. TLD report Tag file

Step 1: Add tags

Add in Web. xml

<jsp-config><taglib><taglib-uri>/WEB-INF/chartsTagLib</taglib-uri><taglib-location>/WEB-INF/tag/chartsTag.tld</taglib-location></taglib></jsp-config>

Where

/WEB-INF/tag/chartsTag.tld

Ask the TLD storage path;

Step 2: Add a report

Add in JSP Header

<%@taglib uri="/WEB-INF/chartsTagLib" prefix="chart"%>

Then add

 

<chart:flashTag  id="lineChart" type="lineChart"dataUrl="xml/LineChartData.xml" flashUrl="SunshineCharts.swf"cleanCache="off" width="100%" height="100%" />

ID: Report ID

Type: linechart/piechart/columnchart

Flashurl: sunshinecharts.swf path

Dataurl: the path of the data source URL. The data source is XML.

Cleancache: whether to automatically clear the cache

Step 3: Construct a data source

Input linechartdata. XML in dataurl

<? XML version = "1.0" encoding = "UTF-8"?> <Data Title = "" autorefreshpolicy = "on" autorefreshtime = "180" DEBUG = "off" backgroudcolor = "0 xffffff" verticaltitle = "price" horizontaltitle = "date" form =" curve "showdatatips =" true "showalldatatips =" false "savepicturepolicy =" on "savepicturepolicyname =" test.jpg "legend =" true "> <lines> <line value =" line1 "label =" false ""Line 1" color = "ox000000"/> </lines> <node label = "1" line1 = "100"/> <node label = "2" line1 = "0 "/> <node label =" 3 "line1 =" 100 "/> </data>

XML parsing:

Title: Title

Autorefreshpolicy: whether to automatically refresh

Autorefreshtime: Automatic refresh time

Debug: whether to display debug

Backgroudcolor: Background Color

Verticaltitle: vertical axis label

Horizontaltitle: horizontal axis label

Form: Line Style

Showdatatips: interactive display

Showalldatatips: displays all labels.

Savepicturepolicy: Can you right-click to save an image?

Savepicturepolicyname: Right-click to save the image name

Legend: whether a legend is required

Color: The color of the line.

:

Other XML:

<? XML version = "1.0" encoding = "UTF-8"?> <Data Title = "" autorefreshpolicy = "on" autorefreshtime = "180" DEBUG = "off" backgroudcolor = "0 xffffff" verticaltitle = "price" horizontaltitle = "date" form =" curve "showdatatips =" true "showalldatatips =" false "legend =" true "> <lines> <line value =" line1 "label =" Line 1 "color =" 0x00ffff "/> <line value = "line2" label = "Line 2" color = "0xffff00"/> </lines> <node label = "1" line1 = "100" line2 =" 100 "/> <node label =" 2 "line1 =" 0 "line2 =" 300 "/> <node label =" 3 "line1 =" 100 "line2 =" 100" /> </data>

Result chart:

Construct XML using Java code:

Construct line chart XML

Package COM. shine. framework. charts. coffercharts. linecharts; public class linechartsexample {/*** line chart generation example ** @ Param ARGs */public static void main (string [] ARGs) {Line line1 = new line ("line1", "Line 1", "0x000000"); line1.put ("1", 100); line1.put ("3 ", 100); linechartshelper helper = new linechartshelper (); helper. addaix ("1", "2", "3"); helper. addline (line1); system. out. println (helper. getdataxml ());}}

Construct pie chart XML

Package COM. shine. framework. charts. coffercharts. piecharts; public class piechartexample {/*** pie chart example ** @ Param ARGs */public static void main (string [] ARGs) {piechartshelper helper = new piechartshelper (); helper. addpiechart ("p1", 10, "0xffff00", "Pie 1"); helper. addpiechart ("p2", 10, "0xff00ff", "Pie 2"); helper. addpiechart ("P3", 10, "0x00ffff", "Pie 3"); system. out. println (helper. getdataxml ());}}

Structure Column chart XML

Package COM. shine. framework. charts. coffercharts. columnscharts; import COM. shine. framework. charts. coffercharts. linecharts. line; import COM. shine. framework. charts. coffercharts. linecharts. linechartshelper; public class columnschartsexample {/*** bar legend sub-** @ Param ARGs */public static void main (string [] ARGs) {colunms = new colunms ("colunms1", "Line 1", "0x00ffff"); colunms. put ("1", 100); colunms. put ("2", 300); colunms. put ("3", 100); colunms colunms1 = new colunms ("colunms2", "Line 1", "0xffff00"); colunms1.put ("1", 200 ); colunms1.put ("3", 500); columnschartshelper helper = new columnschartshelper (); helper. addaix ("1", "2", "3"); helper. addcolunms (colunms); helper. addcolunms (colunms1); system. out. println (helper. getdataxml ());}}

Pie Chart: http://blog.csdn.net/arjick/article/details/7011872

Bar Chart: http://blog.csdn.net/arjick/article/details/7012330

Gauge: http://blog.csdn.net/arjick/article/details/7018354

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.