fc几种图

有几种图可以使用单序列的XML格式的数据

(1)Pie图

FCF_Pie2D.swf  FCF_Pie3D.swf

(2)Area图

FCF_Area2D.swf

(3)Bar图

FCF_Bar2D.swf

(4)Column图

FCF_Column2D.swf  FCF_Column3D.swf

(5)Line图

FCF_Line.swf

(6)Doughnut图

FCF_Doughnut2D.swf


六、多序列XML形式

举例:

  1. <graph baseFont='SunSim' baseFontSize='12' caption='分析' subcaption='' yAxisMinValue='0' yAxisMaxValue='100' xaxisname='地区  
  2. ' yaxisname='数量' hovercapbg='FFECAA' hovercapborder='F47E00' formatNumberScale='0' decimalPrecision='0' showvalues='1'   
  3. numdivlines='10' numVdivlines='0' shownames='1' rotateNames='1' >  
  4.    <categories font='Arial' fontSize='11' fontColor='000000'>  
  5.       <category name='N. America' hoverText='North America'/>  
  6.       <category name='Asia' />  
  7.       <category name='Europe' />  
  8.       <category name='Australia' />  
  9.       <category name='Africa' />  
  10.    </categories>  
  11.    <dataset seriesname='Rice' color='FDC12E' alpha='100'>  
  12.       <set value='30' />  
  13.       <set value='26' />  
  14.       <set value='29' />  
  15.       <set value='31' />  
  16.       <set value='34' />  
  17.    </dataset>  
  18.     <dataset seriesname='Wheat' color='56B9F9' showValues='1' alpha='100'>  
  19.       <set value='67' />  
  20.       <set value='98' />  
  21.       <set value='79' />  
  22.       <set value='73' />  
  23.       <set value='80' />  
  24.    </dataset>  
  25.     <dataset seriesname='Grain' color='C9198D' showValues='1' alpha='100'>  
  26.       <set value='27' />  
  27.       <set value='25' />  
  28.       <set value='28' />  
  29.       <set value='26' />  
  30.       <set value='10' />  
  31.    </dataset>  
  32. </graph>  

<graph>基本上同单序列XML形式

<categroies>指明x轴有几个种类

<categroy>对应一个种类

name:种类名

<dataset>指明一个序列集,序列集中值的个数同category的种类数

seriesname:序列的名称

<set>:序列的一个值

有几种图可以使用多序列的XML格式的数据

(1)Area图

FCF_MSArea2D.swf

(2)Bar图

FCF_MSBar2D.swf

(3)Column图

FCF_MSColumn2D.swf  FCF_MSColumn3D.swf

(4)Line图

FCF_MSLine.swf

(5)Stacked图

FCF_StackedArea2D.swf

FCF_StackedBar2D.swf

FCF_StackedColumn2D.swf  FCF_StackedColumn3D.swf


七、产生上述XML的类

  1. public class FusionChartsXMLGenerator {  
  2.       
  3.     public static final int BOOLEAN_TRUE = 0;  
  4.     public static final int BOOLEAN_FALSE = 1;  
  5.     private static Logger LOGGER = LoggerFactory.getLogger(FusionChartsXMLGenerator.class);   
  6.       
  7.     private static FusionChartsXMLGenerator singleton = new FusionChartsXMLGenerator();  
  8.       
  9.     public static FusionChartsXMLGenerator getInstance() {  
  10.         return singleton;  
  11.     }  
  12.       
  13.     private FusionChartsXMLGenerator() {}  
  14.       
  15.     private String[] colors = {"AFD8F8""F6BD0F""8BBA00""FF8E46""008E8E",  
  16.             "D64646""8E468E""588526""B3AA00""008ED6""9D080D""A186BE"};  
  17.       
  18.     /** 
  19.      * data形式为:  
  20.      * "" category1,category2,category3...-------->这是第一行  
  21.      * type1 value1,value2,value3,...  
  22.      * type2 value1,value2,value3,... 
  23.      * ...... 
  24.      */  
  25.     public String getMultiDSXML(List<List<String>> data,   
  26.             String caption, String subCaption,   
  27.             String xAxisName, String yAxisName,   
  28.             int showNames,int showValues,  
  29.             int decimalPrecision, int rotateNames) {  
  30.         double max = -Double.MAX_VALUE, min = Double.MAX_VALUE;  
  31.         for (int i = 1; i < data.size(); i++) {  
  32.             List row = (List)data.get(i);  
  33.             for (int j = 1; j < row.size(); j++) {  
  34.                 String val = (String)row.get(j);  
  35.                 if (val != null && val.length() > 0) {  
  36.                     double v = Double.parseDouble(val);  
  37.                     if (v > max) {  
  38.                         max = v;  
  39.                     }  
  40.                     if (v < min) {  
  41.                         min = v;  
  42.                     }  
  43.                 }  
  44.             }  
  45.         }  
  46.           
  47.         if (max == -Double.MAX_VALUE) {  
  48.             max = 0;  
  49.         }  
  50.           
  51.         if (min == Double.MAX_VALUE) {  
  52.             min = 0;  
  53.         }  
  54.           
  55.         if (min == max && min == 0) {  
  56.             min = 0;  
  57.             max = 100;  
  58.         }  
  59.           
  60.           
  61.         max = Math.abs(max / 10) + max;  
  62.         min = min - Math.abs(min / 10);  
  63.           
  64.         int valCnt = ((List)data.get(0)).size() - 1;  
  65.         if (valCnt > 30) {  
  66.             showNames = 0;  
  67.             showValues = 0;  
  68.         }  
  69.           
  70.         StringBuffer strXml = new StringBuffer();  
  71.         strXml.append("<graph baseFont='SunSim' baseFontSize='12' caption='" +   
  72.                 caption +"' subcaption='" + subCaption + "' " +  
  73.                 "yAxisMinValue='" + min + "' yAxisMaxValue='" + max + "' " +  
  74.                 "xAxisName='" + xAxisName + "' yAxisName='" + yAxisName + "' hovercapbg='FFECAA' " +  
  75.                 "hovercapborder='F47E00' formatNumberScale='0' decimalPrecision='" + decimalPrecision + "' " +  
  76.                 "showValues='" + showValues + "' numdivlines='10' numVdivlines='0' " +  
  77.                 "showNames='" + showNames + "' rotateNames='" + rotateNames + "' " +  
  78.                 "rotateYAxisName='0' showAlternateHGridColor='1'>");  
  79.       
  80.         strXml.append("<categories>");  
  81.         List headerRow = (List)data.get(0);  
  82.         for (int i = 1; i < headerRow.size(); i++) {  
  83.             strXml.append("<category name='" + headerRow.get(i) + "'/>");  
  84.         }  
  85.         strXml.append("</categories>");  
  86.           
  87.         for (int i = 1; i < data.size(); i++) {  
  88.             List row = (List)data.get(i);  
  89.             String name = (String)row.get(0);  
  90.             String color = colors[(i - 1) % 12];  
  91.             strXml.append("<dataset seriesName='" + name +"' " +  
  92.                     "color='" + color + "' anchorBorderColor='" + color + "' " +  
  93.                     "anchorBgColor='" + color + "'>");  
  94.             for (int j = 1; j < row.size(); j++) {  
  95.                 strXml.append("<set value='" + (String)row.get(j) +"'/>");  
  96.             }  
  97.             strXml.append("</dataset>");  
  98.         }  
  99.           
  100.         strXml.append("</graph>");  
  101.         String str =  strXml.toString();  
  102.         LOGGER.info("=============/n" + str + "/n==============/n");  
  103.         return str;  
  104.     }  
  105.       
  106.     /** 
  107.      *  数据格式为: 
  108.      *  name value  
  109.      *  name value 
  110.      *  ...... 
  111.      */  
  112.     public String getSingleDSXML(List<List<String>> data,   
  113.             String caption, String subCaption,   
  114.             String xAxisName, String yAxisName,   
  115.             int showNames,int showValues,  
  116.             int decimalPrecision, int rotateNames) {  
  117.           
  118.         double max = -Double.MAX_VALUE, min = Double.MAX_VALUE;  
  119.         for (int i = 0; i < data.size(); i++) {  
  120.             List<String> row = data.get(i);  
  121.             double value = Double.parseDouble(row.get(1));  
  122.             if (value > max) {  
  123.                 max = value;  
  124.             }  
  125.             if (value < min) {  
  126.                 min = value;  
  127.             }  
  128.         }  
  129.           
  130.         if (max == -Double.MAX_VALUE) {  
  131.             max = 0;  
  132.         }  
  133.           
  134.         if (min == Double.MAX_VALUE) {  
  135.             min = 0;  
  136.         }  
  137.           
  138.         if (min == max && min == 0) {  
  139.             min = 0;  
  140.             max = 100;  
  141.         }  
  142.           
  143.           
  144.         max = Math.abs(max / 10) + max;  
  145.         min = min - Math.abs(min / 10);  
  146.           
  147.         int valCnt = data.size() - 1;  
  148.         if (valCnt > 30) {  
  149.             showNames = 0;  
  150.             showValues = 0;  
  151.         }  
  152.           
  153.         StringBuffer strXml = new StringBuffer();  
  154.         strXml.append("<graph baseFont='SunSim' baseFontSize='12' caption='" +   
  155.                 caption +"' subcaption='" + subCaption + "' " +  
  156.                 "yAxisMinValue='" + min + "' yAxisMaxValue='" + max + "' " +  
  157.                 "xAxisName='" + xAxisName + "' yAxisName='" + yAxisName + "' hovercapbg='FFECAA' " +  
  158.                 "hovercapborder='F47E00' formatNumberScale='0' decimalPrecision='" + decimalPrecision + "' " +  
  159.                 "showValues='" + showValues + "' numdivlines='10' numVdivlines='0' " +  
  160.                 "showNames='" + showNames + "' rotateNames='" + rotateNames + "' " +  
  161.                 "rotateYAxisName='0' showAlternateHGridColor='1'>");  
  162.         for (int i = 0; i < data.size(); i++) {  
  163.             List<String> row = data.get(i);  
  164.             String label = row.get(0);  
  165.             String value = row.get(1);  
  166.             String color = colors[i % 12];  
  167.             strXml.append("<set name='" + label + "' value='" + value + "' color='" + color + "'/>");  
  168.               
  169.         }  
  170.         strXml.append("</graph>");  
  171.         String str =  strXml.toString();  
  172.         LOGGER.info("=============/n" + str + "/n==============/n");  
  173.         return str;  
  174.     }  
  175. }  

posted on 2011-07-15 14:03  回到未来看历史  阅读(316)  评论(0)    收藏  举报

导航