Last active
August 14, 2020 19:52
-
-
Save 23maverick23/a8585343e9ca1277b381368ddad7912c to your computer and use it in GitHub Desktop.
NS: Chart 012 (Heatmap)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getData() { | |
var recordType = "customrecord_sc_request"; | |
var searchId = "customsearch_scm_eng_by_sc_12_mos"; | |
var results = nlapiSearchRecord(recordType, searchId); | |
if (!results || results.length === 0) { return None; } | |
var data_all = []; | |
function DataEntry(x, y) { | |
this.x = x; | |
this.y = y; | |
} | |
var len = results.length; | |
var i = 0; | |
var j = 1; | |
for (i; i < len; i++) { | |
var series = []; | |
var cols = results[i].getAllColumns(); | |
var name = results[i].getText(cols[0]); | |
for (j; j < 13; j++) { | |
series.push({x: j.toString(), y:results[i].getValue(cols[j])}); | |
} | |
data_all.push({ | |
name: name, | |
data: series | |
}); | |
j = 1; | |
} | |
return data_all; | |
} | |
var callback = function() { | |
var data = getData() || null; | |
if (!data || data === null) { return; } | |
// var categories = ["This Month", "Last Month", "2 Mos Ago", "3 Mos Ago", "4 Mos Ago", "5 Mos Ago", "6 Mos Ago", "7 Mos Ago", "8 Mos Ago", "9 Mos Ago", "10 Mos Ago", "11 Mos Ago"]; | |
var d = new Date(); | |
var cm = d.getMonth(); | |
var categories = [ | |
d.toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-1)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-2)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-3)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-4)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-5)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-6)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-7)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-8)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-9)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-10)).toLocaleString('default', { month: 'short' }), | |
new Date(d.setMonth(cm-11)).toLocaleString('default', { month: 'short' }), | |
]; | |
var options = { | |
series: data, | |
chart: { | |
height: 420, | |
type: 'heatmap', | |
}, | |
plotOptions: { | |
heatmap: { | |
shadeIntensity: 0.5, | |
radius: 0, | |
useFillColorAsStroke: false, | |
colorScale: { | |
ranges: [{ | |
from: 0, | |
to: 1, | |
name: '0-1', | |
color: '#FFB200' | |
}, | |
{ | |
from: 2, | |
to: 3, | |
name: '2-3', | |
color: '#00A100' | |
}, | |
{ | |
from: 4, | |
to: 5, | |
name: '4-5', | |
color: '#128FD9' | |
}, | |
{ | |
from: 6, | |
to: 100, | |
name: '6+', | |
color: '#FF0000' | |
} | |
] | |
} | |
} | |
}, | |
dataLabels: { | |
enabled: true | |
}, | |
stroke: { | |
width: 3 | |
}, | |
xaxis: { | |
type: 'category', | |
categories: categories | |
}, | |
title: { | |
align: 'center', | |
text: 'HeatMap of SC Engagements (Trailing 12 Months)' | |
} | |
}; | |
var chart = new ApexCharts(document.querySelector("#chart012"), options); | |
chart.render(); | |
}; | |
if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) { | |
callback(); | |
} else { | |
document.addEventListener("DOMContentLoaded", callback); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getData(){var t=nlapiSearchRecord("customrecord_sc_request","customsearch_scm_eng_by_sc_12_mos");if(!t||0===t.length)return None;var e=[];for(var o=t.length,a=0,n=1;a<o;a++){for(var r=[],l=t[a].getAllColumns(),h=t[a].getText(l[0]);n<13;n++)r.push({x:n.toString(),y:t[a].getValue(l[n])});e.push({name:h,data:r}),n=1}return e}var callback=function(){var t=getData()||null;if(t&&null!==t){var e=new Date,o=e.getMonth(),a={series:t,chart:{height:420,type:"heatmap"},plotOptions:{heatmap:{shadeIntensity:.5,radius:0,useFillColorAsStroke:!1,colorScale:{ranges:[{from:0,to:1,name:"0-1",color:"#FFB200"},{from:2,to:3,name:"2-3",color:"#00A100"},{from:4,to:5,name:"4-5",color:"#128FD9"},{from:6,to:100,name:"6+",color:"#FF0000"}]}}},dataLabels:{enabled:!0},stroke:{width:3},xaxis:{type:"category",categories:[e.toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-1)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-2)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-3)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-4)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-5)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-6)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-7)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-8)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-9)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-10)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-11)).toLocaleString("default",{month:"short"})]},title:{align:"center",text:"HeatMap of SC Engagements (Trailing 12 Months)"}};new ApexCharts(document.querySelector("#chart012"),a).render()}};"complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?callback():document.addEventListener("DOMContentLoaded",callback); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script><script>function getData(){var t=nlapiSearchRecord("customrecord_sc_request","customsearch_scm_eng_by_sc_12_mos");if(!t||0===t.length)return None;var e=[];for(var o=t.length,a=0,n=1;a<o;a++){for(var r=[],l=t[a].getAllColumns(),h=t[a].getText(l[0]);n<13;n++)r.push({x:n.toString(),y:t[a].getValue(l[n])});e.push({name:h,data:r}),n=1}return e}var callback=function(){var t=getData()||null;if(t&&null!==t){var e=new Date,o=e.getMonth(),a={series:t,chart:{height:420,type:"heatmap"},plotOptions:{heatmap:{shadeIntensity:.5,radius:0,useFillColorAsStroke:!1,colorScale:{ranges:[{from:0,to:1,name:"0-1",color:"#FFB200"},{from:2,to:3,name:"2-3",color:"#00A100"},{from:4,to:5,name:"4-5",color:"#128FD9"},{from:6,to:100,name:"6+",color:"#FF0000"}]}}},dataLabels:{enabled:!0},stroke:{width:3},xaxis:{type:"category",categories:[e.toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-1)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-2)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-3)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-4)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-5)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-6)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-7)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-8)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-9)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-10)).toLocaleString("default",{month:"short"}),new Date(e.setMonth(o-11)).toLocaleString("default",{month:"short"})]},title:{align:"center",text:"HeatMap of SC Engagements (Trailing 12 Months)"}};new ApexCharts(document.querySelector("#chart012"),a).render()}};"complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?callback():document.addEventListener("DOMContentLoaded",callback);</script><div style="height:450px"><div id="chart012"></div></div>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment