2017-06-04 17 views
0

我遇到了問題。我需要在移動應用程序中使用highcharts。所以我決定使用網絡視圖。它不適用於iOS或Android。嘗試在本地腳本Web視圖內使用高圖。不起作用

我有3個問題:

1)我試圖推出簡單演示高腳椅在我的網頁視圖。出了些問題。我在下面的代碼中做了什麼錯誤?我想問題是加載js腳本。網絡視圖組件內部

HTML代碼如下:

<html lang="en" > 
<head> 
    <meta charset="utf-8" /> 
    <meta name="author" content="Script Tutorials" /> 
    <title>How to create active charts using Highcharts | Script Tutorials</title> 

    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 
    <script src="http://code.highcharts.com/highcharts.js"></script> 

</head> 
<body> 
    <div id="chart_1" class="chart"></div> 
    <script type='text/javascript'> 
    $(document).ready(function() { 

// First chart initialization 
var chart1 = new Highcharts.Chart({ 
chart: { 
    renderTo: 'chart_1', 
    type: 'area', 
    height: 350, 
}, 
title: { 
    text: 'Tools developers plans to use to make html5 games (in %)' 
}, 
xAxis: { 
    categories: ['Processing.js', 'Impact.js', 'Other', 'Ease.js', 'Box2D.js', 'WebGL', 'DOM', 'CSS', 'Canvas', 'Javascript'] 
}, 
yAxis: { 
    title: { 
     text: 'Interviewed' 
    } 
}, 
series: [{ 
    name: 'Dev #1', 
    data: [5, 10, 20, 22, 25, 28, 30, 40, 80, 90] 
}, { 
    name: 'Dev #2', 
    data: [15, 15, 18, 40, 30, 25, 60, 60, 80, 70] 
}, { 
    name: 'Dev #3', 
    data: [1, 3, 6, 0, 50, 25, 50, 60, 30, 100] 
}] 
}); 

});</script> 
</body> 
</html> 

我component.ts是使這樣的網絡視圖:

export class ChartComponent implements AfterViewInit { 
    public webViewSrc: string = generateChartHtml(); 

    @ViewChild("myWebView") webViewRef: ElementRef; 
    @ViewChild("labelResult") labelResultRef: ElementRef; 

    ngAfterViewInit() { 
     let webview: WebView = this.webViewRef.nativeElement; 
     let label: Label = this.labelResultRef.nativeElement; 
     label.text = "WebView is still loading..."; 

     webview.on(WebView.loadFinishedEvent, function (args: LoadEventData) { 
      let message; 
      if (!args.error) { 
       message = "WebView finished loading of " + args.url; 
      } else { 
       message = "Error loading " + args.url + ": " + args.error; 
      } 

      label.text = message; 
      console.log("WebView message - " + message); 
     }); 
    } 
} 

PS:generateChartHtml功能簡單,只是返回上面寫的html代碼

這裏是我的component.html:

<ActionBar title="chaaaRtT"> 
</ActionBar> 

<StackLayout #container VerticalOptions="FillAndExpand" height="350" [ngClass]="{'isSigningUp' : !isLoggingIn}"> 
    <WebView #myWebView [src]="webViewSrc"></WebView> 
    <Label #labelResult></Label> 
</StackLayout> 

TNS - V3.0.1 角 - V4

我的第二個問題是: 它關係到這個問題1659

2)如何通過web視圖中的html加載本地文件?

問題1659的解決方案已過時我想。它沒有提到iOS。 而它沒有說什麼將是試圖加載css/js文件的HTML文件的根。 例如這裏

<head> 
    <link rel="stylesheet" href="/form.css"/> 
</head> 

,最後一個:

3)它會嘗試從根機,或者從一些「局部」根加載form.css,即當前文件夾?

在此先感謝您的幫助

回答