refactor: working heatmap
This commit is contained in:
parent
bd3dc6482e
commit
16db6c2f47
@ -2,27 +2,58 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Bisect Accounting Statements", {
|
frappe.ui.form.on("Bisect Accounting Statements", {
|
||||||
|
onload(frm) {
|
||||||
|
frm.trigger("render_heatmap");
|
||||||
|
},
|
||||||
refresh(frm) {
|
refresh(frm) {
|
||||||
frm.add_custom_button(__('Bisect Left'), () =>
|
frm.add_custom_button(__('Bisect Left'), () => {
|
||||||
frm.trigger("bisect_left")
|
frm.trigger("bisect_left");
|
||||||
);
|
});
|
||||||
|
|
||||||
frm.add_custom_button(__('Bisect Right'), () =>
|
frm.add_custom_button(__('Bisect Right'), () => {
|
||||||
frm.trigger("bisect_right")
|
frm.trigger("bisect_right");
|
||||||
);
|
});
|
||||||
|
|
||||||
frm.add_custom_button(__('Up'), () =>
|
frm.add_custom_button(__('Up'), () => {
|
||||||
frm.trigger("move_up")
|
frm.trigger("move_up");
|
||||||
);
|
});
|
||||||
frm.add_custom_button(__('Build Tree'), () =>
|
frm.add_custom_button(__('Build Tree'), () => {
|
||||||
frm.trigger("build_tree")
|
frm.trigger("build_tree");
|
||||||
);
|
});
|
||||||
|
},
|
||||||
|
render_heatmap(frm) {
|
||||||
|
let bisect_heatmap = frm.get_field("bisect_heatmap").$wrapper;
|
||||||
|
bisect_heatmap.addClass("bisect_heatmap_location");
|
||||||
|
|
||||||
|
// milliseconds in a day
|
||||||
|
let msiad=24*60*60*1000;
|
||||||
|
let datapoints = {};
|
||||||
|
let fr_dt = new Date(frm.doc.current_from_date).getTime();
|
||||||
|
let to_dt = new Date(frm.doc.current_to_date).getTime();
|
||||||
|
for(let x=fr_dt; x <= to_dt; x+=msiad){
|
||||||
|
let epoch_in_seconds = x/1000;
|
||||||
|
datapoints[epoch_in_seconds] = 1;
|
||||||
|
}
|
||||||
|
console.log(datapoints);
|
||||||
|
|
||||||
|
new frappe.Chart(".bisect_heatmap_location", {
|
||||||
|
type: "heatmap",
|
||||||
|
title: "Bisecting On",
|
||||||
|
data: {
|
||||||
|
dataPoints: datapoints,
|
||||||
|
start: new Date(frm.doc.from_date),
|
||||||
|
end: new Date(frm.doc.to_date),
|
||||||
|
},
|
||||||
|
countLabel: 'Difference',
|
||||||
|
discreteDomains: 1
|
||||||
|
});
|
||||||
},
|
},
|
||||||
bisect_left(frm) {
|
bisect_left(frm) {
|
||||||
frm.call({
|
frm.call({
|
||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
method: 'bisect_left',
|
method: 'bisect_left',
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
|
frm.trigger("render_heatmap");
|
||||||
console.log(r);
|
console.log(r);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -32,6 +63,7 @@ frappe.ui.form.on("Bisect Accounting Statements", {
|
|||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
method: 'bisect_right',
|
method: 'bisect_right',
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
|
frm.trigger("render_heatmap");
|
||||||
console.log(r);
|
console.log(r);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -41,6 +73,7 @@ frappe.ui.form.on("Bisect Accounting Statements", {
|
|||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
method: 'move_up',
|
method: 'move_up',
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
|
frm.trigger("render_heatmap");
|
||||||
console.log(r);
|
console.log(r);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -50,6 +83,7 @@ frappe.ui.form.on("Bisect Accounting Statements", {
|
|||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
method: 'build_tree',
|
method: 'build_tree',
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
|
frm.trigger("render_heatmap");
|
||||||
console.log(r);
|
console.log(r);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,13 +14,14 @@
|
|||||||
"to_date",
|
"to_date",
|
||||||
"column_break_iwny",
|
"column_break_iwny",
|
||||||
"algorithm",
|
"algorithm",
|
||||||
"section_break_zbty",
|
"section_break_8ph9",
|
||||||
"current_node",
|
"current_node",
|
||||||
"sandbox",
|
|
||||||
"section_break_hmsy",
|
"section_break_hmsy",
|
||||||
"current_from_date",
|
"current_from_date",
|
||||||
"column_break_uqyd",
|
"column_break_uqyd",
|
||||||
"current_to_date",
|
"current_to_date",
|
||||||
|
"section_break_ngid",
|
||||||
|
"bisect_heatmap",
|
||||||
"section_break_hbyo",
|
"section_break_hbyo",
|
||||||
"p_l_summary",
|
"p_l_summary",
|
||||||
"column_break_aivo",
|
"column_break_aivo",
|
||||||
@ -54,10 +55,6 @@
|
|||||||
"fieldname": "column_break_iwny",
|
"fieldname": "column_break_iwny",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "section_break_zbty",
|
|
||||||
"fieldtype": "Section Break"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "current_node",
|
"fieldname": "current_node",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -65,12 +62,6 @@
|
|||||||
"label": "Current Node",
|
"label": "Current Node",
|
||||||
"options": "Nodes"
|
"options": "Nodes"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "sandbox",
|
|
||||||
"fieldtype": "HTML",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "sandbox"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "section_break_hmsy",
|
"fieldname": "section_break_hmsy",
|
||||||
"fieldtype": "Section Break"
|
"fieldtype": "Section Break"
|
||||||
@ -125,13 +116,26 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_hcam",
|
"fieldname": "column_break_hcam",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_ngid",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_8ph9",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bisect_heatmap",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"label": "Heatmap"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"hide_toolbar": 1,
|
"hide_toolbar": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-09-26 21:25:48.779453",
|
"modified": "2023-09-27 12:10:40.044935",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Bisect Accounting Statements",
|
"name": "Bisect Accounting Statements",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user