Fusionchart无法以正确的帧呈现

问题描述 投票:0回答:1

[enter image description here]之前我曾使用UIWebView和具有正确框架的图表显示FusionCharts。现在由于不赞成使用UIWebView,所以我将其替换为WKWebView。HTML文档中的相关图表或javascript函数均未进行代码更改。文件中有一个js函数,我在其中使用数据作为参数发送此函数来创建FusionChart。但是现在图表没有正确的框架。

类ViewController:UIViewController,WKUIDelegate,WKNavigationDelegate {

var webView: WKWebView!
var graphString = "{ \"chart\": { \"xaxisname\":\"Months\", \"yaxisname\":\"Total No Of Claims\", \"caption\":\"Claims By Month\", \"palette\":\"0\", \"showValues\":\"1\", \"numberPrefix\":\"\", \"useRoundEdges\":\"1\", \"animation\":\"1\", \"numdivlines\":\"2\", \"numberprefix\":\"\", \"yaxisminvalue\":\"0\", \"showborder\":\"0\", \"exportEnabled\":\"0\", \"formatNumberScale\":\"0\"},\"categories\":[{ \"category\":[{\"label\":\"Jun_2019\",\"stepSkipped\":\"false\", \"appliedSmartLabel\":\"true\", \"showlabel\":\"1\" },{\"label\":\"Jul_2019\",\"stepSkipped\":\"false\", \"appliedSmartLabel\":\"true\", \"showlabel\":\"1\" },{\"label\":\"Aug_2019\",\"stepSkipped\":\"false\", \"appliedSmartLabel\":\"true\", \"showlabel\":\"1\" },{\"label\":\"Sep_2019\",\"stepSkipped\":\"false\", \"appliedSmartLabel\":\"true\", \"showlabel\":\"1\" }]}],\"dataset\":[{\"seriesname\":\"Accepted\", \"data\": [{\"value\":\"1808\", \"link\":\"\"},{\"value\":\"1281\", \"link\":\"\"},{\"value\":\"25\", \"link\":\"\"},{\"value\":\"7\", \"link\":\"\"}]},{\"seriesname\":\"Adjusted\", \"data\": [{\"value\":\"8\", \"link\":\"\"},{\"value\":\"\", \"link\":\"\"},{\"value\":\"7\", \"link\":\"\"},{\"value\":\"1\", \"link\":\"\"}]},{\"seriesname\":\"Correction Needed\", \"data\": [{\"value\":\"\", \"link\":\"\"},{\"value\":\"34\", \"link\":\"\"},{\"value\":\"1\", \"link\":\"\"},{\"value\":\"\", \"link\":\"\"}]},{\"seriesname\":\"Paid\", \"data\": [{\"value\":\"404\", \"link\":\"\"},{\"value\":\"1\", \"link\":\"\"},{\"value\":\"3\", \"link\":\"\"},{\"value\":\"4\", \"link\":\"\"}]},{\"seriesname\":\"Part Return\", \"data\": [{\"value\":\"40\", \"link\":\"\"},{\"value\":\"75\", \"link\":\"\"},{\"value\":\"1\", \"link\":\"\"},{\"value\":\"1\", \"link\":\"\"}]},{\"seriesname\":\"Rejected\", \"data\": [{\"value\":\"198\", \"link\":\"\"},{\"value\":\"96\", \"link\":\"\"},{\"value\":\"15\", \"link\":\"\"},{\"value\":\"4\", \"link\":\"\"}]},{\"seriesname\":\"Waiting For Approval\", \"data\": [{\"value\":\"1\", \"link\":\"\"},{\"value\":\"541\", \"link\":\"\"},{\"value\":\"11\", \"link\":\"\"},{\"value\":\"10\", \"link\":\"\"}]}] }"


override func loadView() {
    let webConfiguration = WKWebViewConfiguration()
    webView = WKWebView(frame: .zero, configuration: webConfiguration)
    webView.uiDelegate = self
    webView.navigationDelegate = self
    view = webView
}

override func viewDidLoad() {
    super.viewDidLoad()

   // let webView = WKWebView()
    //let htmlPath = Bundle.main.path(forResource: "chart", ofType: "html")
   // let htmlUrl = URL(fileURLWithPath: htmlPath!, isDirectory: false)
   // webView.loadFileURL(htmlUrl, allowingReadAccessTo: htmlUrl)
    //view = webView

    createGraph()
}

func createGraph()
{
    var path = ""
    let thisBundle = Bundle.main
    path = thisBundle.path(forResource: "columncharts", ofType: "html") ?? ""
    let instructionsURL = URL(fileURLWithPath: path)
    var htmlString: String? = nil
    do {
        htmlString = try String(contentsOfFile: path, encoding: .utf8)
    } catch {
    }
    self.webView.loadHTMLString(htmlString!, baseURL: instructionsURL)
}



func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {


        let graphFunction = String(format: "showChart(%@,%f,%f,%ld)", self.graphString, self.view.frame.size.width, self.view.frame.size.height, 1)
        webView.evaluateJavaScript(graphFunction, completionHandler: nil)

}[![Expected Result][1]][1]
 [![INcorrect Result][2]][2]
ios swift
1个回答
0
投票

同样也无法呈现图表。以前它为我工作,然后突然停止工作。

© www.soinside.com 2019 - 2024. All rights reserved.