Charts and graphs - Thousands separator and custom preset functions

Looking for WET v3.1?

WET v4.0 is now the current version. There is a new location for the current page in WET v3.1.


Thousands separator

Comma separator

Default

Contributions to WET from May 5, 2012 to May 4, 2013
Contributor Commits Additions Deletions
pjackson28 1,713 1,483,907 928,648
nschonni 506 90,412 72,797
LaurentGoderre 398 52,983 29,957
duboisp 289 168,976 106,100
patheard 135 6,820 3,639
cfarquharson 85 18,572 3,518

With the CSS option (wb-charts-thousandcomma)

Contributions to WET from May 5, 2012 to May 4, 2013
Contributor Commits Additions Deletions
pjackson28 1,713 1,483,907 928,648
nschonni 506 90,412 72,797
LaurentGoderre 398 52,983 29,957
duboisp 289 168,976 106,100
patheard 135 6,820 3,639
cfarquharson 85 18,572 3,518

Dot separator

Default

Contributions to WET from May 5, 2012 to May 4, 2013
Contributor Commits Additions Deletions
pjackson28 1.713 1.483.907 928.648
nschonni 506 90.412 72.797
LaurentGoderre 398 52.983 29.957
duboisp 289 168.976 106.100
patheard 135 6.820 3.639
cfarquharson 85 18.572 3.518

With the CSS option (wb-charts-thousanddot)

Contributions to WET from May 5, 2012 to May 4, 2013
Contributor Commits Additions Deletions
pjackson28 1.713 1.483.907 928.648
nschonni 506 90.412 72.797
LaurentGoderre 398 52.983 29.957
duboisp 289 168.976 106.100
patheard 135 6.820 3.639
cfarquharson 85 18.572 3.518

Using functions within your custom preset

Goal: Extracting and parsing custom tabular data to create your chart or graph.

Declaring your custom preset

<script>
window[ "wb-charts" ] = {
	charts: {
		custom: {
			fn: {
				"/getcellvalue": function(elem){
					var raw = $(elem).text().replace(/\s\s+/g, ' ').replace(/^\s+|\s+$/g, '').replace(/N/g, '');
					return [parseFloat(raw.match(/[\+\-0-9]+[0-9,\. ]*/)), raw.match(/[^\+\-\.\, 0-9]+[^\-\+0-9]*/)];
				}
			}
		}
	}
};
</script>

The key for the fn object is similar to the JSON pointer defined in RFC 6901. The key identifies what should be overwritten with the function.

<table class="wb-charts wb-charts-custom table">

Contributions to WET from May 5, 2012 to May 4, 2013
Contributor Commits Additions Deletions
pjackson28 1N713 1N483N907 928N648
nschonni 506 90N412 72N797
LaurentGoderre 398 52N983 29N957
duboisp 289 168N976 106N100
patheard 135 6N820 3N639
cfarquharson 85 18N572 3N518
Date modified: