This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Trend scale on graphs
#1
Is it possible to set the max and minimum values on the trend graph? It auto-scales but I would like to set the major and minor intervals (in this case I set 'Always show zero on Y axis). Specifically, for temperature (see example screen shot attachment), I would like to have the major increments set at 5 degrees (not 4.2 degrees as shown here). I am using the 5500SHAC (as you might have guessed).

Wonderful forum, by the way, and great admin and senior member help!!

Thanks!

Attached Files Thumbnail(s)
   
Reply
#2
Try this Custom JS. Change trend ID and max value as needed. You can add if statements to set maximum value for other trends. This will only work in single trend view.

Code:
$(function(){
  if (typeof Chart != 'object') {
    return;
  }
  
  function getid() {
    var sel = $('.nav .active .a');
    if (sel.length == 1) {
      return sel.data('trend').id;
    }
  }
  
  var calcBounds = Chart.calcBounds;
  
  Chart.calcBounds = function() {
    calcBounds.apply(this);
    
    if (getid() == 1) {
      this.max = 1000;
    }
  }
});
Reply
#3
Perfect!

I took a good guess to set the minimum, and now I have the graph how I want it, with an easy to read 2 degrees per graph minor line:

Code:
    if (getid() == 1) {
      this.max = 40;
      this.min = -10;
    }
     
    if (getid() == 2) {
      this.max = 40;
      this.min = -10;
    }

Thanks very much!!

I do have another question. If I hadn't asked you, how would I find this out?

I've noted in my device there is the dygraph.js file that has 3468 lines of JS code. Do I just browse the various .js files hoping to find clues?

In looking there, it seems I might be able to choose log scales, and other goodies. Perhaps the ability to turn off the shading under the graph (fillGraph)? Set gridLineColor: "rgb(128,128,128)", and so on.

Is there a reference guide on all this? Sorry, just hoping to catch up.

Thanks again.

Attached Files Thumbnail(s)
   
Reply
#4
dygraph is not used here. Trends use modified version of Flotr2. Log scale is not supported. Grid minor/major color can be set via Custom CSS by modifying background-color property of .flotr-grid-color and .flotr-grid-minor-color classes. Fill can be hidden like this but for all trends altogether:
Code:
Flotr.graphTypes.lines.options.fillOpacity = 0;
Reply
#5
if i have a multiple trend with 2 different scale ( right and left ) how i can set the right scale?
thanks!
Reply
#6
You can set this.min2 and this.max2
Reply


Forum Jump: