【问题标题】:Can i create a drill down on category in Fusion-chart?我可以在 Fusion-chart 中创建一个类别的向下钻取吗?
【发布时间】:2017-10-04 14:31:52
【问题描述】:

我正在使用 Fusion-chart 库,

我有一种情况,我想在点击类别的(任何栏/区域)时滚动页面到特定的 div。

这意味着我在一个图表中有 7 个多系列类别(每个类别中有 5 个条形图),每个类别有 7 个单独的图表,我想通过单击该类别区域/条形图将页面滚动到特定的类别图表。

我该如何实现?

我可以在以下节点处理吗?

"categories": [
    {
        "category": [
            {"label": "G Outlooks","link": "JavaScript:funname('go')"},
            {"label": "Instruments","link": "JavaScript:funname('mi')"},
            {"label": "G Services","link": "JavaScript:funname('gs')"},
            {"label": "S Services","link": "JavaScript:funname('ss')"},
            {"label": "P Programs","link": "JavaScript:funname('pp')"},
            {"label": "Resources Availability","link": "JavaScript:funname('rac')"},
            {"label": "Resources Functionality","link": "JavaScript:funname('raf')"}
        ]
    }
],
"dataset": [
    {
        "seriesname": "first",
        "data": [{"value":168},{"value":134},{"value":119},{"value":64},{"value":82},{"value":32},{"value":18}]
    },
    {
        "seriesname": "second",
        "data": [{"value":38},{"value":39},{"value":38},{"value":31},{"value":53},{"value":73},{"value":55}]
    },
    {
        "seriesname": "third",
        "data": [{"value":19},{"value":38},{"value":50},{"value":67},{"value":62},{"value":109},{"value":79}]
    },
    {
        "seriesname": "fourth",
        "data": [{"value":5},{"value":13},{"value":23},{"value":33},{"value":20},{"value":84},{"value":94}]
    },
    {
        "seriesname": "fifth",
        "data": [{"value":4},{"value":10},{"value":4},{"value":39},{"value":17},{"value":39},{"value":75}]
    }
]

更新:

我在类别对象中使用了 link 属性,但它仅在类别名称上添加链接。

【问题讨论】:

  • 不,您不能直接在类别中进行向下钻取,因为融合图表不允许这样做。您必须对系列或系列的数据进行下钻。

标签: javascript jquery fusioncharts


【解决方案1】:

这应该对你有很大帮助!

我已经为每个数据条目创建了链接作为 Javascript 调用,然后使用一些东西将页面滚动到您的较低内容!你可以使用

window.scrollTo()

或者如果您使用 jQuery,那么您可以使用 animate 方法对其进行动画处理

function goto(link){
  window.scrollTo(0, document.querySelector('.' + link ).offsetTop );
}

FusionCharts.ready(function () {
    var topStores = new FusionCharts({
        type: 'bar2d',
        renderAt: 'chart-container',
        width: '400',
        height: '300',
        dataFormat: 'json',
        dataSource: {
            "chart": {
                "caption": "Top 5 Stores by Sales",
                "subCaption": "Last month",
                "yAxisName": "Sales (In USD)",
                "numberPrefix": "$",
                "paletteColors": "#0075c2",
                "bgColor": "#ffffff",
                "showBorder": "0",
                "showCanvasBorder": "0",
                "usePlotGradientColor": "0",
                "plotBorderAlpha": "10",
                "placeValuesInside": "1",
                "valueFontColor": "#ffffff",
                "showAxisLines": "1",
                "axisLineAlpha": "25",
                "divLineAlpha": "10",
                "alignCaptionWithCanvas": "0",
                "showAlternateVGridColor": "0",
                "captionFontSize": "14",
                "subcaptionFontSize": "14",
                "subcaptionFontBold": "0",
                "toolTipColor": "#ffffff",
                "toolTipBorderThickness": "0",
                "toolTipBgColor": "#000000",
                "toolTipBgAlpha": "80",
                "toolTipBorderRadius": "2",
                "toolTipPadding": "5"
            },
            
            "data": [
                {
                    "label": "Bakersfield Central",
                    "link": "JavaScript:goto('p1')",
                    "value": "880000"
                }, 
                {
                    "label": "Garden Groove harbour",
                    "link": "JavaScript:goto('p2')",
                    "value": "730000"
                }, 
                {
                    "label": "Los Angeles Topanga",
                    "link": "JavaScript:goto('p3')",
                    "value": "590000"
                }, 
            ],
        }
    }).render();
});
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>

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

<p class="p0">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it <b>1</b>?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

</p>

<p class="p1">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it <b>1</b>?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

</p>

<p class="p2">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it <b>2</b>?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).



</p>
<p class="p3">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it <b>3</b>?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).



</p>

【讨论】:

  • 在我的情况下它不起作用,原因是我有多个系列图,其中每个类别都有 5 个条形图。
  • 我更新并提到了类别代码,等一下,让我也来一个系列。感谢您的辛勤努力,您在我心中得到了很多尊重。
  • 我已经更新了我的问题并添加了数据源。再次感谢。
猜你喜欢
  • 2013-12-22
  • 1970-01-01
  • 2015-10-13
  • 2017-02-26
  • 2020-01-30
  • 1970-01-01
  • 1970-01-01
  • 2012-01-17
  • 1970-01-01
相关资源
最近更新 更多