SPJS Charts for SharePoint v3.x

10.12.12 I introduced a new bug in v3.3.7 that broke the filter if you did NOT use “filterAdditionalCharts”. This should be fixed in v3.3.8.


13.11.2012 Updated to v3.3.7 to fix a bug regarding “filterAdditionalCharts” in the Custom CAML filter setup. This was broken in v3.3.6 – thanks to Paul Brown for notifying me.

Please note that you now have to supply the parameter for each filter in the filter setup. Click the “Instructions” link above the filter setup textarea for details.


20.09.2012 Updated to v3.3.5
06.09.2012 Updated to v3.3.1. This update is an attempt to fix an issue where you apply multiple formatters on the same column, and only the last one sticks.
18.07.2012: Updated to v3.3 and added a few new features. See this article for details.
07.06.2012: Updated to v3.2.2 to add support for special characters like single quote and “&” in the filter options. See change log.
29.05.2012: Updated to v3.2.1 to fix a bug. See change log.
31.03.2012: Updated to v3.2.
Added filter wildcard to allow “Show all” when using dropdown filter. See “Filter setup Instructions” in the “Edit chart GUI”.
See change log for details on some small bugfixes.
21.02.2012: Updated to v3.1.5. See change log.
14.02.2012: Updated to v3.1.4. See change log.
13.02.2012: Updated to v3.1.3. See change log.
06.02.2012: Updated to v3.1.2. See change log.


06.02.2012: Updated to v3.1.1 to avoid using eval. Read more in the article. Thanks to Christophe for pointing me to the “jQuery.parseJSON()” method – I was not aware that jQuery had this built in.


This article will freshen up on the setup of the solution and will describe the changes in v3.1

Keywords: New chart types, multiple dropdown filters and variables in the custom CAML query.


I have “silently” released version 3 of the “Charting for SharePoint using Google Visualization API” solution in November 2011. You find it here. The 3.0 release was not so mush about new functionality, but focused more on tidying up the GUI to make it easier for the user to understand the configuration options.

In the work with v3.0 i realized that i did not have any distinct name for the solution, and I decided to name the solution SPJS Charts for SharePoint.

A full walktrough of the configuration options in v3.0 can be found in this book from O’Reilly. The book is a collection of articles from Nothing But SharePoint. The article you find in this book (Publication Date: February 24, 2012) has not been published elsewhere.
The setup

To start using this solution, you only need the rights to create a list (will be done automatically by this solution), upload files and add a CEWP or a HTML form web part to a page.

After the initial setup, all you need is contribute rights to edit charts.

The setup process contains four steps:

  1. Download the file “SPJS_ChartsForSharepoint_v3.x.js” and “CEWP.txt” from here from here. You can choose between the uncompressed (124KB) “SPJS_ChartsForSharePoint_v3.1.js” and the packed, smaller version version (64KB) “SPJS_ChartsForSharePoint_v3.1_min.js”. The latter is packed using packer. You find the CEWP code and the script file in separate folders. The folder name will reflect the script version. Ensure you download the latest version, and that you read the change log.
  2. Upload the file “SPJS_ChartsForSharepoint_v3.x.js” to a document library, or put it in a folder created with SharePoint Designer for safer storage. Ensure all users have read access to the file.
  3. Copy the link to the file “SPJS_ChartsForSharepoint_v3.x.js” and replace the example path in the CEWP code so that it reflects your local copy.
  4. Either upload the CEWP code to the same folder as the file “SPJS_ChartsForSharepoint_v3.x.js” and use the content link option in a CEWP to link to the code, or use a HTML form web part and insert the code directly in the “Source editor”.

Reload the page, and if it is the first time it is run in the site, the solution will prompt you to create the configuration list. If you are upgrading from an earlier solution, you are prompted to update the configuration list. Both actions require no more than a click on the OK button to complete.

If you are upgrading AND you have a multi language setup:
Ensure you have selected the “native” language for the site collection before you complete the update of the configuration list. If you fail to do so, the update will not take effect and the prompt will not go away.
These are the changes in v3.1
Chart types

Switched GeoMap for GeoChart and added BubbleChart and SteppedAreaChart.

Dropdown select filters

In the previous versions, you could create ONE dropdown filter above the chart. In v3.1 you can have multiple. The setup of the filter have changed, and those updating from a previous version will have to redo the filter setup (you will get an error message telling you that the filter setup is wrong).

IMG
The chart example above has this filter setup to create the “Year dropdown”:

IMG
You can have multiple filters created in the same way, Click “Instructions” above the Filter setup textarea to expand this description:

Use an object literal like this:
[{"label":"Year","urlKey":"year","options":[{"f":"2011","v":"2011"},{"f":"2012","v":"2012","selected":true}]},{“label”:”Status”,”urlKey”:”status”,”options”:[{"f":"Not started","v":"0"},{"f":"In progress","v":"1","selected":true}]}]

The object properties:
label: The label in front of the dropdown.
urlKey: The parameter in the url that identifies the value.
f: Friendly name for the option. Can be the same as “v”.
v: Internal name for the option. Can be the same as “f”.
selected: true if the option should be preselected.

When you have written or prefilled the filter (by selecting it from the “Prefill textarea from choice field-dropdown”), you must add the appropriate CAML in the “Custom CAML-query” textarea. You can start by clicking “Build CAML from selected filters” below the Custom CAML-query textarea to have the raw CAML autogenerated.

Note that you must change the text “FieldInternalNameToMatch” in the Custom CAML-query textarea to the correct FieldInternalName.

The new filter method can use eval1, and thus you can have parts of, or even the complete filter as a variable in the CEWP. To do this, you create a variable in the CEWP code and inserts the variable name in the “Filter setup” textarea. Please note that the CAML is “static” and you must insert the corresponding {filter:urlKey} in the Custom CAML-query textarea to pick up the filters.

1. This feature has changed from v3.1 to v3.1.1 and must now be turned on (off by default) to allow “eval”. This is a security risk, but if you want to have the filter setup as a variable in the CEWP code, add this setting to the CEWP:

var allowEval = true;
Variables directly in the custom CAML

Another new feature is the ability to use variables directly in the CAML. Construct the variables in the CEWP code like an object named “spjsCAMLvariables”, then insert {variable:variable_name} in the Custom CAML-query textarea where you want the variable to be inserted. “variable_name” represents one property from the object “spjsCAMLvariables”.

In the following example i have used it to filter a calendar to show this weeks items.
In the CEWP code you insert code like this to get the two variables “thisWeekMonday” and “thisWeekSunday”:

// Get todays date
var today = new Date();
// Find monday in current week
while(today.getDay()!==1){
	today.setDate(today.getDate()-1); 
}
// Create two date objects - one for Monday and one for Sunday
var monday = new Date(today);
var sunday = new Date(today.setDate(today.getDate()+6));
// Convert the dates to ISO8601 format: yyyy-mm-dd for use in CAML
var thisWeekMonday = monday.getFullYear().toString()+"-"+(monday.getMonth()+1).toString()+"-"+monday.getDate().toString();
var thisWeekSunday = sunday.getFullYear().toString()+"-"+(sunday.getMonth()+1).toString()+"-"+sunday.getDate().toString();
// the object used in the Custom CAML-query
var spjsCAMLvariables = {"thisWeekMonday":thisWeekMonday,"thisWeekSunday":thisWeekSunday};

Insert the variables in the Custom CAML-query textarea like this:

<Where>
<And>
<Geq>
<FieldRef Name='StartDate' /><Value Type='DateTime'>{variable:thisWeekMonday}</Value>
</Geq>
<Leq>
<FieldRef Name='StartDate' /><Value Type='DateTime'>{variable:thisWeekSunday}</Value>
</Leq>
</And>
</Where>

Hit “Save” and your chart will always show the current weeks items.


The Google Visualization API team periodically releases a new version of the Google Visualization API. While the Visualization API team thoroughly tests each new version, bugs may still exist in any new release. You can test the release candidate before it becomes official by setting a variable in the CEWP code like this:

var loadRC = true;
Note on configuration option:
I have changed from “eval” to “jQuery.parseJSON” to handle the configuration options. The new method is a bit more picky on the syntax of the parameters and you must ensure to use double quotes and not single quotes for the option value.

Example:
Wrong syntax
colors:['red','#004411']
Correct syntax
colors:["red","#004411"]


If you use this solution, please consider buying me a beer!

Alexander

239 Responses to “SPJS Charts for SharePoint v3.x”


  • Instead of eval, you could (should?) use a library like json2.js . It is the library I use for backward compatibility.

    • I tested this library in the process, but I could not get it working as the built in JSON.

      I’ll look at jQuery.parseJSON you referred below.

      Alexander

  • Actually, as your solution is based on jQuery you could use the jQuery built in parseJSON http://api.jquery.com/jQuery.parseJSON/

    • Hi,
      I was actually not aware that jQuery had this built in… Thank you!
      I’ll look at it and see what I can do to get away from eval.

      Alexander

    • I updated to 3.1.1 and JSON does not seem to like the Google API customization options.

      FireFox Error:

      Configuration Option error in “Team Chart”

      Parameter: colors
      SyntaxError: JSON.parse: unexpected character

      ——

      Formatters used:

      title:Team;vAxis.format:###%;vAxis.minValue:0;vAxis.maxValue:1;focusTarget:category;legend:none;colors:['tomato','#4682b4'];hAxis.slantedText:true

    • More information ..

      Webpage error details

      User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
      Timestamp: Mon, 6 Feb 2012 21:48:59 UTC

      Message: ‘formatterArr[...]‘ is null or not an object
      Line: 2463
      Char: 4
      Code: 0

    • Change the single quotes for double and you should be good to go.

      Alexander

  • It seems not to ignore the case. If there’s a SharePoint site collection url /sites/SiteAddress users sometimes write /sites/siteaddress or /sites/Siteaddress , which causes charts not to render.

    • Hi,
      I’ll need a bit more details on web browser and possibly a few screenshots to understand the problem.

      Alexander

    • The problem at least seems to occur when storing the charts in list view aspx pages.

      For example, adding a chart in /sites/SiteName/Lists/ViewAddress.aspx generates a SPJS config list row /sites/SiteName/Lists/ViewAddress.aspx. Now when accessing the site with /sites/sitename/… the chart does not show up and modifying the chart changes the SPJS config entry to Lists/ViewAddress.aspx (omitting the /sites/SiteAddress/ from the beginning).

    • Hi, I see that your site is on a managed path, but i need some more information.

      Are you using the latest version (3.1.2)?
      Are you site collection administrator?
      Which browser are you using?

      Alexander

    • I am using the latest version (but the problem was present in the previous version I used 2.9.x also). The browser is IE9. I am the site collection administrator.

    • Safari, Chrome, FF do not fill the Select view dropdown in SPJS chart configuration.

    • Hi,
      I guess the missing view issue has to do with a wrong setting in the “web” selector.

      I did a fix for Firefox forgetting the “web” when editing a configuration in v3.1.2 Is it this one you have been using?

      I have released v3.1.3 with a few bugfixes for a mistaken “prop” vs “attr” issue.

      I have put back the “GeoMap”.

      Please try it and let me know if it helps.

      Alexander

    • GeoMap works as well as SPJS configuration with FF3.6+, Chrome, Safari, thanks.

      However, the url issue still exists. Say I place the chart on the root default.aspx of the site collection. Now when I first access the site using /sites/SiteName/default.aspx I get to configure the chart and it works. But when I now access the site using the lowercase address /sites/sitename/default.aspx I see a default chart instead of the the configured one. I have to configure the chart again. But if I now access the previous address /sites/SiteName/default.aspx I see the old configurations: SPJS has created me two configuration entries in the SPJS Charts for SharePoint configuration list:
      /default.aspx:MyChart1
      and
      /sites/SiteName/default.aspx:MyChart1

    • This issue should be fixed in v3.1.4. Please test it and report back.

      Alexander

    • Setting the region parameter caused a JavaScript error ‘Object doesn’t support property or method ‘toLowerCase’.
      I only checked the region parameter. The browser was IE9.

    • This error was there also earlier I guess.
      Based on quick testing text values seem to work (‘world’) but numeric not.

    • I’ll need a screenshot to see how your configuration looks like – and the error message. I have tested using
      Option: region
      Value: 011
      and it works as expected.

      Alexander

    • Works when region code starts with 1. Throws an error if region code starts with zero.

      For example, testing with region code 150:

      Chrome:
      Uncaught TypeError: Object 150 has no method ‘toLowerCase’

      IE9:
      Microsoft JScript runtime error: Object doesn’t support property or method ‘toLowerCase’

      Note: in IE9 the debugger shows the following code as yellow throwing the error: var a=Pj(a[Mb]())
      after the following code:… Km=em(“regioncoder”,Gc)+”geocodes”,Lm={};function Mm(a,b){var a=Pj(a[Mb]())

      Firefox:
      the error message is “a[Mb] is not a function.

    • Sorry it was just the opposite: Works when region code starts with zero, throws an error is starts with one.

    • Please send me some screenshots of your chart configuration (the GUI) as i cannot recreate this issue.

      Alexander

    • This is fixed in v3.1.5.

      Alexander

    • Thanks, works fine!

  • GeoMap seems not be available any more..?

    We seem not get the highlight effect or nice looking fonts oob with the new GeoChart. Maybe this is because SharePoint uses some IE8 compatibility rendering?

    Would it be possible to have the alternative to use the old (Flash based) GeoMap?

  • Hello Alex,

    im facing a problem with the new version:

    The “colors” Option with the “value” ['red','blue'] dont work anymore.

    Parameters: colors
    Syntax Error: unknown symbol

    Any idea?

  • Hello Alex,
    I am really scratching my head on this. I have everything working in terms of adding 3 CEWP’s and 3 charts. Each chart is setup with a distinct id and the ids are referenced in the script. However when the charts display, I get 3 instances of the “edit chart” at the top of each graph as well as 3 instances of the totals at the bottom of each chart. I can’t seem to figure out why…any thoughts?

    • Hi,
      Look at the file “CEWP_multiple_charts_in_one_page.txt” here

      It will give you 3 charts in one CEWP.

      Alexander

    • Thanks that worked great! One final question for you. I am not a programmer so most of this is greek to me. :-) Is there some way in the interactive chart to have it link to a list view? In other words if I hover over October sales in the chart and it shows the totals, can I click there and open the list with that specific view?

    • Hi,
      Add this example function to your CEWP code and tweak it to match your setup:

      function chartSelectionHandler(data,chart,chartID){
      	var selection, item, x, y, z;
      	selection = chart.getSelection();
      	if(selection.length>0){
      		item = selection[0];
      		if(item.row!==undefined){
      			x = data.getFormattedValue(item.row, 0);
      			if(item.column!==undefined){
      				z =  data.getFormattedValue(item.row, item.column)
      				y = data.getColumnLabel(item.column);
      			}
      		}
      		if(x===undefined && y===undefined && z===undefined){
      			return;
      		}
      		// Create your filter
      		alert("These are the variables you can use for your filter:nnx = "+x+"ny = "+y+"nz = "+z);
      		if(confirm("Open filtered list?")){
      			if(chartID==='MyChart1'){	
      				window.open('/test/English/Charts/Lists/ByStatus/AllItems.aspx?FilterField1=Status&FilterValue1='+x,'','width=1000');
      			}else if(chartID==='MyChart2'){	
      				window.open('/test/English/Charts/Lists/Coffee2/AllItems.aspx?FilterField1='+y+'&FilterValue1='+z,'','width=1000');
      			}
      		}
      	}	
      }
      

      Alexander

  • Hello Alex,

    hope your are well?

    If got a QUestion, how can i adjust the week with the variables in the CAML to the previous week?

    I tried to change the +/- Values, but that didnt make any change.

    Michael

    • Like this:

      var monday = new Date(today.setDate(today.getDate()-7));
      var sunday = new Date(today.setDate(today.getDate()-1));
      

      Alexander

    • And another thing depending this:

      Can i add a CAML Variable Filter and a Filter above the chart (filtering for author) at the same time?

      Im alsways getting an error, here the example:

      1
      2
      3
      4 {filter:Employee}
      5
      6

      and:

      1
      2
      3
      4
      5 {variable:thisWeekMonday}
      6
      7
      8
      9 {variable:thisWeekSunday}
      10
      11
      12

      at the same time?

      Michael

    • Here the code again:

      This together:

      Where
      Eq
      FieldRef Name=’Author’ /
      Value Type=’Text’
      {filter:Employee}
      /Value
      /Eq
      /Where

      with this:

      Where
      And
      Geq
      FieldRef Name=’EventDate’ /
      Value Type=’DateTime’
      {variable:thisWeekMonday}
      /Value
      /Geq
      Leq
      FieldRef Name=’EventDate’ /
      Value Type=’DateTime’
      {variable:thisWeekSunday}
      /Value
      /Leq
      /And
      /Where

    • Alexander Bautz

      Sorry for the late reply, but I have been busy.

      Like this:

      <Where>
      <And>
      <And>
      <Geq><FieldRef Name='EventDate' /><Value Type='DateTime'>{variable:thisWeekMonday}</Value></Geq>
      <Leq><FieldRef Name='EventDate' /><Value Type='DateTime'>{variable:thisWeekSunday}</Value></Leq>
      </And>
      <Eq><FieldRef Name='Author' /><Value Type='Text'>{filter:Employee}</Value></Eq>
      </And>
      </Where>
      

      Read here how to post code in comments

      Alexander

    • Hello Alex,

      thanks for your reply, it wasnt that urgent so its Okay.
      Also Thanks for the Information on posting code in a comment.

      Before i start to try it by myself, i bet its a 2 min thing for you.

      How can i change the date from “week” to, “last 3 month” it should be something like getMonth and -90, but im not sure if he is counting that for days or months, and im not sure with the counting for the current month.

      Michael

    • Alexander Bautz

      Hi,
      Still a lot of email to sift through…

      Something like this:

      var d1 = new Date();
      var d2 = new Date();
      var d3 = new Date(d1.setMonth(d1.getMonth()-3));
      
      var todaysDate = d2.getFullYear().toString()+"-"+(d2.getMonth()+1).toString()+"-"+d2.getDate().toString();
      var threeMonthsAgoDate = d3.getFullYear().toString()+"-"+(d3.getMonth()+1).toString()+"-"+d3.getDate().toString();
      
      var spjsCAMLvariables = {"today":todaysDate,"threeMoonthAgo":threeMonthsAgoDate};
      
      
      <Where>
      <And>
      <Geq>
      <FieldRef Name='StartDate' /><Value Type='DateTime'>{variable:threeMoonthAgo}</Value>
      </Geq>
      <Leq>
      <FieldRef Name='StartDate' /><Value Type='DateTime'>{variable:todaysDate}</Value>
      </Leq>
      </And>
      </Where>
      

      Alexander

  • Hi,

    Just wanted to raise possible bug here:
    Version 3.1.5 of SPJS charts does not allow setting option of combo chart to:
    OPTION: series VALUE: {5: {type: “line”}}
    It returns error when chart is generated (Configuration Option error: invalid json).
    When downgraded to 3.1, it works fine.

    Thanks – it’s great tool though!
    Regards,
    Kajetan

  • Brilliant charting program, just what I was looking for to use in SharePoint. My only headache is working out how to enter the correct options. One headache (for which there doesn’t initially appear to be a solution).

    I’m counting (over a month) the number of successfull events using a simple checkbox. When I come to display this in terms of Success and Fail, the legend only shows a 1 or a zero. Is it possible to change the legend so that it reads Success (in place of 1) and Fail in place of zero?

    Thanks for any help, and keep up the good work.

    • Alexander Bautz

      Hi,
      You find all the configuration options for each chart type by following the link to the right of the “Options” heading in the “Edit Chart GUI”.

      As for your chart, add a calculated column like this, and use it in your chart:

      =IF(Success=TRUE,"Success","Failure")
      

      Alexander

  • I am using this very helpful charts for sharepoint since version 2.4. But suddenly I encounter an error and the charts don’t load anymore. I tried deleting the configuration list but to no avail. The error message is ” Line: 126 Char:3 Error: Object doesn’t support this property or method. Code: 0″ I am using IE7 and Sharepoint 2007.

    I need help. Thanks!!!

    • Hi,
      Is it possible for you to try loading the chart using another browser – like Firefox or Chrome?

      Are you using the latest release – 3.1.5?

      Alexander

  • Hi Alexander,

    I am using the latest release 3.1.5, I am using Firefox 3.6.26 and IE 7.0 in my office. Those are the only browsers allowed. It was fine before and all my graphs were working.

    thanks!

    • Hi,
      Do you get the same error in both browsers?
      Have anything else changed – like modified master page?

      I might be able to spot possible errors if you send me some screenshots – You find my email here

      Alexander

  • Hello Alex, I hope you are well.

    I have a problem : when I try to make the Average of a percent field, the result is only made with the left part of the floating value.

    Example : when I have this value : 2,56% and 4,21% the result is 3,00% and not 3,36%.
    Can you explain??

    Many thanks for your great job!

    • Hi,
      I did a test to see what I could find, but in my setup I get 3,39 (which is rounded up from 3,385).

      If you could provide some screenshots of the chart configuration, and the source list I might be able to tell what’s wrong.

      You find my email here

      Alexander

  • Once again your solutions are amazing! One (hopefully) quick question — how do you do wildcards in the dropdown filters? I want to view a graph for the entire team, and then filter it down to individual member levels.

    thanks!

    • Hi,
      I have have added this feature to v3.2. Please test it and let me know if it works as expected.

      You find the instructions by clicking the “Filter setup Instructions” above the filter setup textarea in the “Edit chart GUI”.

      Alexander

    • Awesome! Works like a charm; I’d already set mine up with the * so all I had to do was upload the 3.2 version and success!

      Thanks again.

  • Hi Alex,

    This is a feature request more than an issue. On any chart where I define my own colours ie. ["Amber","Green","Red"] to match the corresponding status of items in a list all works fine until the list is filtered or changes to include less than 3 unique status values. ie. if I had only Green and Red items, Green ones would show as amber and red ones would show as green!. Is there a way to link specific colours to specific values rather than just allocating them in order??

    Thanks again for an awesome solution!

    Jeremy.

  • Alex,

    Great product.
    I am having an issue with access (?). I set up the chart and have another user access the site to look at the page. Instead of seeing the chart, he gets a blank page to create his own chart. He is also an admin so he has full rights to the site and page. The configuration is SP Foundation 2010 on a hosted environment using Safari, Chrome, and IE.

    Gus

    • Hi, Look at the configuration list – in the title field. Compare the record for your chart with the one created by your colleague. Post back your findings here. Alexander

  • mcurtin@hntb.com

    I apologize for this very basic question. I was able to download the .js files here.

    http://spjsfiles.com/index.php?dir=SharePoint+JavaScripts%2FSPJS_ChartsForSharepoint%2Fv3.2%2F

    But when I try to download the CEWP.txt file, when I click on it, I just get a blank screen. Tried left click, right click, save as, etc. Nothing worked. Not sure what I’m doing wrong. I can open the Version txt file fine.
    Any ideas?
    Thanks
    Mark

  • worked brilliantly for about 10 minutes, and now I don’t get any charts rendering, no error messages when i’ve not put in the parameters & using multiple charts only brings up one edit box.

    Have tried deleting all of the files and the config list, moving all of the files, even tried installing 3.1.5 instead of 3.2 Totally weird, as all was working really well.

    Is there a debug mode so I can figure out what is going wrong??

    • Hmm, rather odd, seems to have started working again. I suspect it was something to do with the View option, changing away from DEFAULT VIEW seems to cause problems for me.

  • Alexander

    i’m trying to draw a line on bar graphs – just like the combo graphs where we can have a line drawn on columns graphs. Any thoughts or work-around suggestion?

    thanks
    Clare

    • You can configure a bar chart using the “combo chart settings” “series” and “seriesType”.

      Alexander

    • Alexander, i tried using combo chart and make SeriesType=”bars”. it’s still showing the “bars” vertically, not horizontally.
      thx
      clare

    • Alexander
      I tried typing seriesType=”bars” and series={4: {Type: “line”}}, using your v2.9.3.2-packer.js and it still giving me incompatible error.

  • I see. I tried again and didn’t get it to work.

    I’m using your v2.7 SharePoint using Google Visualization API.

    I’ve chosen Chart type = Bar Chart (there isn’t Combo Chart in this version of Google Visualization API)

    SeriesType = “bars”
    series = {4: {Type: “line”}}

    I got “Incompatible default series types” error. Would that mean that i need to upgrade the API?

    • Hi,
      The Google Visualization API is the same in all versions of this tool. – it’s referred from Google and not a part of the files you download from me, and therefore the “series” and “seriesType” parameters should work.

      You should however upgrade to v3.2 and test it by setting up a working Combo Chart. Then flip the “Chart type” select to “Bar Chart”.

      Note that you will have to reconfigure any “filters” for charts you have configured “pre v3.0″.

      Alexander

  • I love this script, thank you!

    However, It works for me but does not show to other users.

    I am using a Current User filter for a list on the page as well as a filter within the charts for the same purpose. The list shows for other users and other page administrators can see the web parts in site edit mode so the page seems to be okay.

    I have tried changing the edit-access to give the group access but that didn’t work either.

    Suggestions (if you have a chance)?

    • Hi, This solution requires Internet access as some files must be referred from Google. Could this be the case? Alexander

    • Thanks for the reply Alexander. As it turns out this problem was strictly between keyboard and chair.

      Note to self: CHECK IN files.

  • Hi, when I click the CEWP.txt files they all appear blank.

  • Hi Alexander,
    is there a way to auto refresh the chart webpart?
    thanks
    britta

    • Alexander Bautz

      Hi,
      Not in the GUI, but you can add this to the CEWP code:

      setTimeout(function(){
         location.href = location.href;
      },10000);
      

      This will refresh the page after 10 seconds.

      The rather odd “location.href = location.href;” is used to ensure you do not resend information to the server if you have edited any webparts in the page during your “stay”.

      Alexander

  • Hi Alexander,
    Thanks for a very powerful solution!
    I upgraded to 3.2 in order to use “Show All” in the drop down filtering. Initially it worked great. However, I receive a CAML-query error once I started using site columns in my list. Is this a known limitation or do I need to modify the FieldRef Name?
    Claes

  • Hi Alex, I just want to let you know that i am working on some improvements in your script. My goal is to let users click on a chart area and be redirected to a specific Sharepoint list, filtered to match the clicked chart area.

    I intend to do so by using the event “select” of method addListener.
    it has to be something pretty straightforward but so far I have not manage to make it work.

    e.g.:
    google.visualization.events.addListener(pie_chart, ‘select’, function() {window.open(http://mysharepointsite.com/mylist/filteredview.aspx?parameter)})

    Any comments on that would be appreciated.

    Best regards,
    Paulo.

    • Just found the spot! Line 1350.

    • Alexander Bautz

      Hi, I have implemented a “listener” in the solution already, but this feature is not available in the GUI. Read this post on how to use a function in the CEWP code to pick up the necessary triggers to redirect to a filtered list

      Alexander

    • the only reference to “listener” I got from a code search is here:

      		if(typeof(chartSelectionHandler)!=='undefined'){
      			
      			google.visualization.events.addListener(chartObj[config.myChartId], 'select', function() {
      				chartSelectionHandler(data,chartObj[config.myChartId],config.myChartId);
      				
      			});
      		}
      

      but i couldn’t use it.
      I just finished the script and here it goes:

      		google.visualization.events.addListener(chartObj[config.myChartId], 'select', function() {        
      		    var row = chartObj[config.myChartId].getSelection()[0].row;
      		    //i have more than one chart in the page, so i have to select witch one is being clicked.
      		    var urladd;
      		    switch(config.myChartId){
      		    	case 'MyChart1': 
      		    		urladd= "byquarter";
      		    	break;
      		   		case 'MyChart2': 
      		   			urladd= "bytech";
      		   		break;
      		   		case 'MyChart3': 
      		   			urladd= "byindustry";
      		   		break;
      		    }
      
      //open the url
      		    window.open('https://ts.accenture.com/sites/tgpindres/Proposal%20Factory/Forms/'+urladd+'.aspx?param='+data.getValue(row, 0))
      		}); 
      
      

      I hope you can use it and implement in a future release.
      Best regards,
      Paulo.

    • It is indeed kind of tricky to implement it in the UI because you have no way to know upfront witch options (i.e. columns) you are going to map urls.

      I will try to figure it out and if i have clue i get back to you.

  • Alex, I am using a Document Library as a source for a chart and it seems that the chart only plot the first 30 points, although I have more than 30 files in the document library.

    I have tried to check possible filters or item limit for the view but everything seems to be ok.

    Does your script have any limitations regarding the number of points it can plot?

    • Alexander Bautz

      Hi,
      A document library has “paging”. Edit the view, scroll down to “Item limit” and the setting “Number of items to display”. I guess this is set to 30, and that “Display items in batches of the specified size” is selected.

      Set this to whatever number of items you want to view, or use a custom CAML to work around the item limit.

      Alexander

    • Exactely! Thanks for your help.

  • Hi Alex,

    My question have little to do with the Charts, but i think I can use your script to get over it.
    Im trying to implement a KPI (key performance indicator) to track the average time that it takes to submit an order in my system.

    I track this info in a List where I have 2 data fields “Order Start” and “Order End” and trough a calculated column I can get uniquely, for each record, the time to submit (End-Start).

    Problem is, i cant get the calculated field to appear in the Totals list field, where I could use the average to came up with the KPI value.

    Do you know anyone that have done something like it? If once I could query the list using SQL, i could use select average(submit_time) from orders… but I couldnt find any CEWP implementations that allows one to do such thing.

    Sorry for the off-topic.

    Regards,
    Paulo.

    • Alexander Bautz

      Hi,
      You can achieve this by setting up a chart like this:

      Alexander

    • Hi Alex, thank you a lot. The solution you proposed worked very fine.

      I just bought your book from Amazon Kindle and it is a very good resource i think will help me and my coworkers maintaining our sharepoint sites as well as implementing new user requests.

      Best regards and keep the good work.

  • Hi Alex,

    When trying to implement the latest code on a site I’m getting the prompt to creat the configuration list but on selecing ‘OK’ it then comes back with an error – “Error creating list: undefined”. I notice you make reference to upgrades on multilanguage installations which I think may relate to my problem but I’m unsure what you mean by “Ensure you have selected the “native” language for the site collection..”.

    Any assistance apprecited, thank you.

    Jeremy.

    • Also of note, it confirms the list has been created, but still then pops up the error. The list has been created but is empty.

    • Alexander Bautz

      If your portal is English, with Norwegian language pack, ensure you go to the “welcome menu” and select “English” before you load the page with the chart that triggers the upgrade.

      Alexander

    • Hi Alex, it’s a hosted solution so I’m not sure i ever get to see that menu. I’m assuming as its hosted it’s also US English. Previous versions work fine and I’m sure I’ve had the latest version working on some team sites but it just wont play on others. Anything further I can do to debug?

      Thanks.

    • Hi Alex, now identified that jquery 1.4.4 is loaded earlier in the page by my master template. Now trying to identify a way of forcing your code to run with 1.6.4 or later alongside the earlier version. Any thoughts?

      Thanks.

    • Alexander Bautz

      Hi,
      Try adding this to your CEWP

      alert("Original: "+$.fn.jquery);
      jQuery.noConflict(false);
      alert("Overridden: "+$.fn.jquery);
      

      You might try passing “true” as argument to the noConflict-function.

      Alexander

    • Thanks Alex, managed to get that to work eventually!

      Jeremy

  • Hello Alex,

    its me again, if got a Question:

    Im using a Calendar with Categorys, if got 10 Categorys and just want to filter out 4 of them, therefor i added the Categorys to my Chart-Config.
    I added a column to but out the Title if the Category is true, so i got it to work to but out the Titles in the Chart instead of the Categorys.

    The Problem is:
    1. The Chart is always printing out the Categorys i choose, but also but out the Categorys merged together i dont choose.
    2. Is it possible to set a specific color for the output (for all items in Category 3-> green, for all items in Category 4->blue…)
    3. How can i but out All Events starting at the beginning of this year until today?

    Thanks for your help again!

    Michael

    • Alexander Bautz

      Hi,
      1. Create a filtered view in the list and use that as source for your chart.

      2. You cannot “bind” a color to a specific category, but if you always have 4 categories, you can add an array of colors as an option in the chart configuration.

      3. Add this code to the CEWP (the one for the chart setup)

      // Get todays date
      var today = new Date();
      // Convert the dates to ISO8601 format: yyyy-mm-dd for use in CAML
      var thisYearStart = today.getFullYear().toString()+"-01-01";
      var spjsCAMLvariables = {"thisYearStart":thisYearStart};
      

      Use this as “Custom CAML” for your chart:

      <Where><And><Geq><FieldRef Name="Date"/><Value Type='DateTime'>{variable:thisYearStart}</Value></Geq><Leq><FieldRef Name="Date"/><Value Type='DateTime'><Today /></Value></Leq></And></Where>
      

      Alexander

  • Charting requires more numeric columns than I have available. I was hoping I could map text values to numbers somewhere, but I’m not seeing how to do that (“Not started” = 1, “Request sent” = 2, etc). How would one address this problem?

    • Alexander Bautz

      Create a calculated column with a formula like this: =IF(Status=”Not started”,”1″,IF(Status=”Request sent”,”2″,”N/A”))

      Alexander

    • Thank you. I have now done this, using Christophe’s concatenation trick to make a nesting of 10 conditions. Works wonderfully.

  • Hi Alexander,

    I have updgraded from an earlier version of your charts in the hope to solve an issue I was having (also so that I could use multiple filters) but it seems that not even this version will do.
    The problem I am facing is that some of my filter options have single quotes, like
    “Alexander’s Charts”
    The chart returns no values, looking at the soap post in Firebug I see that the CAML is constructed like so
    “Alexander”
    As in, the single quote is taken as a string delimiter. Escaping it
    ” ‘ ”
    raises an error in JSON parsing. Not sure at all what to do.
    Do you have any suggestions?

    Other than that, your script is awesome.

    Thank you.

    Vinz

    • Not an ace at JavaScript, but I think the problem is with jQuery .val() when getting the filter values from your GUI to populate the option dropdowns when the chart is then generated.
      Entering the option values with apostrophe/single quote escaped with &#39 seems to be it.

      • Alexander Bautz

        I’m actually looking at it right now. I’ll try to find a fix and update this article when it’s published.

        Alexander

    • Alexander Bautz

      Hi,
      Could you test v3.2.2 to see if you get it working?

      Alexander

    • Hi Alexander,

      3.2.2 works absolutely great!
      Thank you very much for finding the time to look into it.
      I also see you have fixed an issue I noticed with an earlier version whereby filter options were not saved if entered in Firefox. I am very pleased about it.

      You are a star!

      Vinz

    • Alexander Bautz

      Thank you :-)

      Alexander

    • Enjoy your pint, well deserved :)

  • Hello Alex,
    I’ve just managed to get the Charts to work in my area – Thanks for this great little script.
    I’m trying to get multiple charts to open on a single page to make up Dashboard but it only displays that last chart that I add. I’ve edited the CEWP text to have different ID’s but all I get is two GUI edit arrows stacked on top of each other. Do I need to have seperate .JS files for each chart?
    Thanks for your efforts

    • Alexander Bautz

      To have multiple charts in one page, edit the CEWP code something like this:

      <table cellpadding="0" cellspacing="0">
      	<tr>
      		<td id="TopLeft"></td>
      		<td id="TopRight"></td>
      	</tr>
      	<tr>
      		<td id="BottomLeft"></td>
      		<td id="BottomRight"></td>
      	</tr>	
      </table>
      <script type="text/javascript">
      /*****************************************************
      		Address all containers
      *****************************************************/
      // All charts must be represented by a container with a unique id. This container  must be present in the page
      
      arrOfChartContainers = ["TopLeft","TopRight","BottomLeft","BottomRight"];
      
      </script>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script&gt;
      <script type="text/javascript" src="https://www.google.com/jsapi"></script&gt;
      <script type="text/javascript" src="/test/English/Charts/Javascript/SPJS_ChartsForSharePoint_v3.2.1.js"></script>
      

      Alexander

      • Thanks for your quick reply.
        So far I have not been able to get it working, the SPJS list created the new items, but the CEWP with the .txt attached remains empty. I’ve also tried pasting the text into the html editor but this did not work either. I well, I will try again next week. I’m using jquery1.7.2 is that a problem?

    • Alexander Bautz

      Hi,
      You are supposed use one CEWP with script calls in the page. Not call the script multiple times. The charts you want to display must have an unique container ID, which must be in the array “arrOfChartContainers”. This container must be present in the page, but can be placed in another CEWP (without the script calls).

      If you place containers in another CEWP, ensure that the CEWP with the script is placed in the bottom right web part sone in the page.

      Alexander

  • Thanks – I’ve got it working, though I don’t get the Edit GUI arrow on the 1st and 3rd charts (using the 4 cell table) unless I have two CEWP’s with the script on the page (then the 2nd and 4th get two arrows).
    Also note that the charts are stacked vertically, but maybe I need to play with hard wired cell dimensions. I’ve got something working so I’m happy.

    I have a question relating to Slideshow for SharePoint which I will post on the blog page http://spjsblog.com/2011/02/20/slideshow-for-sharepoint

  • Hi,

    I am having an issue with ‘Treat zero values as null’ not working.

    I tick the box, save the changes, but the chart does not change and when I go back to the options – the tick box is unticked,

    I am using v3.2.2

    thanks
    Tom

  • Please advise how to do a CAML to show items only if its not null

  • Hi

    Thanks for the brilliant code we’ve been able to incorporate a hand full of graphs into our stat’s logs. I’m using version v3.1.5 (February 21, 2012), and don’t particularly want to change it as up until today it’s simply worked. Today however it doesn’t, all my users are experiancing an Invalid Agrument error in place of the graphs, however if you look at the graphs on the server using a service account they’re fine.

    We’ve a few ideas of where to start, unfortunatley weren’t been any updates to the system last night, and I’m using an admin account and get the same error, so those ideas are dwindling rapidly.

    Any ideas on whatelse could be causing this to happen?

    Thanks
    David

  • I use SPJS_ChartsForSharePoint_v3.2.2. I try Combo Type report but i get error ‘Parameter: series SyntaxError: JSON.parse: expected property name or }’
    It is bug ?
    I set series value is {5:{type:”line”}}

    • Alexander Bautz

      Hi,
      Read the “Note on configuration option” at the bottom of the article. You must wrap the property name in double quotes like this:
      {5:{“type”:”line”}}

      Alexander

  • Hi Alexander! Your JS is great! It saved my life! I have just one question now: how can I add a filter or exclude items from a chart if they have a specific value. Example:
    Issue | Stage
    Issue01 | 1 – In Progress
    Issue02 | 1 – In Progress
    Issue03 | 1 – Escalated
    Issue04 | 3 – Close
    Issue05 | 3 – Close

    I just want to have in my charts issues that are in progress or escalated (that means also exclude all issues that are closed). Thanks!

    • In fact, I have another question. I’m having problems when creating a Pie Chart. I have a list like that:
      ISSUE – WEEK01 – WEEK02…WEEKN
      Issue01 – 89 – 45 – 12
      Issue02 – 89 – 45 – 12
      IssueN – N – N – N
      The numbers in my list means customers affected by this issue each week. I can create the chart, but the WEEK and ISSUE are reversed. That means, hAxis is the name of the issues, when it should be Weeks. And the lines are the Weeks, when it should be the name of the issues. Not sure if I was clear, and I can’t paste an image here. Thanks again! Brilliant work! :)

  • Ok, I might need to buy your tutorial or something, because I’m not getting to configure the charts the way I need. :) They are working, but I’m not being able to change color of text on legends, and so on… Do you have a tutorial like that? I would like to buy even in digital form.

  • Alex, I have a sharepoint list with columns of choice (yes/no) type for each month (Jan through Dec) in an year where user checks boxes for each month. I want to render a chart to show monthly values. When I used column or bar chart I don’t see columns/bars in the chart (it’s empty). I see a legend, false/true on x-axis and 0-1 on y-axis but no bars/columns. What options I should choose in the configuration. I am using v3.3.

    • Alexander Bautz

      Hi,
      I need a screenshot of the list you use as datasource to be able to help you with this one.

      Alexander

  • Hello Alexandre,
    Awesome solution!
    I was trying to figure out how to create a dashboard using your solution and seem that the secreat are in the CEWP code.
    I looked the solution you have provided to Jean Pierre using a table and actually using the last version 3.3 I was trying to using the alignment on the , but when I use filters on my chart looks like the filter field does not follow the div alignment, probabbly this is set up in another div inside your code, is this make anysense?

    • Alexander..
      I am trying to align it on the div and happens what I told you below, it seems that the filters do not follow the div alignment

      <div id="MyChart1" style="float:left"></div>
      <div id="MyChart2" style="float:right"></div>
      <script type="text/javascript">
      /*****************************************************
      		Address all containers
      *****************************************************/
      // All charts must be represented by a container with a unique id. This container  must be present in the page
      
      var arrOfChartContainers = ["MyChart1","MyChart2"];
      
      // Set this to true to load the release candidate
      var loadRC = false;	
      </script>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script&gt;
      <script type="text/javascript" src="https://www.google.com/jsapi"></script&gt;
      <script type="text/javascript" src="XX/SPJS_ChartsForSharePoint_v3.3.js"></script>
      
    • Alexander Bautz

      Hi,
      Use a table to align the containers:

      <table>
      	<tr>
      		<td>
      			<div id="MyChart1"></div>
      		</td>
      		<td>
      			<div id="MyChart2"></div>
      		</td>
      	</tr>
      </table>
      

      Alexander

    • Thanks Alexander.
      That solved my problem.

    • Just for curiosity, it is possible to have your solution working together with the Christopher’s solution (Easy Tabs), if so we would consider to create a script for each CEWP and the containers should have unique ID’s?
      Regards

  • Just for curiosity, it is possible to have your solution working together with the Christopher’s solution (Easy Tabs), if so we would consider to create a script for each CEWP and the containers should have unique ID’s?
    Regards

  • Hi Alex,

    Thanks for a wonderful blogs.
    i am new to sharepoint. So need some help. I want to create multiple chart view of the report. My report contains. Name and the score for each person of different levels(say level A, Level B.. ). I am able to create a columnchart view for Level A, Level B seperately. But i need to display all the report in same page for all the levels.

    So can you please help me on that.

  • Hi. Really (dumb) quick question. Will the solution work on SP2007?

    I know, I know, you dont need to tell me…. :) We are moving to SP2010 but still have P2007 for the moment.

    I have followed the instructions on a SP2007 site but dont get prompted to create the configuration list…

    Thanks

    Paul

  • Hey Alex,

    Great tool! this is SO much better then using the Office Pivot Tables webpart! One issue we seem to be experiancing is that theres anywhere from a 30 second to 2 minute lag now when loading the page, durring that time the page is fully loaded minus the graphs and is unresponsive. I’m running 3.3.1. Thoughts?

  • Thanks a lot for sharing this solution.

    I am trying to animate the gauge chart by adding animation.duration and animation.easing options. These options doesn’t seem to affect the chart and the gauge pointer doesn’t animate.
    Did anyone encounter this problem?

    Also, can we change the color of the pointer in gauge chart?

    Thanks again!

    • Great tool, thanks! I’m also trying the animation options for the column chart, but these don’t seem to do anything either. Is this a know issue?

      Thanks

    • Hi,
      Sorry, but to have the animation work, you must edit the source code in the file “SPJS_ChartsForSharePoint_vX.Y.Z.js” file.

      How is it you trigger the change to the chart data that you want to animate?

      Regarding the graphics of the gauge: I do not think it is possible to change it as it’s not an image, but SVG or VML.

      Alexander

    • Trigger? I thought it would animate just onload or something? Can you give some directions in where to enable animation in the SPJS_ChartsForSharePoint_vX.Y.Z.js file?

      Thanks!

      Peter

    • Hi,
      The transition animation in a chart is used to animate the transition when changing the chart data. In my implementation of this chart tool, there are no transitions as the data is not changed, only created.

      I will look into adding support for transition animation when applying filter to a chart, but as it stands now, you cannot use transition animation because there are no transition.

      Alexander

  • I’m using a filtered view as my data source, but it always uses data from the default view instead. Has anyone else attempted to use filtered view as their data source?

    • If you use Custom CAML, this overrides the selected view – is this the case?

      Alexander

    • Hi again,
      By filtered view , do you mean a filter with a filter web part – like “current user filter”?

      If so, this filter is not applied to the chart.

      Alexander

    • “If you use Custom CAML, this overrides the selected view”

      That was my problem. I’m having a lot of luck building the custom CAML queries with U2U CAML Query Builder.

      I’m just using the “Create filter(s) above the chart” option. I’m wanting to apply that filter to multiple charts on the same page by using the following code in the filter: “filterAdditionalCharts”:["MyChart2","MyChart3"] and inserting “{filter:Market}” (my filter variable name) into the value tags of MyChart2 and MyChart3.

      However, whenever I use the variable to filter the other charts – it makes the charts get stuck on “loading”. I have “alloweval” set to true in the CEWP.

    • Hi,
      It seems I might have broken the “filterAdditionalCharts” setting in an update…

      I’ll look into it.

      Thank you for the pint.

      Alexander

    • This issue should be fixed in v3.3.7.

      Alexander

    • After I update v3.3.7, urlKey filter does not work.

    • Sorry for the delay. I actually introduced a new bug in v3.3.7 that broke the filter if you did NOT use “filterAdditionalCharts”.

      This should be fixed in v3.3.8.

      Alexander

    • I’m able to get filters in 3.3.7 to work with SP2007 without “filterAdditionalCharts”, however none of the filters would work in SP2010. Maybe that’s the bug you’re talking about?

      When I upgraded to 3.3.8, it broke all of the charts for IE7 (unfortunately this a lot of our users). Only the arrow in the upper left would appear (no chart). However, it did work in Chrome.

      I also have a chart that uses a list with ~18000 records and it takes a while to load in IE7 – but it will load successfully. For some reason those pages with tons of records completely time out in Chrome and IE9.

    • Hi,
      Do you get any errors (exclamation marks in bottom left corner) in IE 7? If so, double click the exclamation mark and post the error message.

      Alexander

    • I think it was my error. I set it up again and it worked just fine with 3.3.8 in both SP2007 and SP2010.

      It also fixed the issue with timeouts in Chrome and IE9 for the charts with an extremely large pool of data. (or maybe my sharepoint server is just running fast today and not taking long enough to timeout?)

      In IE7 selecting multiple items with multiselect gives: ‘customCAML.match(…).1′ is null or not an object

    • I tried downgrading to get Chrome and IE9 to timeout on the charts that use tons of data – but it worked with the old version too. My sharepoint server is just having a good day today.

      It’s weird how IE7 and IE8 will keep loading if the load time is more than 10 seconds, but Chrome and IE9 seem to timeout.

  • When I put whole numbers on the X axis, they come out looking like this: http://imgur.com/swU65

    The same thing happens when I use string type for the column.

    I tried the following (did not work):
    var chartOptionOverride = {“MyChart1″: {hAxis: {‘format’:'#’}}};

    Also, I tried using the NumberFormat field in SPJS charts and it did not work.

  • Hi, Thanks for making a great and easy to use charting tool for SP, I only have one question (and it may have already been answered) How can I get the chats to appear side by side on the page rather than on top of each other when using multiple charts? I’ve tried changing the div tags, and putting them into a table, but no joy.

  • I wanted to dynamically select an item from the filter drop-down, here’s how I did it: http://paulsprogrammingnotes.blogspot.com/2012/11/spjs-charts.html

  • Know what would cause the “Hit error fn!”?

    It only happens on IE7, and the page still works after clicking past the error.

  • Something which may make spjs charts more intuitive to new users, is changing the code for “Prefill textarea from choice field:” to allow for filtering by text fields also.

  • Alexander,

    I can’t get the chart configuration screen to open. The configuration list was successfully created. The Form Web Part holding the “MyChart1″ container says “Loading Edit Chart GUI. Please wait….” and it just stays on that indefinitely.

    The IE Dev Tools error console has this error in it:

    “SCRIPT5007: Unable to get value of the property ‘join’: object is null or undefined
    SPJS_ChartsForSharePoint_v3.3.6.js, line 2965 character 8″

    Do you know what this one means? Thanks!

    • Hi, i suspect there is another script in the page interfering with the variable “fht” defined in line 2554. Try changing all occurrences of “fht” with another name to test it.

      Alexander

    • Thanks for the reply! I replaced fht with fhtNew in every occurrence, but there was no changes. I still see the “Please wait…” forever. Also, I have no other scripts running on that page except the ones in the sample CEWP.

      What is the Google jsapi script for again?

      [code]<script type="text/javascript" src="https://www.google.com/jsapi"></script>/code

    • The jsapi is the script that generates the charts. This must be referred from Google, and you must be “online” when using this solution as you are not allowed to download the jsapi files locally (Google terms of use).

      Have you been successful implementing this chart solution in another site?

      Alexander

      • I implemented one of your first versions on SP2007, but haven’t tried since we migrated to SP2010.

      • There can be incompatibilities if you have modified the master page or other customizations. Is your SP2010 system standard, or is it enhanced / modified in any way?

        Alexander

      • The only master page modification is a reference to pick up another style sheet. We have a custom branding site feature, but I turned it off to test the conflicts I was having with the vLookup script on another list. Otherwise everything is plain old SP out of the box. (as far as I know)

      • Could it be a conflict with multiple instances of jQuery being loaded? – maybe one version is loaded in the master page?

        Alexander

  • Hi Alex.
    Great tool (I bought the book!).
    Problem: On the chart configuration, the column listing doesn’t show all the columns in the selected list.

    Am i missing something?

  • Hi, the column type is decimal.
    thanks

  • It is an external list from a view in separate SQL database. I tried other external lists… I can see everything apart from decimal typed columns.
    To get me going, i am directly editing the entry in the chartcols field in the ‘SPJS Charts for Sharepoint’ list.

    • Hi,
      Sorry for the late reply. I have not tested this with external content types, but you might be able to get this working if you look at the function “customGetListFields” and the array “arrOfTypesToIncludeInNum”.

      Alexander

  • Quick Question: How do I maintain the title if the graph is empty (no records)? The title should persist even if the graph is empty.

  • I got a work around for the titles… I am not using the graph title… instead I just edited the CEWP script and put in the titles as text within the ‘divs’ / tables.

  • HI Alex.. quick one: How do I hide the legend.. if I don’t want it displayed?

  • Paul,
    Thank you so much!
    It works with the legend also under quotation marks i.e.:
    var charOptionOverride = {“MyChart1″: {“legend”:{position:’none’}}};

    pardon my limited jquery knowledge:
    I have multiple charts… i tried to enter the same expression multiple times (with respective chartIDs) but it only executes the last one.

    Am i missing something?
    Thanks

    • With multiple charts, it would work like this (make sure you change MyChart1 to the real ID of each of your containers):
      var charOptionOverride = {“MyChart1″: {“legend”:{position:’none’}}, “MyChart2″: {“legend”:{position:’none’}}, “MyChart3″: {“legend”:{position:’none’}}};

  • Paul,
    No worries… I used the chart GUI options. set legend.position to none for each of the charts and it worked.

    Thanks!

  • I think it is easier (for maintenance) to edit the CEWP… so perhaps I will go with your solution.

  • HI Alex,
    I am using tables to display multiple charts. I would like to collapse or hide the cell container if there are no records. This is to avoid the “no items found” box that appears.

    How can i go about this?
    thanks

  • Instead of hiding the cell container, i used a blank chart.

  • When I try to access a spjs chart (3.3.8) in safari, it gives the “Configuration list missing” error. I press cancel on that because I don’t want it to overwrite anything. After I press cancel, the console says “/_vti_bin/lists.asmx 400 (Bad Request)”.

    • Hi,
      Is this Safari for Mac or Windows? Does it work in other browsers? Does it work with versions before 3.3.8?

      Alexander

  • Thanks for sharing this! I have been able to get everything to work on my pie chart expect for one option. I can’t get the “pieSliceTextStyle” option to work. Here is the option value that I’m trying now but I’m having no luck: {color: ‘black’}

  • Alexandar had answered a similar question in an earlier posting… see Michael’s question above. It is to do with using double quotes.

  • Hi,
    Any way to prevent IE from leaking memory? Using a simple line chart it consume ~50MB after each refresh and that memory is not released after.

    • Hi, I do not know if this is possible. The memory will be released if you close the tab. Do you run out of memory? – if not, IE will consume more memory if you have a lot of memory available.

      Alexander

  • Hi Alexander,

    I really appreciate all the work you’ve shared.

    I’m having a couple issues and looking for suggestions. I’m using the CEWP and SPJS Charts For SharePoint v3.3.8 on a SharePoint 2010 foundation site.

    I have followed the instructions you provided regarding setup of these files and the charts. I’m having the following difficulties

    Launching the page prompts for the creation of the configuration list, however the list created is empty.

    I have included your recommended code for troubleshooting when script does not work, and I receive the following messages:

    “function” and then “undefined”

    I should warn you that javascript is not my native language and I am trying to learn as I go.

    Any recommendation for my next step is appreciated.

    Thanks

    • Hi,
      When the list is created, it is empty. You have to configure a chart and save it to add an entry to the list. What kind of errors do you get? If you hit F12 in IE you can bring up the console and look for errors there.

      The two alerts is OK I guess – if you did not change the “InsertTheFunctionNameHere” in the second alert.

      Alexander

  • Hi Alex,
    Do you have an option in the SPJS for exporting graph data to csv or excel? thanks
    Gilbert

  • “you can have parts of, or even the complete filter as a variable in the CEWP.”

    • Woops, didn’t complete my question.

      Can you show an example of a filter as a variable in the CEWP?

    • Alexander Bautz

      Hi,
      Sorry for the late reply.

      To use a variable as filter, you must set the parameter “allowEval” to true, and then you include the filter using the same syntax as described in the “Instructions” over the filter setup textarea like this (in the CEWP code):

      var allowEval = true;
      var myFilter = [{"label":"Category","urlKey":"Category","multiselect":false,"size":3,"options":[{"f":"Category 1","v":"Category 1"},{"f":"Category 2","v":"Category 2"},{"f":"Category 3","v":"Category 3"}]}];

      In the Filter setup textarea, you insert the variable name: myFilter.

      The filter can be generated by javascript in the CEWP as long as the syntax is correct.

      Alexander

  • I’m trying to create a line chart to show the average resolution time per category by assigned team. I can show the average resolution time by assinged team (vAxis = team, yAxis is set to average a column of resolution time in days). But I want to add a third dimension to calculate the averages based on the list item’s category. Is this possible?

    fields:
    Assigned team (string)
    Resolution time (integer)
    Category (string)

    column 0 = assigned team…string – merge duplicates
    column 1 = Resolution time…average

    do i add Category as a 3rd column in some way?

    • Hi,
      I do not think this is possible as you cannot have multiple categories / dimensions in one chart. You will have to make two separate charts.

      Alexander

  • Hi Alex,

    I’m using your solution to create a dashboard of charts and tables and it’s working great!

    I have one issue I can’t seem to resolve. I have a table of which I’m trying to sort by the first column using sortColumn and sortAscending. It works for every column index except when I chose sortColumn 0. I don’t get an error however it won’t load the chart or table. I’ve tested various fields in my list as the first column and get the same results. If I set sortColumn 1, it sorts the 2nd column perfectly.

    Any ideas?

    Thanks!

    • Hi,
      This was a bug with the “chart options parser” as the number 0 was interpreted as text. It is fixed in v3.3.81.

      Alexander

    • Thank you so much for looking into the issue! It’s working perfectly in most browsers however in ie, the charts or tables won’t load as soon as I point to the new js file even before attempting to set sortColumn to 0 however loads fine in Chrome or Firefox. Unfortunately my work deploys ie to all staff as the only browser.

      I’ve tested quite a bit but am at a loss.

    • First I tested in ie8 as that’s what they have at work and then I tested in ie9 with the same results.

      I noticed today that in ie there was the following error related to the new js file:

      ‘console’ is undefined
      Line: 1461

    • My bad, I forgot this line in the code!

      Remove line 1461 and you are good to go – I’ll update the code in the download section.

      Alexander

    • Thank you so much!! Works perfectly!

  • Hello Alex,
    I have a question about the items total.
    I created a list with 31 items, and the pie chart renders properly. but its only showing 30 items.
    Is there some lock on how many records can be used?

    • If you pull the items from a view, and not using a custom CAML, the paging size of your list will limit the item-count and give you only page 1.

      Increase the list view item-limit, or use a custom CAML.

      Alexander

  • Hello Alexander,

    What a great script this is! I do have one question :-)

    How should the sharepointlist be populated to make a map with 15 Markers of locations?

    Now i’ve got the columns: Longtitude, Altitude, Title (contains address) and Establisement.

  • Hi
    This is really nice.

    Question I have the following list structure
    Value 1 | Value 2 | Value 3 | Notes
    3 2 1

    I want top have on the bar chart under the bars those labels Value 1 ..3 instead of having it in the legend.

    Is there a way to do that ?
    thx

  • I am getting the below error when using “filterAdditionalCharts” option.
    ——————————————————
    [Custom CAML-query filter error]

    The custom CAML-query for the chart with id “MyChart2″ contains the following filter key: “Month”.

    This key is undefined.
    ——————————————————

    What am i missing?

    • To filter multiple charts with one filter, you must enter this in the configuration for your first chart:

      filterAdditionalCharts":["MyChart2"]
      

      In “MyChart2″ you then use the same CAML as you did for “MyChart1″.

      Alexander

  • Hi,
    first of all: great Work!
    Now i have a question: Is it possible to add a Rangefilter like that one:
    http://code.google.com/apis/ajax/playground/?type=visualization#chartrangefilter_control
    in the charts?

    thx
    Pawel

  • Hi,

    I have multiple column charts in a page with 4 series. While displaying the charts how to make sure the colors of series to be uniform in all the charts.

    JK

  • Alex

    I love your google Charts solution. As always you have went above and beyond. I was wondering if it is possible to create a custome CAML filter, to filter by the three views I have created of the list. I have “Coming Due”, “Past Due”, and “Completed 100%”. You will have to forgive me as I am not too familiar with CAML coding. But I would like to do this to filter between the different views in one chart so that I do not have 3 instances of the same chart on one page.

    Thanks in advance,
    Randy

Leave a Reply




%d bloggers like this: