-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
69 lines (65 loc) · 2.11 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.chartaccess = factory());
}(this, (function () { 'use strict';
var splitCamelCase;
splitCamelCase = function (camelCaseString) {
var index = camelCaseString.search(/[A-Z]/g);
// if there is a camelCase
if (index !== -1) {
var letter = camelCaseString[index];
var newStr = camelCaseString.replace(letter, " " + letter.toLowerCase());
return newStr;
}
else {
return camelCaseString;
}
};
/**
* generate fallback text for chart
*
* @param chartconfig: ChartConfiguration interface
*
* @returns {string}
*/
function generateFallbackText(chartconfig) {
var text1;
var chartType = splitCamelCase(chartconfig.type);
// substring 1
if (chartconfig.options && chartconfig.options.title) {
if (chartconfig.options.title.text !== "") {
var typeCapitalized = chartType[0].toUpperCase() + chartType.slice(1);
text1 = typeCapitalized + " chart titled, '" + chartconfig.options.title.text + "'.";
}
else {
text1 = "Untitled " + chartType + " chart.";
}
}
else {
text1 = "Untitled " + chartType + " chart.";
}
//substring 2
/*
if (datapointsThreshold(chartconfig, datapoints)) {
text2 = generateStringContainingData(chartconfig);
} else {
text2 = "";
}
*/
return "" + text1;
}
/**
* add fallback text for chart to its canvas
*
* @param chart: Chart instance
*/
function addFallback(chart) {
chart.canvas.innerText = generateFallbackText(chart.config);
return;
}
var access = {
addFallback: addFallback
};
return access;
})));