高图将不会显示在Chrome应用中

用户名

我正在尝试嵌入highcharts.com的图表(使用jquery)。如果我只是windows.html在chrome本身中打开图形,则这些图片就可以正常工作,但不会在chrome应用程序中加载。只是一个空白的屏幕。我在文件夹中有所有标准的.js文件,但此处未包括它们。

我从这里的示例开始:https : //developer.chrome.com/apps/first_app

background.js

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('window.html', {
    'bounds': {
      'width': 400,
      'height': 500
    }
  });
});

清单文件:

{
  "name": "Hello World!",
  "description": "My first Chrome App.",
  "version": "0.1",
  "manifest_version": 2,
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}

window.html

<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Highcharts Example</title>

        <script type="text/javascript" src="jquery.min.js"></script>
        <style type="text/css">
${demo.css}
        </style>
        <script type="text/javascript">
$(function () {
    $(document).ready(function () {
        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });

        $('#container').highcharts({
            chart: {
                type: 'spline',
                animation: Highcharts.svg, // don't animate in old IE
                marginRight: 10,
                events: {
                    load: function () {

                        // set up the updating of the chart each second
                        var series = this.series[0];
                        setInterval(function () {
                            var x = (new Date()).getTime(), // current time
                                y = Math.random();
                            series.addPoint([x, y], true, true);
                        }, 1000);
                    }
                }
            },
            title: {
                text: 'Live random data'
            },
            xAxis: {
                type: 'datetime',
                tickPixelInterval: 150
            },
            yAxis: {
                title: {
                    text: 'Value'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                formatter: function () {
                    return '<b>' + this.series.name + '</b><br/>' +
                        Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
                        Highcharts.numberFormat(this.y, 2);
                }
            },
            legend: {
                enabled: false
            },
            exporting: {
                enabled: false
            },
            series: [{
                name: 'Random data',
                data: (function () {
                    // generate an array of random data
                    var data = [],
                        time = (new Date()).getTime(),
                        i;

                    for (i = -19; i <= 0; i += 1) {
                        data.push({
                            x: time + i * 1000,
                            y: Math.random()
                        });
                    }
                    return data;
                }())
            }]
        });
    });
});
        </script>
  </head>
  <body>
    <script src="highcharts.js"></script>
    <script src="exporting.js"></script>

    <div id="container" style="min-width: 200px; height: 200px; margin: 0 auto"></div>
  </body>
</html>
帕维尔·普兹提克(Pawel Psztyc)

答案在以下JSFiddle中:http : //jsfiddle.net/jarrodek/sdr57h3g/

<body>
    <!-- Firstly show content, the app will looks more responsive -->
    <div id="container" style="min-width: 200px; height: 200px; margin: 0 auto"></div>
    <!-- now you have content loaded and you can execute you code -->
    <script type="text/javascript" src="jquery.min.js"></script>
    <script src="highcharts.js"></script>
    <script src="exporting.js"></script>
    <!-- move your code to external file (panel below) -->
    <script src="myapp.js"></script>
</body>

现在,您可以确保在运行代码之前已加载所有依赖项。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Facebook分享按钮将不会在Chrome中显示

来自分类Dev

高图(高库存)-数据不会显示

来自分类Dev

如果调用revokeObjectURL,则Blob图片将不会在Chrome中显示

来自分类Dev

类库中的ImageSource将不会显示

来自分类Dev

按钮将不会显示在FlowLayout中

来自分类Dev

JScrollPane中的JTextArea将不会显示

来自分类Dev

JPanels将不会显示在Cardlayout容器中

来自分类Dev

JScrollPane将不会显示在JTextArea中

来自分类Dev

UIAlertController将不会显示-在Swift中

来自分类Dev

Dygraph将不会显示在Bootstrap卡中

来自分类Dev

AlertDialog将不会显示在onCreate方法中

来自分类Dev

JScrollPane中的JTextArea将不会显示

来自分类Dev

UITableViewCell中的ImageView将不会显示

来自分类Dev

科尔多瓦将不会启动Safari,并在应用程序中显示网站

来自分类Dev

SVG将不会显示

来自分类Dev

UIPickerView将不会显示

来自分类Dev

JButton将不会显示

来自分类Dev

QWinTaskbarProgress将不会显示

来自分类Dev

高图不会显示我的GeoJSON湖层

来自分类Dev

高图未显示在Firefox中

来自分类Dev

高图散点图:在图表中显示值

来自分类Dev

高图散点图:在图表中显示值

来自分类Dev

DIV中的DIV将不会显示在浏览器中

来自分类Dev

高图将不同的背景颜色应用于每年的每个月

来自分类Dev

柱形图显示datalabel中的空值-高图

来自分类Dev

突出显示饼图(高图)中的活动数据标签

来自分类Dev

Nexus 5将不会在Eclipse中显示

来自分类Dev

XML文档中的错误,浏览器将不会显示

来自分类Dev

CKAsset将不会显示在表格视图图像中