AmCharts: ChartScrollBar going out of chartdiv

坚强是说给别人听的谎言 提交于 2019-12-11 17:04:59

问题


I am Using amCharts for displaying stock data. I have a scrollBar enabled and positioned at bottom. I have a chartholderdiv which has style:

#chartholderdiv{
  height:80%;
  width:80%;
  overflow:visible;
  background-color:#db946b;
}

For clarity, I have added a background color to see the limits of div in the following image.
I have a chartdiv (which is provided to AmCharts.makeChart) which has style:

#chartdiv {
  width: 100%;
  height: 100%;
}

HTML:

<div id="chartholderdiv">
    <div id="chartdiv"></div>   
</div>

There are no other style or tags in my file for which I have pasted output. If the browser is resized to smaller size, the issue will be clear. I have given all my code here except the <script> tag which has amCharts config and AmCharts.makeChart(chartdiv,chartobject);(this command is called within ajax onreadystatechange function). So more or less my script tage is:

<script>
 chartObject={......};

 var xhttp=new XMLHttpRequest();
 xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
     .....//parse json data for dataset of chart.
     .....//set chartObject dataProvider to dataset parsed above
     chart = AmCharts.makeChart("chartdiv", chartObject);
   }
  };
  xhttpHour.open("GET", dataUrlString, true);
  xhttpHour.send();

</script>

But when the chart is drawn, the scrollbar of chart goes out of the chartdiv/chartholderdiv. See image:

I have added the red background so that the problem is visible. I assume that when setting height, the two graphs take 70 and 30 as in chart config and the scrollbar is added after that which spills out of div but I want the chartholder div to resize to accommodate everything. I have tried many things, but the problem persists.

来源:https://stackoverflow.com/questions/48023787/amcharts-chartscrollbar-going-out-of-chartdiv

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