- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我使用了“multilevelpie”图表。由于图表中的数据较少(比如 10 或 1),标签名称正在与另一个合并。
我已附上截图和消息,请考虑并给我一个解决方案
请检查 JsFiddle 重新生成的问题.. & 我也附上了图片,奇怪的错误
FusionCharts.ready(function () {
var topProductsChart = new FusionCharts({
type: 'multilevelpie',
renderAt: 'chart-container',
id : "myChart",
width: '500',
height: '500',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Split of Top Products Sold",
"subCaption": "Last Quarter",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"baseFontColor" : "#333333",
"baseFont" : "Helvetica Neue,Arial",
"basefontsize": "9",
"subcaptionFontBold": "0",
"bgColor" : "#ffffff",
"canvasBgColor" : "#ffffff",
"showBorder" : "0",
"showShadow" : "0",
"showCanvasBorder": "0",
"pieFillAlpha": "60",
"pieBorderThickness": "2",
"hoverFillColor": "#cccccc",
"pieBorderColor": "#ffffff",
"useHoverColor": "1",
"showValuesInTooltip": "1",
"showPercentInTooltip": "0",
"numberPrefix": "$",
"plotTooltext": "$label, $$valueK, $percentValue"
},
"category": [
{
"label": "Sales by category",
"color": "#ffffff",
"value": "150",
"category": [
{
"label": "Food & {br}Beverages",
"color": "#f8bd19",
"value": "55.5",
"category": [
{
"label": "Breads",
"color": "#f8bd19",
"value": "11.1"
},
{
"label": "Juice",
"color": "#f8bd19",
"value": "27.75"
},
{
"label": "Noodles",
"color": "#f8bd19",
"value": "19.99"
},
{
"label": "Seafood",
"color": "#f8bd19",
"value": "0"
}
]
},
{
"label": "Apparel &{br}Accessories",
"color": "#e44a00",
"value": "42",
"category": [
{
"label": "Sun Glasses",
"color": "#e44a00",
"value": "62.08"
},
{
"label": "Clothing",
"color": "#e44a00",
"value": "18.9"
},
{
"label": "Handbags",
"color": "#e44a00",
"value": "6.3"
},
{
"label": "Shoes",
"color": "#e44a00",
"value": "6.72"
}
]
},
{
"label": "Baby {br}Products",
"color": "#008ee4",
"value": "22.5",
"category": [
{
"label": "Bath &{br}Grooming",
"color": "#008ee4",
"value": "9.45"
},
{
"label": "Feeding",
"color": "#008ee4",
"value": "16.3"
},
{
"label": "Diapers",
"color": "#008ee4",
"value": "76.75"
}
]
},
{
"label": "Electronics",
"color": "#33bdda",
"value": "30",
"category": [
{
"label": "Laptops",
"color": "#33bdda",
"value": "8.1"
},
{
"label": "Televisions",
"color": "#33bdda",
"value": "10.5"
},
{
"label": "SmartPhones",
"color": "#33bdda",
"value": "11.4"
}
]
}
]
}
]
}
});
topProductsChart.render();
});
最佳答案
让我们指出我们在这里的担忧:
dataRefiner()
,它只是提炼出数据源中的零和空数据。 :) {br}
标记附加到标签,使其断开线条并容纳在弧中。在非常薄的切片中没有多大用处。font-size
缩小到刚好可以容纳的范围。 Docs可能会有用。创建一个解决方法以适应 avobe 提到的一些修复。此代码与 FC 3.11.0 兼容。扩展对以下内容的支持:
现在甚至在MultiLevel Pie charts .在 FusionCharts 原生支持之前,这是一个临时的近似解决方法。
运行以下代码片段或使用 fiddle :
/*
Recursively removes the data containing falsy values.
@param data {Object} - The original data.
@return {Object} - The refined data.
*/
function dataRefiner(data) {
var i,
category = data.category,
len = category && category.length;
for (i = 0; i < len; i += 1) {
elem = category[i];
if (elem.category) {
dataRefiner(elem);
} else if (!Number(elem.value)) {
category.splice(i, 1);
i -= 1;
len -= 1;
}
}
return data;
}
var overlapManager = (function() {
return function(chartRef, dataSet) {
var jsonData = chartRef.getJSONData(),
chartAttrs = jsonData.chart;
if (Number(chartAttrs.enablesmartlabels) === 0 || Number(chartAttrs.managelabeloverflow) === 0) {
return;
}
/*
* Returns the point to point distance for two points.
* @return {Number}
*/
function dist_point(point1, point2) {
var math = Math;
return math.sqrt((math.pow((point1.x - point2.x), 2)) + (math.pow((point1.y - point2.y), 2)))
}
/*
* given a radius, center, and two ends of a chord.
* return: {
inner: Coordinate of the dipped point on the inner circle.
outer: coordinate of the dipped point on the outer circle.
}
*/
function give_dips(center_circle, angle, innerRadius, outerRadius) {
var math = Math,
res = {
inner: {},
outer: {}
},
getExtreme = function(radius) {
return {
x: center_circle.x + (radius * math.cos(angle)),
y: center_circle.y - (radius * math.sin(angle))
}
};
if (center_circle) {
res.inner = getExtreme(innerRadius);
res.outer = getExtreme(outerRadius);
}
return res;
}
/*
* Manages the overlapping of the texts in ML pie chart.
* @params: elem - {Object} - Internal store for the graphic and configurations.
* @params: chartRef - {Object} - The reference for the chart.
*/
function wrapText(elem, chartRef) {
var conf = elem && elem.config || {},
smartLabel = chartRef.jsVars.instanceAPI.linkedItems.smartLabel,
jsonData = chartRef.getJSONData(),
chart = jsonData.chart,
useEllipsesWhenOverflow = chart && !!Number(chart.useellipseswhenoverflow),
math = Math,
graphics = elem && elem.graphics,
ringpath = graphics.element && graphics.element.attr('ringpath') || [],
center_circle = {
x: ringpath[0],
y: ringpath[1]
},
innerRadius = ringpath[3],
outerRadius = ringpath[2],
strechAngle = conf.angleStrech,
angle = (2 * math.PI) - conf.startAngle - (strechAngle / 2),
dipPoints = give_dips(center_circle, angle, innerRadius, outerRadius),
center = {
x: (dipPoints.inner.x + dipPoints.outer.x) / 2,
y: (dipPoints.inner.y + dipPoints.outer.y) / 2
},
textObj,
radius = math.min(dist_point(center, center_circle) * math.sin(strechAngle / 2) - (conf.borderWidth || 0),
dist_point(center, dipPoints.inner)),
offset = radius * math.cos(math.PI / 4),
side = math.sqrt(2) * radius;
smartLabel.useEllipsesOnOverflow(useEllipsesWhenOverflow);
textObj = smartLabel.getSmartText(conf.displayValue, side, side);
if (graphics.label && graphics.label.getBBox().width > side) {
(innerRadius !== 0) && graphics.label
.attr({
text: textObj.text,
});
}
}
if (!dataSet) {
dataSet = chartRef.jsVars.instanceAPI.components.dataset[0];
}
var data = dataSet.components.data || [],
len = data.length,
i;
for (i = 0; i < len; i += 1) {
// recursively traverse the graphical objects.
overlapManager(chartRef, data[i]);
}
wrapText(dataSet, chartRef);
}
})();
FusionCharts.ready(function() {
topProductsChart = new FusionCharts({
type: 'multilevelpie',
renderAt: 'chart-container',
id: "myChart",
width: '500',
height: '500',
dataFormat: 'json',
dataSource: dataRefiner(data),
events: {
"rendered": function(e, a) {
if (FusionCharts.version.join('.') !== '3.11.0') {
// It access the internal architechural properties of fusioncharts which might change in future release.
console.log('overlapManager() is a work around supported for FusionCharts 3.11.0 and might not work in this version.');
}
overlapManager(e.sender);
}
}
});
topProductsChart.render();
});
var topProductsChart,
data = {
"chart": {
"useEllipsesWhenOverflow": "1",
"caption": "Split of Top Products Sold",
"subCaption": "Last Quarter",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"baseFontColor": "#333333",
"baseFont": "Helvetica Neue,Arial",
"basefontsize": "9",
"subcaptionFontBold": "0",
"bgColor": "#ffffff",
"canvasBgColor": "#ffffff",
"showBorder": "0",
"showShadow": "0",
"showCanvasBorder": "0",
"pieFillAlpha": "60",
"pieBorderThickness": "2",
"hoverFillColor": "#cccccc",
"pieBorderColor": "#ffffff",
"useHoverColor": "1",
"showValuesInTooltip": "1",
"showPercentInTooltip": "0",
"numberPrefix": "$",
"plotTooltext": "$label, $$valueK, $percentValue"
},
"category": [{
"label": "Sales by category",
"color": "#ffffff",
"value": "150",
"category": [{
"label": "Food & {br}Beverages",
"color": "#f8bd19",
"value": "55.5",
"category": [{
"label": "Breads",
"color": "#f8bd19",
"value": "11.1"
}, {
"label": "Juice",
"color": "#f8bd19",
"value": "27.75"
}, {
"label": "Noodles",
"color": "#f8bd19",
"value": "19.99"
}, {
"label": "Seafood",
"color": "#f8bd19",
"value": "0"
}]
}, {
"label": "Apparel &{br}Accessories",
"color": "#e44a00",
"value": "42",
"category": [{
"label": "Sun Glasses",
"color": "#e44a00",
"value": "62.08"
}, {
"label": "Clothing",
"color": "#e44a00",
"value": "18.9"
}, {
"label": "Han",
"color": "#e44a00",
"value": "6.3"
}, {
"label": "Shoes",
"color": "#e44a00",
"value": "6.72"
}]
}, {
"label": "Baby {br}Products",
"color": "#008ee4",
"value": "22.5",
"category": [{
"label": "Bath & Grooming",
"color": "#008ee4",
"value": "9.45"
}, {
"label": "Feeding",
"color": "#008ee4",
"value": "16.3"
}, {
"label": "Diapers",
"color": "#008ee4",
"value": "76.75"
}]
}, {
"label": "Electronics",
"color": "#33bdda",
"value": "30",
"category": [{
"label": "Laptops",
"color": "#33bdda",
"value": "8.1"
}, {
"label": "Televisions",
"color": "#33bdda",
"value": "10.5"
}, {
"label": "SmartPhones",
"color": "#33bdda",
"value": "11.4"
}]
}]
}]
};
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<!--
Sales by category shown using Multi-level Pie Chart.
-->
<div id="chart-container">FusionCharts will render here</div>
您也可以引用融合 treeMap chart来表示树和分层数据。
关于javascript - 融合图表 multilevelpie 文本 chop/重叠问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38627370/
我正在使用 onclick javascript 方法,动态内容如下: onclick="adviceEvent('${advice?.content}');" 建议内容介于字符串之间,例如: Che
我想 chop 一个具有字符限制的字符串,并且最后一个字符应该是空格的条件(这样我就没有被 chop 的单词) 示例: var sentence = "The string that I want t
我正在使用省略号 chop 文本并在工具提示上显示整个文本。如果文本溢出,则仅显示工具提示。工具提示在 Chrome 中看起来不错,但在 IE 和 Firefox 中却不行。在 IE 中,工具提示文本
我正在使用带有 rails ( http://jrvis.com/trunk8/#toggle ) 的 trunk8 jquery 插件,它只会 chop 前几个句子,直到第一个中断空格。这是我的代码
Readmore Js 只折叠 div block 而不折叠文本。请帮助我 chop 文本和 div 容器,而不仅仅是 div。非常感谢 London is the most popul
我有一个 div,它会动态填充一些可能包含或不包含链接的文本。 例如: Welcome to Stackoverflow. Someone will provide an answer to
作为一些背景 使用 Material UI Multiple Select,您可以 chop 选择后显示的值,而不是转到另一行(通过将 renderValue 设置为 .join selected 选
有人可以向我解释一下为什么不能将包含空格的字符串作为参数传递到 JavaScript 函数中吗? 这是我的代码,显示了这个问题,只需将鼠标悬停在链接上,您就会看到只有“mario”显示为标题,而不是“
我在打印模块内容时遇到了问题,这发生在所有浏览器上。当我打印模态内容时,它只预览第一页,第一页之后的任何内容都会被切断。我已经尝试在 Chrome 打印模拟器中进行调试,但仍然无法找到解决方案。 在某
我正在尝试检测是否使用 JS chop 了文本。解决方案mentioned here除了下面的边缘情况外,效果很好。您会注意到,如果文本在视觉上被 chop ,则鼠标悬停的第一个 block 将返回
我制作的模态面临一个罕见的问题。我有一个iframe,可以在该模式下加载嵌入式youtube视频,它在为测试该视频而创建的单独HTML文件(空白)上运行良好。 当我尝试将其加载到实际网站的本地模板上时
我有一个 Javascript,它从两个 HTML 下拉列表中读取文本,删除所有特殊字符,然后将文本存储在变量中。下拉列表中的文本来自 JSON 文件。问题是,只要下拉列表中的文本有撇号,Javasc
在node和chrome中,下面的代码只给了我10个堆栈帧,而我期望的是100个。有什么方法可以打印整个堆栈吗? function blowUp(n) { if(n > 100) {
所以我有一个对象数组,问题是返回的名称很长。我怎样才能让名字结果看起来像 returnedArray: [ {name:'reallyy..',age:'28',hobby:'blah'},{name
我遇到了一些字符串溢出其容器的问题。我当然可以使用溢出:隐藏,但它看起来不太好,因为我更喜欢文本溢出:省略号。然而,对此的跨平台支持充其量是不确定的,而且我发现的现有解决方案不允许字符串在包含空格时换
我正在编写 jQuery 应用程序,但遇到了障碍。 我需要我的双行描述简介能够在浏览器大小调整时随着文本回流而做出响应。下面的示例成功地收缩了字符串的大小,并在缩小浏览器时替换为省略号。但是当您扩大浏
当前版本: def chop(ar,size): p=len(ar)/size for i in xrange(p): yield ar[(i*size):((i+1)
My Codepen if("matchMedia" in window) { if(window.matchMedia("(max-width: 533px)").matches) {
我这里遇到了一些问题。 我基本上是在 div 中循环项目,以便每个项目都有一个可以使用的键,这样当单击图标时,就会出现一个编辑模式并填充所选项目的数据。 这可行,但我想为我的跨度添加功能 {{ $no
我有一个代码块,其中包含以下形式的行: 在接收端,我有一个像这样抓取数据的文档: $title = $_POST['title']; 这将被插入到数据库中,但任何包含撇号的“标题”都会在撇号处被
我是一名优秀的程序员,十分优秀!