0

All,

I am trying to have the crosshair track the three waveforms.

enter image description here

The crosshair does show up, and the tracking does not (oops ... see EDIT) take place. Please note - as specified in the picture - that the legend for the horizontal bar is simply a DIV styled to look like a legend from FLOT.

The CodePen can be found here

As the program is executed, the 'legend' becomes null, and the strings do not update ... the code is:

legends = $(".legendLabel");

legends.each(function () {
    // fix the widths so they don't jump around
    $(this).css('width', $(this).width());
}); 

I ended up having to put this code in the updateLegend() function. The question is 'why'? Am I sitting on a time bomb? :-) :-)

On a side note, thank you again to Raidri for getting me started earlier in the day.

-- EDIT -- The tracking DOES take place (I had managed to fix it in the middle of posting the question). The only doubt I have is about having to re-initialize variable 'legend' in function updateLegend()

-- EDIT 2 -- The code works in Chrome and Firefox, but fails in IE: 'Object doesn't support property or method "assign"'. I found the solution here

The code below will fix the problem ...

if (typeof Object.assign != 'function') {
  Object.assign = function(target) {
     'use strict';
     if (target == null) {
        throw new TypeError('Cannot convert undefined or null to object');
     }

     target = Object(target);
     for (var index = 1; index < arguments.length; index++) {
        var source = arguments[index];
        if (source != null) {
          for (var key in source) {
             if (Object.prototype.hasOwnProperty.call(source, key)) {
                target[key] = source[key];
             }
          }
        }
     }
     return target;
  };
}               

$.each(data1, function (idx, item) {
    Object.assign(item, {
        stack: true,
        lines: {show: false, steps: false },
        bars: {show: true, horizontal:true, width: 1}
    });
});
Community
  • 1
  • 1
vpappano
  • 111
  • 1
  • 11
  • Works fine for me (in Chrome) with the code only outside the `updateLegend()` function. Which browser do you use? Putting the code in the `updateLegend()` should be no problem. – Raidri Dec 07 '16 at 09:43
  • @Raidri ... Apologies ... My code is indeed working (see my EDIT). Thank you for your reply. I won't worry about having to re-initialize 'legends' in 'updateLegends()'. Thank you again ... :-) – vpappano Dec 07 '16 at 11:28
  • @Raidri ... A couple of things ... (1) The code is now working without problems (no need to re-init 'legends') -- don't know why, but I'll take it ... (2) The code works in Chrome and Firefox, but fails in IE (see my **EDIT 2**) – vpappano Dec 07 '16 at 11:41

0 Answers0