jQuery 在顶部留出更多空间

标签 jquery height flot space

如何在图表顶部创造更多空间?

现在我明白了: enter image description here

但我想要这个:

enter image description here

这是我的 JS 代码:

$("table.chart").each(function() {
    var colors = [];
    $("table.chart thead th:not(:first)").each(function() {
        colors.push($(this).css("color"));
    });
    $(this).graphTable({
        series: 'columns',
        position: 'replace',
        width: '100%',
        height: '200px',
        colors: colors
    }, {
        xaxis: {
            tickSize: 1
        }
    });
});

最佳答案

调整 y 轴的 autoscaleMargin 属性。来自 API:

The "autoscaleMargin" is a bit esoteric: it's the fraction of margin that the scaling algorithm will add to avoid that the outermost points ends up on the grid border. Note that this margin is only applied when a min or max value is not explicitly set. If a margin is specified, the plot will furthermore extend the axis end-point to the nearest whole tick. The default value is "null" for the x axes and 0.02 for y axes which seems appropriate for most cases.

听起来像是从默认的 0.02 提高它就可以达到你想要的效果。

关于jQuery 在顶部留出更多空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9095387/

相关文章:

javascript - 为什么 PHP 的 AJAX GET 响应带有 HTML 标签?

javascript - 将 div 移至特定 div 内,并在某些断点处再次移回

android - 添加视频后如何获取videoview的宽高

jquery - 如何正确设置 100% DIV 高度以匹配文档/窗口高度?

javascript - 更改 float 中的数据点尾随小数

Javascript 变量不更新它的值

javascript - 当鼠标离开 <li> 时,子菜单 CSS 下拉菜单在 CSS 下拉菜单中消失

javascript - 查找html文本区域中的行数

javascript - 具有多个图表和动态图例的 Flot Chart Crosshair 插件

php - 使 JSON 数组 Flot 兼容