Something like RGraphs is meant for adding graphing elements to a website. I guess technically could include the files in your app bundle and just access the local paths with Safari (if you are allowed to do that), in which case the JavaScript should execute automatically.
This is really not the right tool for the job to generate local graphs, and is kind of a kludge.
Have you looked into any native iOS graphing libraries like CorePlot?
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writablePath = [documentsDirectory stringByAppendingPathComponent:@"BasicGraph.html"];
NSURL *urlStr = [NSURL fileURLWithPath:writablePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *myPathInfo = [[NSBundle mainBundle] pathForResource:@"BasicGraph" ofType:@"html"];
[fileManager copyItemAtPath:myPathInfo toPath:writablePath error:NULL];
[graphView loadRequest:[NSURLRequest requestWithURL:urlStr]];
[graphView stringByEvaluatingJavaScriptFromString:@"methodName()"];
<script>
function methodName()
{
alert(hi);
}
window.onload = function ()
{
// Code Omitted
}
</script>
[graphView stringByEvaluatingJavaScriptFromString:@"methodName()[COLOR="Red"];[/COLOR]"];
I think you are just missing a semicolon.
Code:[graphView stringByEvaluatingJavaScriptFromString:@"methodName()[COLOR="Red"];[/COLOR]"];
Alternatively, can't you just call methodName() in the window.onload? Is there a reason you want to call it natively from the app?
Also, make sure you are calling this in webViewDidFinishLoad so that your JavaScript code is actually available when you are trying to run it.