首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么Highcharts动画在移动设备上起伏不定?

为什么Highcharts动画在移动设备上起伏不定?
EN

Stack Overflow用户
提问于 2015-04-22 21:58:45
回答 1查看 441关注 0票数 0

我正在为我的仪表板页面制作一个用于安卓的HTML5混合应用程序。

这一页有3个图表,每个图表只有不到10个点。初始化动画在PC浏览器(包括chrome和火狐)上看起来很流畅,但在我的移动设备(Nexus7和MSM8916 CPU phone)上却非常不稳定。即使我将duration设置为2000,它仍然是不稳定的。

使用jQuery 2.1.3和Hightcharts 4.1.5。

有人能告诉我为什么和如何提高Highcharts动画在移动设备上的性能吗?

下面是html代码,我使用jquery mobile 1.4.5作为UI框架。

代码语言:javascript
运行
复制
<div data-role="page" data-title="总览" id="overall-page">
    <div role="main" class="ui-content no-margin">
        <div class="border-chart" id="hdgjChart"></div>
        <div class="border-chart" id="sbzxlChart"></div>
        <div class="border-chart" id="lsgjChart"></div>
    </div>
</div>

js代码如下:

代码语言:javascript
运行
复制
$(document).on("pageshow", "#overall-page", function() {
// Draw first Charts.
$('#hdgjChart').highcharts({
    credits: {
        enabled: false
    },
    chart: {
        type: 'column',
        //pinchType: 'xy',
        //zoomType: 'xy',
        //panning: true
    },
    title: {
        text: '活动告警',
        align: 'left',
        margin: 0,
        style: { "color": "#004488", "fontSize": "16px" }
    },
    legend: {
        enabled: false
    },
    xAxis: {
        labels: {
            enabled: false
        },
        tickLength: 0
    },
    yAxis: {
        labels: {
            enabled: false
        },
        stackLabels: {
            style: {
                color: "#004488"
            },
            enabled: true
        },
        title: {
            text: null
        },
        tickAmount: 8
    },
    plotOptions: {
        column: {
            stacking: 'normal',
            animation: {
                duration: 2000
            }
        }
    },
    tooltip: {
        headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>'
    },
    series: [{
        name: '数目',
        data: [
            {
                y: 381,
                color: "#f00505",
                name: "一级告警"
            },
            {
                y: 25,
                color: "#f46700",
                name: "二级告警"
            },
            {
                y: 652,
                color: "#ffcf05",
                name: "三级告警"
            },
            {
                y: 72,
                color: "#22a5f2",
                name: "四级告警"
            }]

    }]
});

// Draw second chart
$('#sbzxlChart').highcharts({
    credits: {
        enabled: false
    },
    chart: {
        type: 'pie',
        spacingBottom: 0
    },
    title: {
        text: '<span style="color:#004488;font-size:16px">设备在线率</span><span style="color:#004488;font-size:12px">--总设备数:78</span>',
        align: 'left',
        margin: 0
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    legend: {
        align: 'right',
        verticalAlign: 'top',
        floating: true,
        itemDistance: 10,
        borderRadius:3,
        borderWidth: 1
    },
    plotOptions: {
        pie: {
            dataLabels: {
                enabled: true,
                format: '{point.y}个,{point.percentage:.1f} %',
                style: {
                    color: "#004488"
                }
            },
            innerSize: '50%',
            point: {
                events: {
                    legendItemClick: function(e) {
                        e.preventDefaut();
                    }
                }
            },
            animation: {
                duration: 2000
            }
        }
    },
    series: [{
        name: '数目',
        data: [
            {
                y: 31,
                color: "#00ff00",
                name: '在线'
            },
            {
                y: 47,
                color: "#959595",
                name: '中断'
            }
        ],
        showInLegend: true
    }]
});

// Draw third chart
$('#lsgjChart').highcharts({
    credits: {
        enabled: false
    },
    chart: {
        type: 'areaspline',
        spacingBottom: 0,
        //pinchType: 'x',
        //zoomType: 'x',
        //panning: true
    },
    title: {
        text: '<span style="color:#004488;font-size:16px">历史告警数量</span><span style="color:#004488;font-size:12px">--最近7天</span>',
        align: 'left',
        margin: 7
    },
    tooltip: {
        headerFormat: "",
        pointFormat: '{point.y}'
    },
    legend: {
        align: 'right',
        verticalAlign: 'top',
        floating: true,
        borderRadius:3,
        borderWidth: 1
    },
    xAxis: {
        gridLineWidth: 1,
        tickAmount: 7,
        tickInterval: 1
    },
    yAxis: {
        stackLabels: {
            enabled: true,
            useHTML: true,
            y: -12,
            formatter: function() {
                return '<span style="background-color:#0d61be;color:white;font-weight:normal">' + this.total + '</span>';
            }
        },
        title: {
            text: null
        },
        tickAmount: 7
    },
    plotOptions: {
        areaspline: {
            stacking: 'normal',
            pointStart: 1,
            color: '#0d61be',
            events: {
                legendItemClick: function(e) {
                    e.preventDefault();
                }
            },
            animation: {
                duration: 2000
            }
        }
    },
    series: [{
        name: '总告警数',
        data: [150, 450, 300, 550, 300, 300, 100]
    }]
});

});

EN

回答 1

Stack Overflow用户

发布于 2015-04-30 10:35:28

当我制作了一个简单的highcharts测试html页面,并在移动chrome浏览器上运行它时,它运行得很流畅。但当简单地将其打包为混合安卓应用程序时,使用操作系统WebView和Crosswalk,它仍然可以运行。(英特尔XDK)我测试了一个基于画布的js图表库Chart.js,它在混合应用程序时也是起伏不定的。

所以,我认为这是VebView或Phonegap的问题。我现在正在寻找原因,当我解决了这个问题时,我会更新它。谢谢大家。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29799895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档