How to set specific y-axis label points in dygraphs?

前端 未结 2 1122
一整个雨季
一整个雨季 2021-01-06 05:00

Dygraphs ordinarily automatically picks Y- (and X-) axis labeling points based on the size of your axes, the size of the labels, etc. In some cases, it picks labeling points

2条回答
  •  心在旅途
    2021-01-06 05:24

    If you just want to add a label to those that are auto-generated

    g = new Dygraph(div, data, {
        axes: {
          y: {
            ticker: function(min, max, pixels, opts, dygraph, vals) {
              var your_value = 7.5;
    
              //Get auto-generated tickers (numericTicks is the default ticker generator)
              var tickers = Dygraph.numericTicks(min, max, pixels, opts, dygraph, vals);
              tickers.push({v: your_value, label: 'Custom Label'}); //Insert your label
    
              return tickers;
            }
          }
        }
      });
    

提交回复
热议问题