【问题标题】:Ionic ionScroll not working with AmChartsIonic ionScroll 不适用于 AmCharts
【发布时间】:2014-10-13 13:52:59
【问题描述】:

我正在尝试使用 ionScroll 组件制作可滚动的 n 轴 X 的基本图表(使用 AmChart 库创建):

http://ionicframework.com/docs/api/directive/ionScroll/

问题是,如果我使用移动设备上的 ionScroll 组件移动,我会收到错误消息:

E/Web Console﹕ Uncaught TypeError: Cannot call method 'contains' of undefined:2882

我不知道这个问题是由 amchart 还是 ionic 引起的,但它在移动设备上不起作用(在 Chrome 中模拟移动设备时它正在运行)。

我正在使用 Ionic 版本: v1.0.0-beta.13 "镧-豹

什么会导致这个错误?

这里是chart div和ion-scroll模板的附加内容:

<ion-view title="Hourly charts" animation="slide-in-up">

    <ion-nav-buttons side="left">
        <button class="button button-icon icon  ion-arrow-left-c" ui-sref="home">
        </button>
    </ion-nav-buttons>

  <!--content-->
  <ion-content ng-controller="HourlyChartsCtrl"
               ng-init="setDateRange('today');">
      <div class="chart_range_date">
        Date: {{dateFrom}} 8 AM - 6 PM
      </div>
      <!--daily charts-->
      <ion-scroll
          id="scroll_hourly"
          style="width:100%;"
          class="vh72"
          direction="x"
          has-bouncing="false"
          locking="false"
          paging="true">
      <div id="chartdiv_hourly" class="vh72" style="width:200%;">
      </div>
  </ion-scroll>

  <h3 class="swipeNote">Swipe here to move through weeks</h3>


</ion-content>

<!--tabbar-->
  <div class="tabs-striped tabs-background-positive tabs-light tabs-icon-left">
        <div class="tabs">
            <a class="tab-item active" ui-sref="hourly-chart" href="/#/hourly-chart">
                Hours
            </a>
            <a class="tab-item" ui-sref="daily-chart" href="/#/daily-chart">
                Days
            </a>
            <a class="tab-item " ui-sref="monthly-chart" href="/#/monthly-chart">
                Months
            </a>
        </div>
  </div>

</ion-view>

【问题讨论】:

    标签: javascript android ionic-framework amcharts


    【解决方案1】:

    如果没有 JavaScript,我无法诊断该错误,但 amChart 有自己的功能来管理滚动http://www.amcharts.com/demos/line-chart-with-scroll-and-zoom/

    我使用了highcharts(不是amCharts),发现图表有触摸事件,如果触摸事件发生在图表上,可以覆盖滚动区域行为。 amChart 说它支持触摸事件,所以我希望有类似的行为。

    与其尝试使用 ionScroll 来处理水平导航,为什么不使用内置图表的滚动?

    【讨论】:

    • 您好,我之前尝试过在 Amcharts 中滚动图表,但对于触摸屏设备绝对无法使用(您可以尝试在您提供的链接中运行演示),所以我想使用 ionScroll 来“破解”它,这看起来按照性能和可用性的顺序是可接受的。
    猜你喜欢
    • 1970-01-01
    • 2016-04-22
    • 2018-05-12
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-11
    • 1970-01-01
    相关资源
    最近更新 更多