我amCharts
在我的 Web 应用程序中使用该库来呈现所有图表。他们工作正常,但我需要mapChart
在页面上添加一个。我不像mapCharts
其他图表那样熟悉,因为使用它似乎需要与其他图表不同的方法。
请查看我的代码设置并查看我的代码中可能出现的问题。
以下代码将库添加到索引文件中:
<script type="text/javascript" src="bower_components/ammap3/ammap/ammap.js">
</script>
<script type="text/javascript"
src="bower_components/ammap3/ammap/maps/js/worldLow.js"></script>
我这样写控制器:
.controller('MapChartCtrl', ['$scope', '$timeout', function ($scope, $timeout) {
$scope.amChartOptions = {
type: 'map',
theme: 'blur',
zoomControl: { zoomControlEnabled: false, panControlEnabled: false
},
data: {
map: 'worldLow',
zoomLevel: 3.5,
zoomLongitude: 10,
zoomLatitude: 52,
areas: [
{ title: 'Austria', id: 'AT', color: '#62bbb2', customData: '1
244', groupId: '1'},
{ title: 'Ireland', id: 'IE', color: '#62bbb2', customData: '1
342', groupId: '1'},
{ title: 'Denmark', id: 'DK', color: '#62bbb2', customData: '1
973', groupId: '1'},
{ title: 'Finland', id: 'FI', color: '#62bbb2', customData: '1
573', groupId: '1'},
{ title: 'Sweden', id: 'SE', color: '#62bbb2', customData: '1
084', groupId: '1'},
{ title: 'Great Britain', id: 'GB', color: '#62bbb2',
customData: '1 452', groupId: '1'}
]
},
areasSettings: {
rollOverOutlineColor: "#62bbb2",
rollOverColor: "#62bbb2",
alpha: 0.8,
unlistedAreasAlpha: 0.2,
unlistedAreasColor: "#bfbfbf",
balloonText: '[[title]]: [[customData]] users'},
categoryField: "title",
legend: {
width: '100%',
marginRight: 27,
marginLeft: 27,
equalWidths: false,
backgroundAlpha: 0.3,
backgroundColor: "#bfbfbf",
borderColor: "#bfbfbf",
borderAlpha: 1,
top: 362,
left: 0,
horizontalGap: 10,
data: [
{
title: 'over 1 000 users',
color: '#62bbb2'
},
{
title: '500 - 1 000 users',
color: '#b9f2a1'
},
{
title: '100 - 500 users',
color: '#ed7878'
},
{
title: '0 - 100 users',
color: '#e1e1e1'
}
]
},
export: {
enabled: true
},
pathToImages: 'bower_components/amcharts/dist/amcharts/images/'
}}])
<div class="panel-heading">Map Chart</div>
<div ng-controller="MapChartCtrl" style="height: 400px; width: 100%;">
<am-chart id="MapChart" options="amChartOptions"></am-chart>
</div>