Highcharts Bar Chart Auto Height

瘦欲@ 提交于 2019-12-11 09:04:13

问题


I have a highcharts 3d Bar chart and I need the height to automatically size depending on how many bars are on the chart. We may only need 1 or we may need 100. the current problem is that it always expands to fill the page. So If I have one it will be a huge bar and if I have 100 it will be all smashed together. I need it to grow as it has data.

I have done searching and see this http://jsfiddle.net/wkkAd/149/ demo.

Here is my chart with that demo: http://jsfiddle.net/a40a0bjy/2/

The issue is that I neeed to to grow as it has more bars. Right now, it expands to 100% of my page height.

I set the bar height hoping that it would stop the chart from growing bigger but it does not work.

Using:

 pointWidth: 30//width of the column bars irrespective of the chart size

If I do that, it will just have the 30 width bars with all kinds of space and the chart still expands to fill the entire page height.

Update: This is what I want to do. http://jsfiddle.net/highcharts/jMX8G/ If you remove some of that data the charts automatically is smaller, while keeping the same size bar heights.

This issue with that demo is that my data is much more complex than that demos. Here it is:

var data = [{
            name: 'Not Complete',
            data: [{
                y: 5,
                drilldown: {
                TaskID: 343434545252,
                name: 'somename'
                }

            },
            {
                y: 3,
                drilldown: {
                TaskID: 343434545252,
                name: 'somename'
            }
        },
        {
               y: 4,
               drilldown: {
               TaskID: 343434545252,
               name: 'somename'
            }
        },
        {
               y: 7,
               drilldown: {
               TaskID: 343434545252,
               name: 'somename'
            }
        },
       {
              y: 2,
              drilldown: {
              TaskID: 343434545252,
              name: 'somename'
           }
       }]
    }, {
        name: 'Clean Up',
        data: [2, 2, 3, 2, 1]
    }, {
        name: 'Complete',
        data: [3, 4, 4, 2, 5]
    }];

Now the denmo uses this:

 height: data.length * 20 + 120 // 20px per data item plus top and bottom margins

But I do not know how or what to get the length of for my data.

来源:https://stackoverflow.com/questions/30868963/highcharts-bar-chart-auto-height

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!