简体   繁体   English

高图,容器内无填充物

[英]Highchart without padding inside the container

is it possible to have an linechart without the padding left and right? 是否有可能没有左右填充的折线图? So that the line would be edge to edge, just like in the Design? 像设计中一样,线会边到边吗?

预习

At the moment it looks like that 目前看来

演示版

chartOptions: {
chart: {
  type: 'spline',
  spacingBottom: 0,
},
title: null,
legend: {
  enabled: false
},
credits: {
  enabled: false,
},
tooltip: {
  split: true,
  pointFormat: '{point.y} {series.name}',
},
plotOptions: {
  series: {
    shadow: true,
  },
},
xAxis: {
  categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  minPadding: 0,
  maxPadding: 0,
  tickWidth: 0,
  lineWidth: 0,
  crosshair: true,
},
yAxis: {
  visible: false,
},
series: [
  {
    name: 'Bookings',
    data: [43, 44, 43, 42, 42, 41, 42, 43, 45, 44, 42, 43],
  },
  {
    name: 'EUR',
    data: [143, 144, 143, 142, 142, 141, 142, 143, 145, 144, 142, 143],
  },
],

}, },

Yes, it is possible by adding to "xAxis" configuration object, params "min" and "max", which determines minimum and maximum value of the axis. 是的,可以通过在“ xAxis”配置对象中添加参数“ min”和“ max”来确定轴的最小值和最大值。 However, no exactly in your case, because there isn't enough data in series of this chart ( you don't specify the data before January and after December, therefore chart has start point and an end point ). 但是,您的情况并不完全如此,因为此图表系列中没有足够的数据(您未在1月和12月之后指定数据,因此图表具有起点和终点)。

Here is a piece of configuration code based on yours: 这是根据您的配置代码的一部分:

xAxis: {
    categories: ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul','Aug', 'Sep', 'Oct', 'Nov', 'Dec', ''],
    minPadding: 0,
    maxPadding: 0,
    tickWidth: 0,
    lineWidth: 0,
    crosshair: true,
    min: 1,
    max: 12
},

series: [
    {
     name: 'Bookings',
     data: [39, 43, 44, 43, 42, 42, 41, 42, 43, 45, 44, 42, 43, 48],
    },
    {
     name: 'EUR',
     data: [141, 143, 144, 143, 142, 142, 141, 142, 143, 145, 144, 142, 143, 148],
    },
],

I added two more categories ( one before 'Jan' and one after 'Dec' ), and two more data positions for both of series objects. 我又添加了两个类别(一个在“ Jan”之前,一个在“ Dec”之后),以及两个系列对象的另外两个数据位置。 Due to set min and max params, chart shows the range only from between this points. 由于设置了最小和最大参数,因此图表仅显示此点之间的范围。

Finally, You should set spacing like this: 最后,您应该像这样设置间距:

chart: {
    type: 'spline',
    spacing: [0,0,10,0]
},  

Lets look on the live working below: JSFiddle 让我们看看下面的实时工作: JSFiddle

Best regards! 最好的祝福!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM