jquery - BlackBerry bbUI 应用程序中 Flot 图表的 Canvas 尺寸太大

标签 jquery flot blackberry-webworks blackberry-10

我正在使用 Flot BB10 WebWorks 应用程序中的折线图也使用 bbUI.js工具包。

使用 Ripple 模拟器运行应用程序时,图表大小正确 (1000x500)。但是,当我将应用程序部署到设备 (Dev Alpha) 时,图表尺寸太大 (2243x1121)。

使用 Web Inspector,我发现 Canvas 元素的宽度和高度属性超出了占位符大小:

<div id="weight-chart" style="width: 1000px; height: 500px; 
     padding: 0px; position: relative;">
  <canvas class="flot-base" 
     style="direction: ltr; position: absolute; left: 0px; top: 0px; 
            width: 1000px; height: 500px;" 
     width="2243" height="1121">
  </canvas>
  <canvas class="flot-overlay" 
    style="direction: ltr; position: absolute; left: 0px; top: 0px; 
           width: 1000px; height: 500px;" 
    width="2243" height="1121">
  </canvas>
</div>

这是 HTML 页面片段:

<div data-bb-type="screen" data-bb-scroll-effect="on" id="chart-page" 
     data-bb-indicator="true">

  <!-- chart goes here: -->
  <div id="weight-chart" style="width:1000px;height:500px;"></div>

  <div data-bb-type="action-bar" data-bb-back-caption="Back"></div>
</div>

这是对 Flot 的 javascript 调用,ondomready:

bb.init({onscreenready: function(element, id, params) {
  }, 
  ondomready: function(element, id, params) {
    if (id == 'chart') {
      chartDataset = ...
      chartOptions = ...
      $.plot($("#weight-chart", element), chartDataset, chartOptions);
      element.getElementById('chart-page').refresh();
    }
});

你知道发生了什么吗?

最佳答案

您所需要的只是在 JS 中找到这一行:

this.pixelRatio = devicePixelRatio / backingStoreRatio;

并替换为:

this.pixelRatio = 1;

关于jquery - BlackBerry bbUI 应用程序中 Flot 图表的 Canvas 尺寸太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14636956/

相关文章:

javascript - jquery : How to use the . css() 方法

javascript - jQuery Flot xaxis 元素数

动态浮图图 - 通过单击图上的图例文本或框来显示隐藏系列

javascript - jquery flot 图例中的事件处理程序

javascript - PlayBook相机API(WebKit)抛出异常并且不打开相机

javascript - 滚动在移动设备上被锁定

javascript - 使用 D3.js(IE、safari 和 chrome)创建 SVG 后如何保存/导出 SVG 文件?

javascript - 为什么将 &lt;script&gt; 附加到动态创建的 &lt;iframe&gt; 似乎在父页面中运行脚本?

jquery - 让我的 jQuery Ajax 脚本使用 CORS

适用于 BlackBerry 的 jQuery Mobile 固定工具栏解决方法?