如何在HighCharts中的每一列添加表

发布于 2025-02-11 14:28:19 字数 3795 浏览 1 评论 0原文

我正在使用Highcharts使用图表钻对。我可以显示具有钻取的列图。要求是在单击每一列之后,与该列的详细信息有关的表需要显示一些数据,即在图表下方的Barchart。我无法创建该表。想更喜欢 ant table ,但是任何表都值得赞赏,并希望与表合影,并希望与表合影。关闭按钮。有人可以帮我吗?谢谢您

<script src="http://github.highcharts.com/highcharts.js"></script>
<script src="http://github.highcharts.com/modules/drilldown.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

$(function () {    

    // Create the chart
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Basic drilldown'
        },
        xAxis: {
            type: 'category'
        },

        legend: {
            enabled: true
        },

        plotOptions: {
            series: {
                borderWidth: 0,
                dataLabels: {
                    enabled: true,
                    style: {
                        color: 'white',
                        textShadow: '0 0 2px black, 0 0 2px black'
                    }
                },
                stacking: 'normal'
            }
        },

        series: [{
            name: 'Things',
            data: [{
                name: 'Animals',
                y: 5,
                drilldown: 'animals'
            }, {
                name: 'Fruits',
                y: 2,
                drilldown: 'fruits'
            }, {
                name: 'Cars',
                y: 4,
                drilldown: 'cars'
            }]
        }, {
            name: 'Things2',
            data: [{
                name: 'Animals',
                y: 1,
                drilldown: 'animals2'
            }, {
                name: 'Fruits',
                y: 5,
                drilldown: 'fruits2'
            }, {
                name: 'Cars',
                y: 2,
                drilldown: 'cars2'
            }]
        }],
        drilldown: {
            activeDataLabelStyle: {
                color: 'white',
                textShadow: '0 0 2px black, 0 0 2px black'
            },
            series: [{
                id: 'animals',
                name: 'Animals',
                data: [
                    ['Cats', 4],
                    ['Dogs', 2],
                    ['Cows', 1],
                    ['Sheep', 2],
                    ['Pigs', 1]
                ]
            }, {
                id: 'fruits',
                name: 'Fruits',
                data: [
                    ['Apples', 4],
                    ['Oranges', 2]
                ]
            }, {
                id: 'cars',
                name: 'Cars',
                data: [
                    ['Toyota', 4],
                    ['Opel', 2],
                    ['Volkswagen', 2]
                ]
            },{
                id: 'animals2',
                name: 'Animals2',
                data: [
                    ['Cats', 3],
                    ['Dogs', 5],
                    ['Cows', 6],
                    ['Sheep', 2],
                    ['Pigs', 2]
                ]
            }, {
                id: 'fruits2',
                name: 'Fruits2',
                data: [
                    ['Apples', 1],
                    ['Oranges', 5]
                ]
            }, {
                id: 'cars2',
                name: 'Cars2',
                data: [
                    ['Toyota', 2],
                    ['Opel', 3],
                    ['Volkswagen', 2]
                ]
            }]
        }
    })
});

添加了代码在这里。当您单击钻down时,我想看看桌子,然后单击任何一个猫都与所有猫一起显示表格。

I am using highcharts as for using the charts drilldown. I can display the column graph which has a drilldown. The requirement is after clicking over each column, a table related to that column's detailed information needs to be displayed with some data concerning that barchart below the chart. I am unable to create that Table. Would like to prefer ant table, but any table is appreciated, and would like to close the table with a close button. Can someone please help me with this? Thank you

<script src="http://github.highcharts.com/highcharts.js"></script>
<script src="http://github.highcharts.com/modules/drilldown.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

$(function () {    

    // Create the chart
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Basic drilldown'
        },
        xAxis: {
            type: 'category'
        },

        legend: {
            enabled: true
        },

        plotOptions: {
            series: {
                borderWidth: 0,
                dataLabels: {
                    enabled: true,
                    style: {
                        color: 'white',
                        textShadow: '0 0 2px black, 0 0 2px black'
                    }
                },
                stacking: 'normal'
            }
        },

        series: [{
            name: 'Things',
            data: [{
                name: 'Animals',
                y: 5,
                drilldown: 'animals'
            }, {
                name: 'Fruits',
                y: 2,
                drilldown: 'fruits'
            }, {
                name: 'Cars',
                y: 4,
                drilldown: 'cars'
            }]
        }, {
            name: 'Things2',
            data: [{
                name: 'Animals',
                y: 1,
                drilldown: 'animals2'
            }, {
                name: 'Fruits',
                y: 5,
                drilldown: 'fruits2'
            }, {
                name: 'Cars',
                y: 2,
                drilldown: 'cars2'
            }]
        }],
        drilldown: {
            activeDataLabelStyle: {
                color: 'white',
                textShadow: '0 0 2px black, 0 0 2px black'
            },
            series: [{
                id: 'animals',
                name: 'Animals',
                data: [
                    ['Cats', 4],
                    ['Dogs', 2],
                    ['Cows', 1],
                    ['Sheep', 2],
                    ['Pigs', 1]
                ]
            }, {
                id: 'fruits',
                name: 'Fruits',
                data: [
                    ['Apples', 4],
                    ['Oranges', 2]
                ]
            }, {
                id: 'cars',
                name: 'Cars',
                data: [
                    ['Toyota', 4],
                    ['Opel', 2],
                    ['Volkswagen', 2]
                ]
            },{
                id: 'animals2',
                name: 'Animals2',
                data: [
                    ['Cats', 3],
                    ['Dogs', 5],
                    ['Cows', 6],
                    ['Sheep', 2],
                    ['Pigs', 2]
                ]
            }, {
                id: 'fruits2',
                name: 'Fruits2',
                data: [
                    ['Apples', 1],
                    ['Oranges', 5]
                ]
            }, {
                id: 'cars2',
                name: 'Cars2',
                data: [
                    ['Toyota', 2],
                    ['Opel', 3],
                    ['Volkswagen', 2]
                ]
            }]
        }
    })
});

Added the code here. I would like to see the table when you click on the drilldown and click either cats to show a table with with all the cats.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沐歌 2025-02-18 14:28:19

您可以从这里开始在html中制作表格,内部 cart a>在表中控制内容。

  chart: {
    type: 'column',
    events: {
      drilldown: function(e) {
        if (e.point.name === 'Animals') {
          firstDiv.style.display = 'block';
          secondDiv.style.display = 'none';
          thirdDiv.style.display = 'none';
        } else if (e.point.name === 'test') {
          secondDiv.style.display = 'block';
          firstDiv.style.display = 'none';
          thirdDiv.style.display = 'none';
        } else if (e.point.name === 'test2') {
          thirdDiv.style.display = 'block';
          firstDiv.style.display = 'none';
          secondDiv.style.display = 'none';
        }

        setTimeout(function() {
          chart.setSize(300);
        }, 0);
      },
      drillup: function() {
        firstDiv.style.display = 'none';
        secondDiv.style.display = 'none';
        thirdDiv.style.display = 'none';

        this.setSize(null, null);
      }
    }
  },

演示: https://jsfiddle.net.net/blacklabel/blacklabel/jqcccpv6ox/

You can start from here to make table in HTML, and inside chart.events.drilldown to control content in tables.

  chart: {
    type: 'column',
    events: {
      drilldown: function(e) {
        if (e.point.name === 'Animals') {
          firstDiv.style.display = 'block';
          secondDiv.style.display = 'none';
          thirdDiv.style.display = 'none';
        } else if (e.point.name === 'test') {
          secondDiv.style.display = 'block';
          firstDiv.style.display = 'none';
          thirdDiv.style.display = 'none';
        } else if (e.point.name === 'test2') {
          thirdDiv.style.display = 'block';
          firstDiv.style.display = 'none';
          secondDiv.style.display = 'none';
        }

        setTimeout(function() {
          chart.setSize(300);
        }, 0);
      },
      drillup: function() {
        firstDiv.style.display = 'none';
        secondDiv.style.display = 'none';
        thirdDiv.style.display = 'none';

        this.setSize(null, null);
      }
    }
  },

Demo: https://jsfiddle.net/BlackLabel/jqcpv6ox/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文