Fusioncharts饼图无填充颜色

时间:2016-08-08 02:54:54

标签: javascript charts pie-chart fusioncharts

我使用fusioncharts创建了以下fiddle。我无法理解为什么图表的填充颜色是透明的。

示例的HTML代码段:



<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>

<!-- A pie3D Chart showing percentage visiting for different age groups last year in Harry's Supermart website. Attribute : # showPercentValues set to 1 to show the values w.r.t percentage of total visits. -->

<head>
  <base href="/">
</head>
<div id="chart-container">FusionCharts will render here</div>
&#13;
"caption": "Age profile of website visitors",
"subCaption": "Last Year",
"startingAngle": "120",
"showLabels": "0",
"showLegend": "1",
"enableMultiSlicing": "0",
"slicingDistance": "15",
"showPercentValues": "1",
"showPercentInTooltip": "0",
"plotTooltext": "Age group : $label<br>Total visit : $datavalue",
"theme": "fint"
&#13;
&#13;
&#13;

使用以下图表级别属性:

m <- sum(colSums(matrix(grepl("J|Q|K", poker_face), nrow = 2)) == 2)

1 个答案:

答案 0 :(得分:0)

问题是由于HTML头中使用了base标记。

正如here所说:

  

问题主要不在于FusionCharts - 它是一个通用的SVG问题。在SVG中,当渐变颜色应用于元素时,它实际上“引用”页面上的另一个渐变元素。这有点类似于链接在页面上引用标签的方式。

     

现在,当您设置页面时,引用是   去干草。渐变现在引用URL为的元素   在您的基本标记中提供。

然而,FusionCharts为此提供了解决方案。使用'FusionCharts.options.SVGDefinitionURL ='绝对';'在你的JavaScript代码中解决这个问题。您可以参考此fiddle或查看下面的代码段:

FusionCharts.ready(function() {
  FusionCharts.options.SVGDefinitionURL = 'absolute';
  var demographicsChart = new FusionCharts({
    type: 'pie2d',
    renderAt: 'chart-container',
    width: '450',
    height: '300',
    dataFormat: 'json',
    dataSource: {
      "chart": {
        "caption": "Age profile of website visitors",
        "subCaption": "Last Year",
        "startingAngle": "120",
        "showLabels": "0",
        "showLegend": "1",
        "enableMultiSlicing": "0",
        "slicingDistance": "15",
        "showPercentValues": "1",
        "showPercentInTooltip": "0",
        "plotTooltext": "Age group : $label<br>Total visit : $datavalue",
        "theme": "fint"
      },
      "data": [{
        "label": "Teenage",
        "value": "1250400"
      }, {
        "label": "Adult",
        "value": "1463300"
      }, {
        "label": "Mid-age",
        "value": "1050700"
      }, {
        "label": "Senior",
        "value": "491000"
      }]
    }
  });
  demographicsChart.render();
});
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<!-- A pie3D Chart showing percentage visiting for different age groups last year in Harry's Supermart website. Attribute : # showPercentValues set to 1 to show the values w.r.t percentage of total visits. -->

<head>
  <base href="/">
</head>
<div id="chart-container">FusionCharts will render here</div>

希望这有帮助。