Giter Site home page Giter Site logo

Comments (9)

fhurta avatar fhurta commented on May 5, 2024 1

Was any feature request created out of this? I would need this feature too

from plotly.js.

etpinard avatar etpinard commented on May 5, 2024

Should be doable with plotly_hover event handler and an appropriate shape. Here's an example with a click event handler: http://chriddyp.github.io/interactive-heatmaps/ .

In the future, implementation questions should be asked on Stack Overflow (tagged plotly) or community.plot.ly (tagged plotly-js). GitHub issues are reserved for bugs reports and feature requests.

from plotly.js.

prog8 avatar prog8 commented on May 5, 2024

Thanks for your response. I'll keep in mind that I should write on Stack Overflow or community.plot.ly. From one side I wrote a question but from the other side it is feature request since Plotly doesn't support this out of the box.

from plotly.js.

etpinard avatar etpinard commented on May 5, 2024

Correct.

#53 is a feature request, which is totally fine in this repo. 🍻

from plotly.js.

leifdejong avatar leifdejong commented on May 5, 2024

Hi! Hope you guys are well and not too overworked. I wanted to follow up to this question and see if you guys had an example for how this would work or a codepen or feature that I missed while digging through the documentation... Please let us know if you have any direction as this seems to be a common struggle. Thank a lot!

from plotly.js.

fhurta avatar fhurta commented on May 5, 2024

I put together some working example using shape, check this out

from plotly.js.

leifdejong avatar leifdejong commented on May 5, 2024

@fhurta you're the man! Thanks

from plotly.js.

jayfresh avatar jayfresh commented on May 5, 2024

@fhurta 👍

from plotly.js.

backgroundColor avatar backgroundColor commented on May 5, 2024
const gd = this.refs.headerLine
const d3 = Plotly.d3
gd.on('plotly_hover', (data) => {
      const originTooltip = document.querySelector('.hovertext')
      const rectH = d3.select(gd).select('.xy').select('rect').attr('height')
      const transformAttr = originTooltip.getAttribute('transform')
      const translate = /translate\(\s*([^\s,)]+)[ ,]([^\s,)]+)/.exec(transformAttr)
      const translateX = parseInt(translate[1])
      const translateY = parseInt(translate[2])
      const xAxisH = d3.select(gd).select('.xaxislayer')[0][0]
      const xAxisTranslateY = /translate\(\s*([^\s,)]+)[ ,]([^\s,)]+)/.exec(xAxisH.getAttribute('transform'))[2]
      let toolMarker, sheet
      const stylesheets = document.styleSheets
      if (document.querySelector('.toolMarker')) {
        toolMarker = document.querySelector('.toolMarker')
      } else {
        toolMarker = document.createElement('div')
        document.createElement('div')
        toolMarker.style.position = 'absolute'
        toolMarker.style.zIndex = '10000'
        toolMarker.setAttribute('class', 'toolMarker')
        this.refs.headerLine.appendChild(toolMarker)
      }
      toolMarker.style.left = `${translateX - 3}px`
      toolMarker.style.top = `${translateY - 3}px`

      if (stylesheets) {
        sheet = stylesheets[stylesheets.length - 1]
      } else {
        const style = document.createElement('style')
        document.head.appendChild(style)
      }
      const cssRulesLength = sheet.cssRules.length
      sheet.insertRule(`.toolMarker::after{height:${rectH}px; top:${xAxisTranslateY - translateY}px}`, cssRulesLength)
    }).on('plotly_unhover', (data) => {
      const sheet = document.styleSheets[document.styleSheets.length - 1]
      sheet.deleteRule(sheet.cssRules.length - 1)
      document.querySelector('.toolMarker').remove()
    })

I passsed this method to achieve

from plotly.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.