简体   繁体   English

在页面上放置多个raphael.js对象

[英]Placing multiple raphael.js objects on a page

I am new to raphael.js and want to use it to make small pie charts that show the progress percentage. 我是raphael.js的新手,并希望使用它制作显示进度百分比的小饼图。 I have prepared the function to plot the chart and it works well if I have only one chart on the page. 我已经准备好绘制图表的功能,并且如果页面上只有一张图表,它会很好地工作。 However, when I add additional elements, the charts overlap. 但是,当我添加其他元素时,图表会重叠。 I iterate through the .min-pie-chart elements: 我遍历.min-pie-chart元素:

$(".min-pie-chart").each(function () {
  var value = $(this).data("percent");
  Raphael($(this), 20, 20).minPieChart(10, 10, 8, value, "rgb(89,185,86)", "rgb(75,175,72)");
});

I'm guessing this is a css issue which is new to me as well. 我猜这是一个CSS问题,对我来说也是新问题。

A demonstration is located here . 这里有一个示范。

Any help is appreciated. 任何帮助表示赞赏。

You need to adjust its location based on some factor. 您需要根据某些因素调整其位置。 In this case, maybe it makes sense to adjust an offset according to its index in the list. 在这种情况下,可能有必要根据列表中的索引调整偏移量。

You can get an index from the anonymous function... 您可以从匿名函数获取索引...

each(function (index) {

then 然后

minPieChart(30, (index + 1) * 20, 8, value,

as an example. 举个例子。 jsfiddle jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM