问题
We have the following problem - no matter what we try, we can't set the minimum or maximum on our chart in javascript.
Chart1 = new Tee.Chart("canvas");
var a = new Tee.Area();
Chart1.addSeries(a);
a.data.values = values
a.data.x = times;
a.format.fill = "rgba(0,175,240,0.0)";
var aa = new Tee.Line();
Chart1.addSeries(aa);
aa.data.values = values
aa.data.x = times;
Chart1.getSeries(0).vertAxis = "right";
Chart1.getSeries(1).vertAxis = "right";
Chart1.axes.bottom.labels.dateFormat = "UTC:HH:MM:ss";
Chart1.axes.right.labels.decimals = 5;
Chart1.axes.right.grid.format.stroke.fill = "#191919";
Chart1.axes.right.labels.format.font.fill = "#ccc";
Chart1.axes.bottom.grid.format.stroke.fill = "#191919";
Chart1.axes.bottom.labels.format.font.fill = "#ccc";
Chart1.getSeries(0).format.gradient.visible = true;
Chart1.getSeries(0).format.gradient.colors = ["rgba(0,175,240,0.2)", "rgba(255,175,240,1)"];
Chart1.getSeries(0).format.gradient.stops = [0, 1];
Chart1.getSeries(0).format.stroke.fill = "rgba(0,175,240,0)";
Chart1.getSeries(1).format.stroke.fill = "rgba(0,175,240,1)";
Chart1.getSeries(0).format.stroke.size = 0;
Chart1.getSeries(1).format.stroke.size = 2;
Chart1.title.visible = false;
Chart1.walls.back.visible = false;
Chart1.panel.transparent = true;
Chart1.legend.visible = false;
var maxValue = data[data.length - 1][0];
var minValue = data[0][0];
maxValue = maxValue + 1000 * 60 * 10;
maxValue = new Date(maxValue);
//Chart1.axes.bottom.setMinMax(minValue, maxValue);
Chart1.axes.bottom.maximum = maxValue;
Chart1.axes.bottom.minimum = minValue;
Chart1.draw();
The bottom axes contains dates and we are trying to add 10 minutes to the last date value and the set it as maximum and remove 10 minutes from the first date value and set it as minimum. We can't achieve that no matter what we try.
回答1:
This seems to work fine for me here:
var tenMinutes = 1000 * 60 * 10;
var minValue = series1.minXValue();
var maxValue = series1.maxXValue();
minValue = minValue - tenMinutes;
maxValue = maxValue + tenMinutes;
Chart1.axes.bottom.setMinMax(minValue, maxValue);
来源:https://stackoverflow.com/questions/33099797/javascript-teechart-set-min-or-max-not-working