UIWebView cuts off bottom of content

johnyu

I am working on an app in which I have several webViews and in them I render various charts using javascript library HighCharts. Here is part of my view controller's view in which such a web view is placed

enter image description here

"Country Name" and everything above is part of web view, while "Legend" is in a UILabel. As you can see, 'y' in "Country Name" is cut off at the bottom. I made the label at bottom transparent and even set webView.scrollView.clipsToBounds = NO as well as change that scroll view's contentInsets, but that doesn't really change anything (and I realize that turning clipsToBounds off might be wrong, I was just checking if the problem has anything to do with it). (EDIT: Replaced fragments with full html)

This is the html template that I use. In the final html all "%%" are replaced with just "%" and "%@" are replaced with chart data.

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <script type="text/javascript" src="jquery-1.8.2.min.js"></script>
        <script type="text/javascript">
            $(function() {
              $('#chart_container').highcharts({
                                               chart: {
                                               type: '%@',
                                               spacing: [10, 0, 0, 0],
                                               zoomType: 'x'
                                               },
                                               title: {
                                               text: null
                                               },
                                               xAxis: {
                                               categories: %@,
                                               title: {
                                               text: '%@',
                                               style: {
                                               fontSize: '13.0px'
                                               }
                                               },
                                               minRange: 1,
                                               labels: {
                                               rotation: -45,
                                               style: {
                                               fontSize: '13.0px'
                                               }
                                               }
                                               },
                                               yAxis: {
                                               title: {
                                               text: '%@',
                                               style: {
                                               fontSize: '12.0px'
                                               }
                                               },
                                               labels: {
                                               style: {
                                               fontSize: '14.0px'
                                               }
                                               }
                                               },
                                               tooltip: {
                                               shared: true,
                                               headerFormat: '<span style="font-size: 18.0px">{point.key}</span><br/>',
                                               %@
                                               style: {
                                               fontSize: '16.0px'
                                               }
                                               },
                                               legend: {
                                               enabled: false
                                               },
                                               %@
                                               series: %@,
                                               credits: {
                                               enabled: false
                                               },
                                               exporting: {
                                               enabled: false
                                               }
                                               });
              });

              function toggleSeries(index) {
                  var chart = $('#chart_container').highcharts();
                  chart.tooltip.hide();
                  %@
              }
        </script>
        </head>

<body style="height: 100%%; min-height: 100%%; margin:0; padding:0; overflow: visible">
    <script src="highcharts.js">
        </script>
    <script src="exporting.js">
        </script>
    <div id="chart_container" style="height: 100%%; overflow: visible"></div>
</body>

Any idea where does this problem come from and how can it be fixed?

Paweł Fus

Problem was in setting for a chart:

spacing: [10, 0, 0, 0]

After removing this, auto-calculation for spacing prevents from this problem.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related