带有x,y数据系列的图表中的保证金

时间:2013-08-29 09:22:10

标签: highcharts

在具有[x,y]格式的数据系列的堆叠图表中,左侧和右侧的边距较大。我已经使用示例数据创建了以下jsfiddle:

http://jsfiddle.net/ymyrA/4/

图表的代码如下:

    $(function () {
        var chart = new Highcharts.Chart({
            chart: {"renderTo": "container", "type": "column"},
            colors: ["#2f7ed8", "#0d233a", "#8bbc21", "#910000", "#1aadce", "#492970", "#f28f43", "#77a1e5", "#c42525", "#a6c96a", "#4572A7", "#AA4643", "#89A54E", "#80699B", "#3D96AE", "#DB843D", "#92A8CD", "#A47D7C", "#B5CA92"],
            credits: {"enabled": false},
            plotOptions: {"column": {"stacking": "normal"}},
            series: [
                {"name": "Muster1", "data": [
                    [11, 1],
                    [32, 1]
                ]},
                {"name": "Muster2", "data": [
                    [11, 7],
                    [12, 4],
                    [14, 4],
                    [15, 1],
                    [16, 1],
                    [17, 4],
                    [18, 6],
                    [19, 2],
                    [20, 1],
                    [21, 1],
                    [22, 1],
                    [25, 3],
                    [26, 2],
                    [28, 1],
                    [29, 1],
                    [30, 1]
                ]},
                {"name": "Muster 3", "data": [
                    [11, 2],
                    [13, 2],
                    [15, 1],
                    [16, 3],
                    [18, 5],
                    [19, 11],
                    [20, 8],
                    [21, 1],
                    [23, 3],
                    [24, 12],
                    [27, 3],
                    [28, 4],
                    [30, 3],
                    [31, 3],
                    [33, 3],
                    [34, 3]
                ]}
            ],
            title: {"text": null},
            xAxis: {"title": {"text": "Week"}},
            yAxis: {"title": {"text": "Count"}}
        });
    });

我尝试过最小值和最大值,类别等,但没有任何结果。如何调整图表以全尺寸显示?

我已经使用正确的排序更新了代码和jsfiddle。我使用3.0而不是3.05因此我在控制台中没有错误。有了最新版本,我还有问题。一个是上面提到的右边和左边的大边距,另一个是我无法(甚至使用tickInterval)每个日历周有一个刻度。根据上面提到的样本,整个图表的范围应为x = 11到x = 34,每个x都有一个勾号。

1 个答案:

答案 0 :(得分:1)

问题在于第一个系列的计算pointRange - 当你只有两个点时,对于x = 11和x = 31,假设该系列中点之间的最小间隔是20,所以Highcharts会尝试设置间隔大约为20.对于这种情况,您需要使用pointRange例如将其设置为1,请参阅:http://jsfiddle.net/ymyrA/5/