<small id='jRdfk'></small><noframes id='jRdfk'>

      • <bdo id='jRdfk'></bdo><ul id='jRdfk'></ul>

    1. <legend id='jRdfk'><style id='jRdfk'><dir id='jRdfk'><q id='jRdfk'></q></dir></style></legend>
    2. <tfoot id='jRdfk'></tfoot>

      <i id='jRdfk'><tr id='jRdfk'><dt id='jRdfk'><q id='jRdfk'><span id='jRdfk'><b id='jRdfk'><form id='jRdfk'><ins id='jRdfk'></ins><ul id='jRdfk'></ul><sub id='jRdfk'></sub></form><legend id='jRdfk'></legend><bdo id='jRdfk'><pre id='jRdfk'><center id='jRdfk'></center></pre></bdo></b><th id='jRdfk'></th></span></q></dt></tr></i><div id='jRdfk'><tfoot id='jRdfk'></tfoot><dl id='jRdfk'><fieldset id='jRdfk'></fieldset></dl></div>

      如何让 Plotly.js 监听刻度标签的点击事件?

      时间:2023-09-30
      • <bdo id='TOHf4'></bdo><ul id='TOHf4'></ul>
        <tfoot id='TOHf4'></tfoot>
        <i id='TOHf4'><tr id='TOHf4'><dt id='TOHf4'><q id='TOHf4'><span id='TOHf4'><b id='TOHf4'><form id='TOHf4'><ins id='TOHf4'></ins><ul id='TOHf4'></ul><sub id='TOHf4'></sub></form><legend id='TOHf4'></legend><bdo id='TOHf4'><pre id='TOHf4'><center id='TOHf4'></center></pre></bdo></b><th id='TOHf4'></th></span></q></dt></tr></i><div id='TOHf4'><tfoot id='TOHf4'></tfoot><dl id='TOHf4'><fieldset id='TOHf4'></fieldset></dl></div>

        <small id='TOHf4'></small><noframes id='TOHf4'>

      • <legend id='TOHf4'><style id='TOHf4'><dir id='TOHf4'><q id='TOHf4'></q></dir></style></legend>

                <tbody id='TOHf4'></tbody>
                本文介绍了如何让 Plotly.js 监听刻度标签的点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                因此,在此动态图表中,我想在单击任何 Y 轴的刻度标签时更改 Y 轴的最小值和最大值.

                So, in this dynamic chart, I want to change the Y-axis' min and max values when any of the Y-axis' Tick Label is clicked.

                推荐答案

                您可以为所有 y-ticks 添加一个 d3 事件侦听器,并确保 SVG 组获取所有 活动.将整个片段包装在 Plotly 的 afterplot 事件中可确保事件侦听器在更新图形后不会丢失.

                You could add a d3 event listener to all y-ticks and make sure that the SVG group gets all the events. Wrapping the whole snippet in Plotly's afterplot event makes sure that the event listener does not get lost after updating the graph.

                var trace1 = {
                  x: [1, 2, 3, 4], 
                  y: [10, 15, 13, 17], 
                  type: 'scatter'
                };
                var trace2 = {
                  x: [1, 2, 3, 4], 
                  y: [16, 5, 11, 9], 
                  type: 'scatter'
                };
                var data = [trace1, trace2];
                var myPlot = document.getElementById('myDiv');
                Plotly.newPlot(myPlot, data);
                myPlot.on('plotly_afterplot', function(){
                    Plotly.d3.selectAll(".yaxislayer-above").selectAll('text')
                          .on("click", function(d) {
                            alert("Hello, I am " + d.x);
                          });
                });

                .yaxislayer-above {
                  cursor: pointer;
                  pointer-events: all;
                }

                <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
                <div id="myDiv"></div>

                这篇关于如何让 Plotly.js 监听刻度标签的点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Plotly.js:如何避免重叠的轮廓线? 下一篇:如何使用ui-router中的ui-sref将参数传递给控制器

                相关文章

                    <bdo id='HgXng'></bdo><ul id='HgXng'></ul>
                1. <legend id='HgXng'><style id='HgXng'><dir id='HgXng'><q id='HgXng'></q></dir></style></legend>

                  1. <tfoot id='HgXng'></tfoot>

                    <small id='HgXng'></small><noframes id='HgXng'>

                    <i id='HgXng'><tr id='HgXng'><dt id='HgXng'><q id='HgXng'><span id='HgXng'><b id='HgXng'><form id='HgXng'><ins id='HgXng'></ins><ul id='HgXng'></ul><sub id='HgXng'></sub></form><legend id='HgXng'></legend><bdo id='HgXng'><pre id='HgXng'><center id='HgXng'></center></pre></bdo></b><th id='HgXng'></th></span></q></dt></tr></i><div id='HgXng'><tfoot id='HgXng'></tfoot><dl id='HgXng'><fieldset id='HgXng'></fieldset></dl></div>