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 http://jsfiddle.net/asgallant/GTpgA/36/

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.
jQueryJavaScriptMicrosoft SharePoint

Avatar of undefined
Last Comment
Rainer Jeschor

8/22/2022 - Mon
Rainer Jeschor

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.
Rainer Jeschor

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes