2009-12-12 6 views
1

J'ai besoin de html - java script/jquery en utilisant un seul fichier.page html unique - html charts -

De quoi ai-je besoin est comme suit?

  • liens ci-dessus ne sont que pour la création de graphiques à barres
  • Je dois créer graphique en ligne ainsi que des diagrammes circulaires & D'autres cartes.
  • Je ne connais pas les scripts java jQuery.
  • Inshort - J'ai besoin des rapports dans un seul fichier. (pas de fichier .css supplémentaire ou fichier .js ou tout autre fichier, juste parce que ici, je dois utiliser - NSString stringWithContentsOfFile-fichier - ici, je ne peux spécifier qu'un seul nom de fichier.En bref, je dois tout faire ceux-ci dans un fichier.)

Laissez-moi illustrer ce que j'ai fait. Ici, j'ai généré une page html dynamique dans l'iPhone &

cette page est jointe dans mail composer.

Maintenant, le code ci-dessous est pour la création de la page html - table. Je veux aussi créer une page html de graphiques.

NSString *dt=[self getDateStringFromDate:[dtPicker date]]; 

NSDictionary *fromTo=[DatabaseAccess getFromToDate:dt]; 
if(arrayForIncomeExpense!=nil && [arrayForIncomeExpense retainCount]>0){ [arrayForIncomeExpense release]; arrayForIncomeExpense=nil; } 
arrayForIncomeExpense=[[NSArray alloc] initWithArray:[DatabaseAccess getIncomesExpensesSummaryForUserID:[BudgetTrackerAppDelegate getUserID] profileID:[BudgetTrackerAppDelegate getProfileID] fromDate:[fromTo valueForKey:@"fromDate"] toDate:[fromTo valueForKey:@"toDate"]]]; 
NSMutableString *htmlString=[[NSMutableString alloc] init]; 
NSDictionary *temp; 
int i,j=[arrayForIncomeExpense count]; 
for(i=-1;i<j;i++){ 
    if(i==-1){ 
    [htmlString appendString:@"<html><head><title>Budget Tracker Report</title></head><body bgcolor=\"#6699ff\"><h2 align=\"center\">Income - Expense SpreadSheet</h2><table align=\"center\" width=\"75%\" bgcolor=\"black\" cellspacing=\"1\" cellpadding=\"1\"><tbody bgcolor=\"silver\"><tr><th>Month</th><th>Income</th><th>Expense</th><th>Balance</th></tr>"]; 
    } else { 
    temp=[arrayForIncomeExpense objectAtIndex:i]; 
    [htmlString appendString:(i%2==0)[email protected]"<tr bgcolor=\"gray\">":@"<tr bgcolor=\"lightgray\">"]; 
    [htmlString appendFormat:@"<td>%@</td>",[self getMonthYear:[temp valueForKey:@"MonthID"]]]; 
    [htmlString appendFormat:@"<td align=\"right\">%15.2lf</td>",[[temp valueForKey:@"Income"] doubleValue]]; 
    [htmlString appendFormat:@"<td align=\"right\">%15.2lf</td>",[[temp valueForKey:@"Expense"] doubleValue]]; 
    [htmlString appendFormat:@"<td align=\"right\">%15.2lf</td>",[[temp valueForKey:@"Income"] doubleValue]-[[temp valueForKey:@"Expense"] doubleValue]]; 
    [htmlString appendString:@"</tr>"]; 
    } 
} 
[htmlString appendString:@"</table></body></html>"]; 
NSLog(@"%@",htmlString); 

[htmlString writeToFile:[self pathOfHTMForExport] atomically:YES encoding:NSStringEncodingConversionAllowLossy error:nil]; 

picker = [[MFMailComposeViewController alloc] init]; 
picker.mailComposeDelegate=self; 

[picker setSubject:@"bt SpreadSheet Report"]; 

NSString *filePath = [self pathOfHTMForExport]; 

NSData *d=[NSData dataWithContentsOfFile:filePath]; 
NSString *[email protected]"bt.htm"; 

[picker addAttachmentData:d mimeType:@"text/htm" fileName:fileNameToSend]; 
NSString *emailBody = [NSString stringWithFormat:@"%@",@"Hello! This is export test for html report."]; 
[picker setMessageBody:emailBody isHTML:NO]; 

[ASForPicker dismissWithClickedButtonIndex:0 animated:YES]; 

[self presentModalViewController:picker animated:YES]; 

Répondre

2

Sonne comme si vous étiez d'humeur pour Highcharts. Cela vous obligera cependant à créer des liens vers des fichiers supplémentaires dans votre page HTML (à moins que vous ne l'utilisiez comme script en ligne).