Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Charts help

Hi All,

I am sort of at a dead end and not sure how to proceed.  Hope I can get some help/insight on how to go forward.

I created chart using google api in SharePoint 2007.  It looks somewhat like this

Here's a picture of it in SharePoint

Here's my problem, as you can see, the x-axis uses months but the client has changed it to actual dates in the fiscal year.  So, it should be like this

These dates are in a list with associated data to plot. These dates represent all dates, separated by a week, in a fiscal year starting with October 4, 2012.

Previously I created a multidimensional array that would allow me to plot my lines graphs by month.

 I was then able to pick which index to manipulate like so dataValues[monthProjectedIndex][10] += parseInt(checkForUndefined($(this).attr("ows_Plan")));

The dates make it somewhat difficult because there are 52/53 weeks in a fiscal year and I don't want to manually create an array with all the date values.

Any ideas?  Code attached.
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

as I understand, you will have an entry in your (chart) data array for each week starting with October, 4th 2012.
Therefore I would create a simple helper function which will return a value representing the index like
function returnWeekindexSince(datevalfromsp) {
var basedate = new Date(2012,9,4);
var checkdate = new Date(datevalfromsp);
var timecheck = checkdate .getTime();
var timebase = basedate .getTime();

var weekindex = parseInt((t2-t1)/(24*3600*1000*7));
if (weekindex < 0) {
// if necessary - propper error handling here
} else { return weekindex;}

Open in new window

You just have to ensure, that you pass either a correct date string to the function or use a helper library to pass directly a date variable.
Perhaps you would also need a function to initialize the data array by getting the maximum week index (CAML query on the date column, rowlimit 1, order by date column desc).

BTW, completely different approach: as it seems from your last questions, you are reaching the limits of MOSS2007, CAML and client side scripting in regards to complexity, duration and server performance. As MOSS 2007 and CAML are very very limited (no SELECT DISTINCT, SELECT SUM ... equivalents) and due to the fact that you will run the  same queries and calculation each time the chart is shown, you might think of starting to implement your own web service, which can use server side object model, using the property bag for caching the results and eventually even updating the cache when something in the list has changed. Just my 2ct.
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial