欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

echart簡(jiǎn)介_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

 更新時(shí)間:2017年08月11日 10:28:28   作者:xuemoyao  
這篇文章主要介紹了echart簡(jiǎn)介,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

1. 插件的下載

以下是ECharts的下載鏈接,需要注意的是ECharts內(nèi)部也是依賴于另一個(gè)插件的叫ZRender,當(dāng)然對(duì)于大部分圖表而言不需要ZRender的,但是對(duì)于地圖控件及其他復(fù)雜的呈現(xiàn)控件而已都是需要ZRender的。為了避免不要的問(wèn)題出現(xiàn),建議大家在下載ECharts時(shí)同時(shí)也要下載ZRender。

ECharts下載地址: http://echarts.baidu.com/

ZRender下載地址:http://ecomfe.github.io/zrender/index.html

下載之后解壓各自的文件目錄結(jié)構(gòu)如下:

ECharts:

     

 ZRender:

 

2. 插件的引用

首先,新建一個(gè)Web應(yīng)用程序,然后添加剛剛下載的文件,具體的目錄結(jié)構(gòu)如下:

這里有以下幾點(diǎn)需要說(shuō)明:

  • 所有的跟ECharts有關(guān)的文件全部都在echarts文件夾下
  • echarts文件夾的內(nèi)容分為兩部分

1) 一部分是以echarts開頭的js文件,這些文件全部來(lái)自于1.中的ECharts文件目錄中的js文件夾下的文件,也就是1.中的圖中紅框標(biāo)注的js下的文件。如下:

2)另一部分是一個(gè)名為zrender的文件夾,這里需要特別注意的是該文件夾的命名必須為zrender,因?yàn)樵趀charts的js文件中對(duì)zrender的引用都是以zrender為根目錄的,zrender文件夾的內(nèi)容即為1.中zrender文件目錄中的src文件夾下的內(nèi)容,如下:

3. 在頁(yè)面中的具體使用

按照上邊的步驟配置過(guò)之后,我們就可以在頁(yè)面中引用了,這里我主要是演示地圖控件的使用方式,因?yàn)榈貓D的引用跟其他的基本圖形的引用不太一樣。其他的圖形的呈現(xiàn)也會(huì)做一個(gè)簡(jiǎn)要的演示。

MapChart

首先在跟2中的echarts文件夾同一個(gè)目錄(也就是Modules文件夾)下添加一個(gè)aspx頁(yè)或html頁(yè),需要注意的是,如果是在aspx頁(yè)中使用echarts時(shí),需要把要渲染的div放在form標(biāo)簽之外,否則圖形是顯示不出來(lái)的。

在head標(biāo)簽中添加對(duì)echarts的引用如下:

<head runat="server"> 
  <title></title> 
  <script src="echarts/esl.js" type="text/javascript"></script> 
</head> 

在body標(biāo)記中,form標(biāo)記之外,添加一個(gè)div,用來(lái)做圖表渲染的容器。如下:

<body> 
 
<div id="main"style="height:500px;border:1px solid #ccc;padding:10px;"></div> 
 
…………… 
 
…………… 
 
</body> 

在上面中添加的div標(biāo)記下,添加如下的js代碼段,如下:

 <script type="text/javascript"> 
 
    //為模塊加載器配置echarts的路徑,這里主要是配置map圖表的路徑,其他的圖表跟map的配置還不太一樣,下邊也會(huì)做另一種類型的圖表事例。 
這里引用的主要是echarts文件夾下的echarts-map文件,而其他類型的圖表引用的都是echarts文件夾下的echarts文件。 
 
    require.config({ 
 
      paths: { 
 
        echarts:'./echarts/echarts', 
 
        'echarts/chart/map':'./echarts/echarts-map' 
 
      } 
 
    }); 
 
   //動(dòng)態(tài)加載echarts,在回掉函數(shù)中使用,要注意保持按需加載結(jié)構(gòu)定義圖表路徑 
 
    require( 
 
    [ 
 
      'echarts', 
 
      'echarts/chart/map' 
 
    ], 
 
    function (ec) { 
 
      varmyChart=ecinit(documentgetElementById('main')); 
 
      //option主要是圖標(biāo)的一些設(shè)置,這不是這篇文章的重點(diǎn),關(guān)于具體的設(shè)置可以參考官方的文檔說(shuō)明文檔 
 
option= { 
 
        title: { 
 
          text:'iphone銷量', 
 
          subtext:'純屬虛構(gòu)', 
 
          x:'center' 
 
        }, 
 
        tooltip: { 
 
          trigger:'item' 
 
        }, 
 
        legend: { 
 
          orient:'vertical', 
 
          x:'left', 
 
          data: ['iphone3','iphone4','iphone5'] 
 
        }, 
 
        dataRange: { 
 
          min:0, 
 
          max:2500, 
 
          text: ['高','低'],      
 
          calculable:true, 
 
          textStyle: { 
 
            color:'orange' 
 
          } 
 
        }, 
 
        toolbox: { 
 
          show:true, 
 
          orient:'vertical', 
 
          x:'right', 
 
          y:'center', 
 
          feature: { 
 
            mark:true, 
 
            dataView: { readOnly:false }, 
 
            restore:true, 
 
            saveAsImage:true 
 
          } 
 
        }, 
 
        series: [ 
 
    { 
 
      name:'iphone3', 
 
      type:'map', 
 
      mapType:'china', 
 
      selectedMode: 'single', 
 
      itemStyle: { 
 
        normal: { label: { show:true },color:'#ffd700' },// for legend 
 
        emphasis: { label: { show:true} } 
 
      }, 
 
      data: [ 
 
        { name:'北京',value:Math.round(Math.random() *1000) }, 
 
        { name:'天津',value:Math.round(Math.random() *1000) }, 
 
        { name:'上海',value:Math.round(Math.random() *1000) }, 
 
        { name:'重慶',value:Math.round(Math.random() *1000) }, 
 
        { name:'河北',value:Math.round(Math.random() *1000) }, 
 
        { name:'河南',value:Math.round(Math.random() *1000) }, 
 
        { name:'云南',value:Math.round(Math.random() *1000) }, 
 
        { name:'遼寧',value:Math.round(Math.random() *1000) }, 
 
        { name:'黑龍江',value:Math.round(Math.random() *1000) }, 
 
        { name:'湖南',value:Math.round(Math.random() *1000) }, 
 
        { name:'安徽',value:Math.round(Math.random() *1000) }, 
 
        { name:'山東',value:Math.round(Math.random() *1000) }, 
 
        { name:'新疆',value:Math.round(Math.random() *1000) }, 
 
        { name:'江蘇',value:Math.round(Math.random() *1000) }, 
 
        { name:'浙江',value:Math.round(Math.random() *1000) }, 
 
        { name:'江西',value:Math.round(Math.random() *1000) }, 
 
        { name:'湖北',value:Math.round(Math.random() *1000) }, 
 
        { name:'廣西',value:Math.round(Math.random() *1000) }, 
 
        { name:'甘肅',value:Math.round(Math.random() *1000) }, 
 
        { name:'山西',value:Math.round(Math.random() *1000) }, 
 
        { name:'內(nèi)蒙古',value:Math.round(Math.random() *1000) }, 
 
        { name:'陜西',value:Math.round(Math.random() *1000) }, 
 
        { name:'吉林',value:Math.round(Math.random() *1000) }, 
 
        { name:'福建',value:Math.round(Math.random() *1000) }, 
 
        { name:'貴州',value:Math.round(Math.random() *1000) }, 
 
        { name:'廣東',value:Math.round(Math.random() *1000) }, 
 
        { name:'青海',value:Math.round(Math.random() *1000) }, 
 
        { name:'西藏',value:Math.round(Math.random() *1000) }, 
 
        { name:'四川',value:Math.round(Math.random() *1000) }, 
 
        { name:'寧夏',value:Math.round(Math.random() *1000) }, 
 
        { name:'海南',value:Math.round(Math.random() *1000) }, 
 
        { name:'臺(tái)灣',value:Math.round(Math.random() *1000) }, 
 
        { name:'香港',value:Math.round(Math.random() *1000) }, 
 
        { name:'澳門',value:Math.round(Math.random() *1000) } 
 
      ] 
 
    }, 
 
    { 
 
      name:'iphone4', 
 
      type:'map', 
 
      mapType:'china', 
 
      selectedMode: 'single', 
 
      itemStyle: { 
 
        normal: { label: { show:true },color:'#ff8c00' },// for legend 
 
        emphasis: { label: { show:true} } 
 
      }, 
 
      data: [ 
 
        { name:'北京',value:Math.round(Math.random() *1000) }, 
 
        { name:'天津',value:Math.round(Math.random() *1000) }, 
 
        { name:'上海',value:Math.round(Math.random() *1000) }, 
 
        { name:'重慶',value:Math.round(Math.random() *1000) }, 
 
        { name:'河北',value:Math.round(Math.random() *1000) }, 
 
        { name:'安徽',value:Math.round(Math.random() *1000) }, 
 
        { name:'新疆',value:Math.round(Math.random() *1000) }, 
 
        { name:'浙江',value:Math.round(Math.random() *1000) }, 
 
        { name:'江西',value:Math.round(Math.random() *1000) }, 
 
        { name:'山西',value:Math.round(Math.random() *1000) }, 
 
        { name:'內(nèi)蒙古',value:Math.round(Math.random() *1000) }, 
 
        { name:'吉林',value:Math.round(Math.random() *1000) }, 
 
        { name:'福建',value:Math.round(Math.random() *1000) }, 
 
        { name:'廣東',value:Math.round(Math.random() *1000) }, 
 
        { name:'西藏',value:Math.round(Math.random() *1000) }, 
 
        { name:'四川',value:Math.round(Math.random() *1000) }, 

        { name:'寧夏',value:Math.round(Math.random() *1000) }, 
 
        { name:'香港',value:Math.round(Math.random() *1000) }, 
        { name:'澳門',value:Math.round(Math.random() *1000) } 
 
      ] 
 
    }, 
 
    { 
 
      name:'iphone5', 
 
      type:'map', 
 
      mapType:'china', 
 
      selectedMode: 'single', 
 
      itemStyle: { 
 
        normal: { label: { show:true },color:'#da70d6' },// for legend 
 
        emphasis: { label: { show:true} } 
 
      }, 
 
      data: [ 
 
        { name:'北京',value:Math.round(Math.random() *1000) }, 
 
        { name:'天津',value:Math.round(Math.random() *1000) }, 
 
        { name:'上海',value:Math.round(Math.random() *1000) }, 
 
        { name:'廣東',value:Math.round(Math.random() *1000) }, 
 
        { name:'臺(tái)灣',value:Math.round(Math.random() *1000) }, 
 
        { name:'香港',value:Math.round(Math.random() *1000) }, 
 
        { name:'澳門',value:Math.round(Math.random() *1000) } 
 
      ] 
 
    } 
  ] 
      }; 
       //以下的這段代碼主要是用來(lái)處理用戶的選擇,應(yīng)用場(chǎng)景是可以做地圖的交互,比如點(diǎn)擊地圖上的某一個(gè)省,獲取相應(yīng)的省的指標(biāo)變化等。 
       //需要特別注意的是,如果需要點(diǎn)擊某一省作地圖的操作交互的話,還需要為series屬性的每一項(xiàng)添加一個(gè)selectedMode屬性,這里的屬性值為 'single'即單選,也可多選 
  varecConfig= require('echarts/config'); 
      myChart.on(ecConfig.EVENT.MAP_SELECTED,function (param) { 
        varselected=param.selected; 
        varmapSeries=option.series[0]; 
        vardata= []; 
        varlegendData= []; 
        varname; 
        for (varp=0,len=mapSeries.data.length; p<len; p++) { 
          name=mapSeries.data[p].name; 
          mapSeries.data[p].selected=selected[name]; 
          if (selected[name]) { 
            alert(name); //這里只是簡(jiǎn)單的做一個(gè)事例說(shuō)明,彈出用戶所選的省,如需做其他的擴(kuò)展,可以在這里邊添加相應(yīng)的操作  
 
          } 
        } 
      });         
      myChart.setOption(option); 
    } 
  ); 
  </script> 

完成以上操作之后,效果如下圖所示:

 

LineChart

除了地圖圖表之外的其他的圖標(biāo)的使用方式都差不多。事實(shí)上其他的圖表跟地圖圖表的區(qū)別在于對(duì)配置文件的引用。這里只做一個(gè)折線圖的示例,其它的示例都是一樣的。

<scripttype="text/javascript"> 
 
    require.config({ 
 
      paths: { 
 
        echarts:'./echarts/echarts', 
 
        'echarts/chart/bar':'./echarts/echarts',//這里需要注意的是除了mapchart使用的配置文件為echarts-map之外, 
其他的圖形引用的配置文件都為echarts,這也是一般的圖形跟地圖的區(qū)別 
 
        'echarts/chart/line':'./echarts/echarts' 
 
      } 
 
    }); 
 
    require( 
 
    [ 
 
      'echarts', 
 
      'echarts/chart/bar', 
 
      'echarts/chart/line' 
 
    ], 
 
    function (ec) { 
 
      varmyChart=ecinit(documentgetElementById('main')); 
 
      option= { 
 
        tooltip: { 
 
          trigger:'axis' 
 
        }, 
 
        legend: { 
 
          data: ['郵件營(yíng)銷','聯(lián)盟廣告','視頻廣告','直接問(wèn)','搜索引擎'] 
 
        }, 
 
        toolbox: { 
 
          show:true, 
 
          feature: { 
 
            mark:true, 
 
            dataView: { readOnly:false }, 
 
            magicType: ['line','bar'], 
 
            restore:true, 
 
            saveAsImage:true 
 
          } 
 
        }, 
 
        calculable:true, 
 
        xAxis: [ 
 
    { 
 
      type:'category', 
 
      boundaryGap:false, 
 
      data: ['周一','周二','周三','周四','周五','周六','周日'] 
 
    } 
 
  ], 
 
        yAxis: [ 
 
    { 
 
      type:'value', 
 
      splitArea: { show:true } 
 
    } 
 
  ], 
 
        series: [ 
 
    { 
 
      name:'郵件營(yíng)銷', 
 
      type:'line', 
 
      stack:'總量', 
 
      data: [120,132,101,134,90,230,210] 
 
    }, 
 
    { 
 
      name:'聯(lián)盟廣告', 
 
      type:'line', 
 
      stack:'總量', 
 
      data: [220,182,191,234,290,330,310] 
 
    }, 
 
    { 
 
      name:'視頻廣告', 
 
      type:'line', 
 
      stack:'總量', 
 
      data: [150,232,201,154,190,330,410] 
 
    }, 
 
    { 
 
      name:'直接訪問(wèn)', 
 
      type:'line', 
 
      stack:'總量', 
 
      data: [320,332,301,334,390,330,320] 
 
    }, 
 
    { 
 
      name:'搜索引擎', 
 
      type:'line', 
 
      stack:'總量', 
 
      data: [820,932,901,934,1290,1330,1320] 
 
    } 
 
  ] 
 
      };           
 
  
 
      myChart.setOption(option); 
 
    } 
 
  ); 
 
  </script> 
 
  
 
  
 
  <divid="main1"style="height:500px;border:1px solid #ccc;padding:10px;"></div>   
 
  <scripttype="text/javascript"> 
 
    require.config({ 
 
      paths: { 
 
        echarts:'./echarts/echarts', 
 
        'echarts/chart/bar':'./echarts/echarts', 
 
        'echarts/chart/line':'./echarts/echarts' 
 
      } 
 
    }); 
 
    require( 
 
    [ 
 
      'echarts', 
 
      'echarts/chart/bar', 
 
      'echarts/chart/line' 
 
    ], 
 
    function (ec) { 
 
      varmyChart=ecinit(documentgetElementById('main1')); 
 
      option= { 
 
        title: { 
 
          text:'未來(lái)一周氣溫變化', 
 
          subtext:'純屬虛構(gòu)' 
 
        }, 
 
        tooltip: { 
 
          trigger:'axis' 
 
        }, 
 
        legend: { 
 
          data: ['最高氣溫'最低氣溫'] 
 
        }, 
 
        toolbox: { 
 
          show:true, 
 
          feature: { 
 
            mark:true, 
 
            dataView: { readOnly:false }, 
 
            magicType: ['line','bar'], 
 
            restore:true, 
 
            saveAsImage:true 
 
          } 
 
        }, 
 
        calculable:true, 
 
        xAxis: [ 
 
    { 
 
      type:'category', 
 
      boundaryGap:false, 
 
      data: ['周一','周二','周三','周四','周五','周六','周日'] 
 
    } 
 
  ], 
 
        yAxis: [ 
 
    { 
 
      type:'value', 
 
      axisLabel: { 
 
        formatter:'{value} ' 
 
      }, 
 
      splitArea: { show:true } 
 
    } 
 
  ], 
 
        series: [ 
 
    { 
 
      name:'最高氣溫', 
 
      type:'line', 
 
      itemStyle: { 
 
        normal: { 
 
          lineStyle: { 
 
            shadowColor:'rgba(0,0,0,4)' 
 
          } 
 
        } 
 
      }, 
 
      data: [11,11,15,13,12,13,10] 
 
    }, 
 
    { 
 
      name:'最低氣溫', 
 
      type:'line', 
 
      itemStyle: { 
 
        normal: { 
 
          lineStyle: { 
 
            shadowColor:'rgba(0,0,0,4)' 
 
          } 
 
        } 
 
      }, 
 
      data: [-2,1,2,5,3,2,0] 
 
    } 
 
  ] 
 
      };           
 
      myChart.setOption(option); 
 
    } 
 
  ); 
 
  </script> 
 
  
 
  
 
  <divid="main2"style="height:500px;border:1px solid #ccc;padding:10px;"></div>   
 
  <scripttype="text/javascript"> 
 
    require.config({ 
 
      paths: { 
 
        echarts:'./echarts/echarts', 
 
        'echarts/chart/bar':'./echarts/echarts', 
 
        'echarts/chart/line':'./echarts/echarts' 
 
      } 
 
    }); 
 
    require( 
 
    [ 
 
      'echarts', 
 
      'echarts/chart/bar', 
 
      'echarts/chart/line' 
 
    ], 
 
    function (ec) { 
 
      varmyChart=ec.init(document.getElementById('main2')); 
 
      option= { 
 
        title: { 
 
          text:'某樓盤銷售情況', 
 
          subtext:'純屬虛構(gòu)' 
 
        }, 
 
        tooltip: { 
 
          trigger:'axis' 
 
        }, 
 
        legend: { 
 
          data: ['意向','預(yù)購(gòu)','成交'] 
 
        }, 
 
        toolbox: { 
 
          show:true, 
 
          feature: { 
 
            mark:true, 
 
            dataView: { readOnly:false }, 
 
            magicType: ['line','bar'], 
 
            restore:true, 
 
            saveAsImage:true 
 
          } 
 
        }, 
 
        calculable:true, 
 
        xAxis: [ 
 
    { 
 
      type:'category', 
 
      boundaryGap:false, 
 
      data: ['周','周二','周三','周四','周五','周六','周日'] 
 
    } 
 
  ], 
 
        yAxis: [ 
 
    { 
 
      type:'value' 
 
    } 
 
  ], 
 
        series: [ 
 
    { 
 
      name:'成交', 
 
      type:'line', 
 
      smooth:true, 
 
      itemStyle: { normal: { areaStyle: { type:'default'}} }, 
 
      data: [10,12,21,54,260,830,710] 
 
    }, 
 
    { 
 
      name:'預(yù)購(gòu)', 
 
      type:'line', 
 
      smooth:true, 
 
      itemStyle: { normal: { areaStyle: { type:'default'}} }, 
 
      data: [30,182,434,791,390,30,10] 
 
    }, 
 
    { 
 
      name:'意向', 
 
      type:'line', 
 
      smooth:true, 
 
      itemStyle: { normal: { areaStyle: { type:'default'}} }, 
 
      data: [1320,1132,601,234,120,90,20] 
 
    } 
 
  ] 
 
      };           
 
      myChart.setOption(option); 
 
    } 
 
  ); 
 
  </script> 

完成以上操作之后效果圖如下:

 

相關(guān)文章

最新評(píng)論