-->

Maximum and Minimum Y-Axis Values on Keen.io Dashb

2019-07-26 20:00发布

问题:

Is it possible to set maximum and minimum values on the Y-axis on keen dashboard charts?

I downloaded the dashboard from this github repo :

https://github.com/keen/dashboards

I have a vertical column chart like below, I want to set the minimum value on the y-axis to be 70 and the maximum to be 90, how can I do this?

  <div class="col-sm-8">
    <div class="chart-wrapper">
      <div class="chart-title">
        Alex Weight (kg)
      </div>
      <div class="chart-stage">
        <div id="chart-01"></div>
      </div>
      <div class="chart-notes">   
      </div>
    </div>
  </div>


var query = new Keen.Query("maximum", {
    eventCollection: "weight",
    interval: "daily",
    targetProperty: "value",
    timeframe: "this_14_days",
    timezone: "Australia/Sydney"
});

client.draw(
query, document.getElementById("chart-01"), {
    height: 150,
width: '100%',
chartType: 'columnchart',

hAxis: {
    format:'d MMM'
}
}
);

回答1:

As soon as I ask the question, I figure it out... Just add the vAxis values below :

var query = new Keen.Query("maximum", {
eventCollection: "weight",
interval: "daily",
targetProperty: "value",
timeframe: "this_14_days",
timezone: "Australia/Sydney"
});

client.draw(
query, document.getElementById("chart-01"), {
height: 150,
width: '100%',
chartType: 'columnchart',

hAxis: {
    format:'d MMM'
},
vAxis: { 
    minValue: 70,
    maxValue: 80
 }  
}
);