简体   繁体   English

highcharts-热图底部的多余空间

[英]highcharts - unwanted space at bottom of heatmap chart

I have a heatmap that has some space at the bottom that I want to get rid of. 我有一个热图,该热图的底部有一些要删除的空间。 I have tried multiple SO threads suggesting that I change chart.marginBottom, chart.spacingBottom, x and yAxis margins, disabled legend, etc. Unfortunately, I created a jsfiddle and am unable to replicate the issue. 我尝试了多个SO线程,建议我更改chart.marginBottom,chart.spacingBottom,x和yAxis边距,禁用的图例等。不幸的是,我创建了一个jsfiddle,无法复制该问题。 The jsfiddle code is nearly identical my code: http://jsfiddle.net/b637gdxv/1/ jsfiddle代码几乎与我的代码相同: http : //jsfiddle.net/b637gdxv/1/

chart: {
        type: 'heatmap',
        marginTop: 26,
        marginLeft: 5,
        marginRight: 5,
        marginBottom: 5,

        width: 200, // - width when in one row 
        height: 250,

        borderWidth: 3,
        borderColor: 'grey',
        borderRadius: 5,
        plotBackgroundColor: '#FFFFFF',
        plotShadow: true
    },

Here is an image of what it looks like on my page: 这是我页面上的图像:

在此处输入图片说明

Notice the extra space on the bottom. 请注意底部的额外空间。 Sorry that I am not able to define the problem more specifically - the difference between my page and the jsfiddle eludes me, and I am not super experienced with javascript. 抱歉,我无法更具体地定义问题-我的页面和jsfiddle之间的区别使我难以理解,而且我对javascript的了解还不是很丰富。 Any ideas of things to try? 有什么想法可以尝试吗?

Since we don't have enough code to really identify what you're issue is and you can't even reproduce it on jsfiddle, I'll give you a walkthrough of the steps I take to identify CSS issues and fix them - particularly when the CSS is applied dynamically. 由于我们没有足够的代码来真正识别出问题所在,并且甚至无法在jsfiddle上重现它,因此,我将向您逐步介绍识别CSS问题并修复它们所采取的步骤-特别是当CSS是动态应用的。

If you're using IE, use the developer tools (F12). 如果您使用的是IE,请使用开发人员工具(F12)。 From the HTML tab click the "Select Element" tool (it looks like a pointer). 在HTML选项卡中,单击“选择元素”工具(它看起来像一个指针)。 Move the mouse to the outer box and it will garnish a slight grey border... click the mouse. 将鼠标移到外部框上,它会带有轻微的灰色边框...单击鼠标。

At this point - I think you'll have in the HTML pane the following tag highlighted: 此时-我想您将在HTML窗格中突出显示以下标记:

<rect class=" highcharts-background" fill="#ffffff" stroke="grey" stroke-width="3" x="1.5" y="1.5" width="196" height="246" rx="5" ry="5" strokeWidth="3"/>

Note the attributes are clickable and can be changed on the fly. 请注意,这些属性是可单击的,可以随时更改。

At this point you can start tinkering with the styles (on the right pane) or even switch to the CSS pane (next to the HTML tab) and tinker around with the various CSS definitions. 此时,您可以开始修改样式(在右侧窗格中),甚至切换到CSS窗格(在HTML选项卡旁边),然后修改各种CSS定义。

There are different developer tools for each browser. 每个浏览器都有不同的开发人员工具。 Chrome has them built in as well and Firefox has the FireBug plugin to provide them. Chrome也内置了它们,而Firefox具有FireBug插件来提供它们。 For this type of thing they come close to working the same way. 对于这类事情,他们几乎都以相同的方式工作。

Let us know what you find and good luck! 让我们知道您的发现并祝您好运!

I'm running into a similar question with my heatmaps, and updated the jsfiddle to show the issue: 我的热图遇到了类似的问题,并更新了jsfiddle来显示问题:

http://jsfiddle.net/v1697qhj/ http://jsfiddle.net/v1697qhj/

You'll notice in that example that the cells of the heatmap do not fill the full height set on "chart.height". 在该示例中,您会注意到热图的单元格未填充在“ chart.height”上设置的完整高度。 I'm wondering if the issue is because the number of rows divided into the available height is not an even number of pixels, so when highcharts draws the rows at a fixed pixel height there is some amount of total space left over that is never used. 我想知道问题是否是因为将行数划分为可用高度不是偶数像素,所以当highcharts将行以固定像素高度绘制时,总有一些剩余空间从未使用过。

Does anyone know if there's a way to get Highcharts to add a pixel to every so many rows (or columns for the horizontal case) so that the cells of the heatmap will always fill the available plot area? 有谁知道是否有办法让Highcharts向每隔这么多的行(或水平情况的列)添加一个像素,以使热图的单元始终填充可用的绘图区域?

chart: {
    type: 'heatmap',
    marginTop: 26,
    marginLeft: 5,
    marginRight: 5,
    marginBottom: 5,
    width: 200,  
    height: 250,    // We want the cells to fill this entire height
    borderWidth: 3,
    borderColor: 'grey',
    borderRadius: 5,
    plotBackgroundColor: '#FFFFFF',
    plotShadow: true
}

Did a little more digging into the highcharts JS source code, and found a work around! 进一步研究了highcharts JS源代码,找到了解决方法! This is actually being impacted by the logic that calculates the axis ticks, so setting the "endOnTick" option to 'false' on the impacted axis appears to resolve the issue. 这实际上受到计算轴刻度的逻辑的影响,因此在受影响的轴上将“ endOnTick”选项设置为“ false”似乎可以解决问题。 Eg 例如

yAxis: {
    labels: {
      enabled: false
    },
    endOnTick: false,  // This is the fix
    title: null,
    reversed: true
}

Here is an updated jsfiddle showing the fix: 这是显示此修复程序的更新的jsfiddle:

http://jsfiddle.net/e0av9wm1/ http://jsfiddle.net/e0av9wm1/

Compare to the following, which doesn't include the fix: 与不包含此修复程序的以下内容进行比较:

http://jsfiddle.net/v1697qhj/ http://jsfiddle.net/v1697qhj/

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

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