Javascript teechart - 设置min或max不工作?

时间:2015-10-13 10:04:24

标签: teechart

我们遇到以下问题 - 无论我们尝试什么,我们都无法在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();

底部轴包含日期,我们尝试将10分钟添加到最后一个日期值并将其设置为最大值,并从第一个日期值中删除10分钟并将其设置为最小值。无论我们尝试什么,我们都无法做到这一点。

1 个答案:

答案 0 :(得分:1)

这似乎对我来说很好:

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);