Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added custom legend to heatmap chart #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified README.md
100644 → 100755
Empty file.
15 changes: 12 additions & 3 deletions dist/frappe-charts.esm.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,8 @@ class Heatmap extends BaseChart {
data = {},
discrete_domains = 0,
count_label = '',
legend_colors = []
legend_colors = [],
labels = null,
}) {
super(arguments[0]);

Expand All @@ -2618,6 +2619,7 @@ class Heatmap extends BaseChart {
this.data = data;
this.discrete_domains = discrete_domains;
this.count_label = count_label;
this.labels = labels;

let today = new Date();
this.start = start || addDays(today, 365);
Expand Down Expand Up @@ -2810,8 +2812,15 @@ class Heatmap extends BaseChart {
this.month_start_points.pop();

this.month_start_points.map((start, i) => {
let month_name = this.month_names[this.months[i]].substring(0, 3);
let text = makeText('y-value-text', start+12, 10, month_name);
let text;
if (this.labels) {
let label_name = this.labels[this.months[i]];
text = makeText('y-value-text', start+12, 10, label_name);
}
else {
let month_name = this.month_names[this.months[i]].substring(0, 3);
text = makeText('y-value-text', start+12, 10, month_name);
}
this.domain_label_group.appendChild(text);
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/frappe-charts.min.cjs.js
100644 → 100755

Large diffs are not rendered by default.

Empty file modified dist/frappe-charts.min.css
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion dist/frappe-charts.min.esm.js
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/frappe-charts.min.iife.js
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/js/frappe-charts.min.js
100644 → 100755

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/index.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ <h6 class="margin-vertical-rem">

discrete_domains: 1, // default: 0

// default: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
labels: ["Jan (8)", "Feb (2)", "Mar (5)", "Apr (1)", "May (8)", "Jun (8)", "Jul (7)", "Aug (0)", "Sep (7)", "Oct (1)", "Nov (2)", "December (9)" ],

start: start_date,
// A Date object;
// default: today's date in past year
Expand Down
15 changes: 12 additions & 3 deletions src/js/charts/Heatmap.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default class Heatmap extends BaseChart {
data = {},
discrete_domains = 0,
count_label = '',
legend_colors = []
legend_colors = [],
labels = null,
}) {
super(arguments[0]);

Expand All @@ -23,6 +24,7 @@ export default class Heatmap extends BaseChart {
this.data = data;
this.discrete_domains = discrete_domains;
this.count_label = count_label;
this.labels = labels;

let today = new Date();
this.start = start || addDays(today, 365);
Expand Down Expand Up @@ -215,8 +217,15 @@ export default class Heatmap extends BaseChart {
this.month_start_points.pop();

this.month_start_points.map((start, i) => {
let month_name = this.month_names[this.months[i]].substring(0, 3);
let text = makeText('y-value-text', start+12, 10, month_name);
let text;
if (this.labels) {
let label_name = this.labels[this.months[i]];
text = makeText('y-value-text', start+12, 10, label_name);
}
else {
let month_name = this.month_names[this.months[i]].substring(0, 3);
text = makeText('y-value-text', start+12, 10, month_name);
}
this.domain_label_group.appendChild(text);
});
}
Expand Down