views:

141

answers:

2

I need html - java script / jquery charts using single file.

What do I need is as follows?

  • Above links are just for creating bar charts
  • I need to create line chart as well as pie charts & other charts.
  • I don't have knowledge regarding java scripts jQuery.
  • Inshort - I need the reports within single file. ( that is - no extra .css file or .js file or any other file, just because here, i have to use - NSString stringWithContentsOfFile-file - here I can specify only one file name. In short I have to do all these within one file. )

Let me illustrate what I have done. Here, I have generated a dynamic html page in iPhone &

that page is attached in mail composer.

Now, Below code is for creating html - table page.

I also want to create an html page of charts.

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)?@"<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 *fileNameToSend=@"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];
+2  A: 

You can include both the javascript and the css you need in the html file if you want to. Here is a list of different kinds of graphs you can create with html/js/css: http://www.cssjuice.com/22-code-snippets-for-creating-decent-charts/

tmadsen
+2  A: 

Sounds like your're in the mood for Highcharts. This will, however, require you to link to some extra files in your HTML-page (unless you use it as an inline script).

Mickel