【问题标题】:How do I get x-axis to expand to take more of the chart width如何让 x 轴扩展以占用更多图表宽度
【发布时间】:2013-03-25 16:09:22
【问题描述】:

从附图中可以看出,我的 x 轴类别在中间聚集在一起。如何配置 highcharts 以占用更多的 x 轴?注意:图表大小是动态的,它会根据整个浏览器大小和应用程序内的拆分面板而增长和缩小。因此,点宽的显式计算不是一种选择(我希望 highcharts 可以为我完成这项工作)。

注意:图片是垂直裁剪的。

我使用的图表选项是:

highchart.setAnimation(false);
Legend legend = new Legend();
legend.setEnabled(false);
highchart.setLegend(legend);

highchart.getXAxis().setCategories(result.getAxisXCategories().toArray(new String[] {}));
highchart.setType(Series.Type.COLUMN);
ColumnPlotOptions options = new ColumnPlotOptions();
options.setStacking(Stacking.NORMAL);
options.setGroupPadding(0);
options.setAnimation(true);
highchart.setColumnPlotOptions(options);

换句话说,图例已关闭,列图选项设置为零组填充。

更新:这是一个显示相同 issue 的 JSFiddle

【问题讨论】:

  • 你能提供 js.fiddle 的链接吗?
  • 或发布您的图表选项
  • 我已经添加了我正在设置的选项。我没有 js.fiddle - 这是一个 gwt-highchart 实现。

标签: highcharts gwt-highcharts


【解决方案1】:

对于遇到相同问题的其他人,解决方案是设置 ColumnPlotOptions 的 pointRange 选项。在 JSON 中,这看起来像:

"plotOptions": {
        "column": {
            "stacking": "normal",
            pointRange: 1,
                "groupPadding": 0
        }
    }

在 GWT-Highcharts 中,您实际上没有针对 pointRange 的特定 API。因此设置一个像这样的通用选项:

ColumnPlotOptions options = new ColumnPlotOptions();
options.setOption("pointRange", 1.0);
...

【讨论】:

    【解决方案2】:

    【讨论】:

    • 每次图表调整大小时,我都必须重新计算!对我来说,这看起来像是 highchart 中的逻辑错误。
    • 这看起来像是一个 GWT 问题,因为在 Highcharts 中它看起来很好。因此,如果可能的话,可以在 jsfiddle.net 中重新创建它吗?
    • 我已经用一个重现问题的 JSFiddle 更新了这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多