如何在 FusionChart js 多层饼中使切片成为链接?

问题描述 投票:0回答:2

我想在饼图中制作可点击的链接。

我使用FusionCharts.js。如何在图表中建立链接?

例如(FusionChart.js 创建带有“海鲜”、“面包”、“服装”、“太阳镜”、“食品和饮料”、“服装和配饰”切片的多层饼图):

FusionCharts.ready(function() {
  var topProductsChart = new FusionCharts({
    type: 'multilevelpie',
    renderAt: 'chart-container',
    id: "myChart",
    width: '400',
    height: '400',
    dataFormat: 'json',
    dataSource: {
      "chart": {
        "theme": "fusion",
        "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",
        "pieRadius": "170"
      },
      "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": "Seafood",
                "color": "#f8bd19",
                "value": "6.66"
              }
            ]
          },
          {
            "label": "Apparel &{br}Accessories",
            "color": "#e44a00",
            "value": "42",
            "category": [{
                "label": "Sun Glasses",
                "color": "#e44a00",
                "value": "10.08"
              },
              {
                "label": "Clothing",
                "color": "#e44a00",
                "value": "18.9"
              },
            ]
          },
        ]
      }]
    }
  });

  topProductsChart.render();
});

现场演示:http://jsfiddle.net/cebu68vt/

我希望这个切片,例如“面包”,成为一个可点击的链接。

javascript fusioncharts
2个回答
1
投票

为了设置到特定饼图的链接,请设置该数据对象的链接属性,这里是一个示例

{
   "label": "Breads",
   "color": "#f8bd19",
   "value": "11.1",
   "link":"https://www.fusioncharts.com/dev"
   }

查看此演示 - http://jsfiddle.net/byzre3vj/

要了解有关此功能的更多信息,请查看此处 - https://www.fusioncharts.com/dev/chart-guide/chart-configurations/drill-down


0
投票

可以使用link属性将切片做成链接

 {
                "label": "Breads",
                "color": "#f8bd19",
                "value": "11.1",
                "link":"n-https://www.fusioncharts.com/dev"
              },
              {
                "label": "Juice",
                "color": "#f8bd19",
                "value": "27.75",
                 "link": "n-http://fusioncharts.com"
              }

查看此演示 - https://jsfiddle.net/2py8z0k7/

在这里你可以看到,当你点击面包和果汁片时,它会打开一个链接值。

要了解更多信息,请查看此处 - https://www.fusioncharts.com/dev/chart-guide/chart-configurations/drill-down#in-a-new-page

© www.soinside.com 2019 - 2024. All rights reserved.