原創(chuàng)|其它|編輯:郝浩|2012-11-27 15:14:14.000|閱讀 1019 次
概述:本文將為你演示如何用AnyChart創(chuàng)建向下鉆取的地圖儀表盤
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
用 AnyChart 創(chuàng)建向下鉆取地圖有兩種方式:用AnyChart JavaScript庫,或者用AnyChart儀表盤。本文將為你講解第二種方式。 假設(shè)地圖中包含兩部分,第一部分包含USA地圖,當(dāng)用戶點擊某個州時,這個州的地圖會顯示在第二個地圖上。
首先我們要用到AnyChart的儀表盤功能,這個儀表盤包含兩部分,代碼如下:
<?xml version="1.0" encoding="UTF-8"?> <anychart> <dashboard> <view type="Dashboard"> <title> <text>USA Drilldown Map</text> </title> <hbox width="100%" height="100%"> <view name="Country" type="Chart" width="50%" height="100%" source="USA" /> <view name="State" type="Chart" width="50%" height="100%" /> </hbox> </view> </dashboard> </anychart>
如何創(chuàng)建儀表盤,請移步 AnyChart應(yīng)用教程一
然后創(chuàng)建一張國家地圖,示例代碼如下:
<chart plot_type="Map" name="USA"> <chart_settings> <title enabled="false" /> <chart_background enabled="false" /> <data_plot_background enabled="false" /> </chart_settings> <data_plot_settings> <map_series source="usa/country/states.amap"> <projection type="orthographic" /> <undefined_map_region palette="Default"> <actions> <action type="updateView" view="State" source_mode="internalData" source="State"> <replace token="{$region_amap}">{%REGION_ID}</replace> <replace token="{$title}">{%REGION_NAME}</replace> </action> </actions> </undefined_map_region> </map_series> </data_plot_settings> </chart>
如圖所示,我們已經(jīng)定義好了第一個地圖:
這里我們要為所有的州配置參數(shù)化XML,{$title} 和 {$region_amap} 將由主要的圖表 <action>處理:
<chart plot_type="Map" name="State"> <chart_settings> <title> <text>{$title}</text> </title> <chart_background enabled="false" /> <data_plot_background enabled="false" /> </chart_settings> <data_plot_settings> <map_series source="usa/states/counties/{$region_amap}.amap"> <projection type="orthographic" /> <undefined_map_region palette="Default" /> </map_series> </data_plot_settings> </chart>
下面我們將 "State"放入<charts>部分就可以了,如圖所示:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件