Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用传单上的Charts.js对饼图进行聚类_Javascript_Leaflet_Pie Chart_Markerclusterer_Chart.js - Fatal编程技术网

Javascript 使用传单上的Charts.js对饼图进行聚类

Javascript 使用传单上的Charts.js对饼图进行聚类,javascript,leaflet,pie-chart,markerclusterer,chart.js,Javascript,Leaflet,Pie Chart,Markerclusterer,Chart.js,我正在尝试使用下面的代码创建一个带有饼图的集群映射,但没有成功 markercluster = L.markerClusterGroup({maxclustersRadius: 2 * rmax //,iconCreateFunction: testcluster } // add a pie chart here with Chart.js }), 如您所见,我尝试在iconCreateFunction选项中创建一个自

我正在尝试使用下面的代码创建一个带有饼图的集群映射,但没有成功

markercluster = L.markerClusterGroup({maxclustersRadius: 2 * rmax //,iconCreateFunction: testcluster } // add a pie chart here with Chart.js
                                     }),
如您所见,我尝试在iconCreateFunction选项中创建一个自定义图表作为testcluster

testcluster函数如下所示:

function testcluster(cluster) {

var ctx = document.getElementById("marker-cluster").getContext("2d"),

children = cluster.getAllChildMarkers(),

html = new Chart(ctx).Pie(children,{
//Boolean - Whether we should show a stroke on each segment
segmentShowStroke : true,
//String - The colour of each segment stroke
segmentStrokeColor : "#fff"
}),
//Create the div

myPieChart = new L.DivIcon({ 

html: html,
className: 'marker-cluster'
} );


return myPieChart;

}
我在这里的目的是在缩小时创建一个汇总饼图,并在放大时拆分数据。我检查了D3版本,但发现太复杂了,于是决定使用Charts.js。但任何可行且简单的lib都可以

我已经上传了数据,但我的目的是不使用D3.js

jsfiddle:http://jsfiddle.net/kuof3L5j/


提前感谢。

如果需要帮助,您需要将其放入JSFIDLE中。JSFIDLE是,您知道如何创建JSFIDLE吗?添加js、css和其他资源。打开调试工具,你会看到页面无法加载库。只是更新了它,我无法让gejson工作。