Giter Club home page Giter Club logo

Comments (4)

arski avatar arski commented on May 18, 2024

Actually, you can also stop the loop once you've found the correct series that needs to have the tooltip shown. Something like the following should do:

    detail.sort(sortFn).forEach( function(d) {

        if (domainMouseY > d.value.y0 && domainMouseY < d.value.y0 + d.value.y && !activeItem) {
            d.formattedYValue = (this.yFormatter.constructor == Array) ?
                this.yFormatter[detail.indexOf(d)](d.value.y) :
                this.yFormatter(d.value.y);

            d.graphX = graphX;
            d.graphY = graph.y(d.value.y0 + d.value.y);

            activeItem = d;
            return;
        }

    }, this );

from rickshaw.

arski avatar arski commented on May 18, 2024

oh and then, you can do

    if (this.visible && activeItem) {
        this.render( {
            activeItem: activeItem,
            domainX: domainX,
            formattedXValue: formattedXValue,
            mouseX: eventX,
            mouseY: eventY
        } );
    }

and the render function then doesnt need any loops

render: function(args) {

    var activeItem = args.activeItem;
    var domainX = args.domainX;

    var mouseX = args.mouseX;
    var mouseY = args.mouseY;

    var formattedXValue = args.formattedXValue;

    var xLabel = document.createElement('div');
    xLabel.className = 'x_label';
    xLabel.innerHTML = formattedXValue;
    this.element.appendChild(xLabel);

    var item = document.createElement('div');
    item.className = 'item';
    item.innerHTML = this.formatter(activeItem.series, domainX, activeItem.value.y, formattedXValue, activeItem.formattedYValue, activeItem);
    item.style.top = this.graph.y(activeItem.value.y0 + activeItem.value.y) + 'px';

    this.element.appendChild(item);

    var dot = document.createElement('div');
    dot.className = 'dot';
    dot.style.top = item.style.top;
    dot.style.borderColor = activeItem.series.color;

    this.element.appendChild(dot);

    item.className = 'item active';
    dot.className = 'dot active';

    this.show();

    if (typeof this.onRender == 'function') {
        this.onRender(args);
    }
},

from rickshaw.

arski avatar arski commented on May 18, 2024

and my apologies, I'm still not too familiar with github in terms of providing patches.. its kinda complicated when i have quite a few more changes to the file too that are unrelated.. hope this works.

from rickshaw.

dchester avatar dchester commented on May 18, 2024

All good points.

Things evolved as they did because we started with a bunch of use cases where it was actually useful to show details for all of the series for a given time at once. Then we hid "inactive" tooltips by default, but the consumer can still show them by overriding some CSS.

But I think that's mostly an edge case. We'll pursue going forward with the optimizations you suggested, and maybe just provide an example subclass that shows all the data for a given time at once if that's what to do.

and my apologies, I'm still not too familiar with github in terms of providing patches.. its kinda complicated when i have quite a few more changes to the file too that are unrelated..

Pull requests are pretty awesome: https://help.github.com/articles/using-pull-requests/

from rickshaw.

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.