All Downloads are FREE. Search and download functionalities are using the official Maven repository.

assets.js.lib.dygraph-serposcope-plugins.js Maven / Gradle / Ivy

/* 
 * Serposcope - SEO rank checker https://serposcope.serphacker.com/
 * 
 * Copyright (c) 2016 SERP Hacker
 * @author Pierre Nogues 
 * @license https://opensource.org/licenses/MIT MIT License
 */

/* global Dygraph, serposcope */

Dygraph.Plugins.Serposcope = (function () {

    "use strict";
    
    var popover = function () {
    };
    
    popover.prototype.toString = function () {
        return "Serposcope Plugin";
    };
    
    popover.prototype.activate = function (e) {
        
        return {
            select: this.select,
            deselect: this.deselect,
            didDrawChart: this.didDrawChart,
            clearChart: this.clearChart
        };
    };
    
    
    popover.prototype.select = function(e){
        var series = e.dygraph.getHighlightSeries();
        if(series == null || series == ""){
            return;
        }
        
        var point = null;
        for(var i=0; i < e.selectedPoints.length; i++){
            if( e.selectedPoints[i].name == series){
                point = e.selectedPoints[i];
            }
        }
        
        if(point == null){
            return;
        }
        
        if(isNaN(point.canvasx)  || isNaN(point.canvasy)){
            return;
        }
        
        var serieProp = e.dygraph.getPropertiesForSeries(point.name);
        
        var elements = document.getElementsByClassName("dygraph-cplg");
        if(elements.length == 0){
            return;
        }
        
        var div = elements[0];
        
        div.style.display = "block";
        div.innerHTML = 
            '' +  moment(point.xval).format('YYYY-MM-DD') + '
' + '' + serposcope.utils.escapeHTML(point.name) + " : " + serposcope.utils.escapeHTML(point.yval) + ''; div.style.left = (parseInt(point.canvasx - (div.offsetWidth+10))) + 'px'; div.style.top = (parseInt(point.canvasy) - 10) + 'px'; div.style.borderColor = serieProp.color; }; popover.prototype.deselect = function(e){ document.getElementsByClassName("dygraph-cplg")[0].style.display = "none"; }; popover.prototype.clearChart = function(e){ // var elements = document.getElementsByClassName("dygraph-cplg"); // for(var i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy