0

ユーザーデータをグラフで表示したいプロジェクトをやっています..

webview、html、javascript、cssファイルを使ってグラフを表示したい。

webview では、グラフではなくテーブルを取得しています。

すべての .js および .css ファイルのファイル パスを正しく取得しています。

コピー バンドル リソースに .js および .css ファイルを既にコピーしています。

これが私のコードです

NSURL* path = [[NSBundle mainBundle] URLForResource:@"jquery.min" withExtension:@"js"];
NSLog(@"PATH %@",path);
NSURL* path1 = [[NSBundle mainBundle] URLForResource:@"03" withExtension:@"js"];
NSLog(@"PATH %@",path1);

NSURL* css1path = [[NSBundle mainBundle] URLForResource:@"common" withExtension:@"css"];

NSLog(@"CSSPATH %@",css1path);

NSURL* css2path = [[NSBundle mainBundle] URLForResource:@"03" withExtension:@"css"];
NSLog(@"CSS2PATH %@",css2path);




NSString *str  = @"<html lang=\"en\">";
str=[str stringByAppendingString:@"<head>"];
str=[str stringByAppendingString:@"<meta charset=\"utf-8\">"];
str=[str stringByAppendingString:@"<meta name=\"viewport\" content=\"width=800\">"];
str=[str stringByAppendingString:@"<title>Sleep Hour Graph of myBeats</title>"];
str=[str stringByAppendingFormat:@"<link rel=\"stylesheet\" href=%@\">",css1path];
str=[str stringByAppendingFormat:@"<link rel=\"stylesheet\" href=%@\">",css2path];
str=[str stringByAppendingString:@"</head>"];

str=[str stringByAppendingString:@"<body>"];

str=[str stringByAppendingString:@"<div id=\"wrapper\">"];

str=[str stringByAppendingString:@"<div class=\"chart\">"];

str=[str stringByAppendingString:@"<h2>Weekly Sleep Graph/Hour</h2>"];

str=[str stringByAppendingString:@"<table id=\"data-table\" border=\"1\" cellpadding=\"10\" cellspacing=\"0\" summary=\"Sleep hours from 2013-08-12 to 2013-08-18\">"];
str=[str stringByAppendingString:@"<caption>Sleep in Hours</caption>"];
str=[str stringByAppendingString:@"<thead>"];
str=[str stringByAppendingString:@"<tr>"];
str=[str stringByAppendingString:@"<td>&nbsp;</td>"];
str=[str stringByAppendingFormat:@"<th scope=\"col\">%@</th>",Str1];
str=[str stringByAppendingFormat:@"<th scope=\"col\">%@</th>",Str2];
str=[str stringByAppendingFormat:@"<th scope=\"col\">%@</th>",Str3];
str=[str stringByAppendingFormat:@"<th scope=\"col\">%@</th>",Str4];
str=[str stringByAppendingFormat:@"<th scope=\"col\">%@</th>",Str5];
str=[str stringByAppendingFormat:@"<th scope=\"col\">%@</th>",Str6];
str=[str stringByAppendingFormat:@"<th scope=\"col\">%@</th>",Str7];
str=[str stringByAppendingString:@"</tr>"];
str=[str stringByAppendingString:@"</thead>"];
str=[str stringByAppendingString:@"<tbody>"];
str=[str stringByAppendingString:@"<tr>"];
str=[str stringByAppendingString:@"<th scope=\"row\">Sleep in Hours Per Day</th>"];
str=[str stringByAppendingFormat:@"<td>%@</td>",Str11];
str=[str stringByAppendingFormat:@"<td>%@</td>",Str22];
str=[str stringByAppendingFormat:@"<td>%@</td>",Str33];
str=[str stringByAppendingFormat:@"<td>%@</td>",Str44];
str=[str stringByAppendingFormat:@"<td>%@</td>",Str55];
str=[str stringByAppendingFormat:@"<td>%@</td>",str66];
str=[str stringByAppendingFormat:@"<td>%@</td>",Str77];
str=[str stringByAppendingString:@"</tr>"];
str=[str stringByAppendingString:@"</tbody>"];
str=[str stringByAppendingString:@"</table>"];

str=[str stringByAppendingString:@"</div>"];

str=[str stringByAppendingString:@"</div>"];

str=[str stringByAppendingFormat:@"<script type=\"text/javascript\" src=%@\"></script>",path];

str=[str stringByAppendingFormat:@"<script type=\"text/javascript\" src=%@\"></script>",path1];

str=[str stringByAppendingString:@"</body>"];

str=[str stringByAppendingString:@"</html>"];
NSLog(@"HTMLFINAL %@",str);
[webview loadHTMLString:str baseURL:nil];

[webview stringByEvaluatingJavaScriptFromString:str];

私が得ている出力:

ここに画像の説明を入力

望ましい出力:

ここに画像の説明を入力

4

1 に答える 1