Skip to content

Commit 86a616c

Browse files
authored
Supports Dark Themes
Export as CSV button wasn't changing color according to theme hence not matching with other export button colors
1 parent 175fde8 commit 86a616c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/CanvasJS As CSV.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
(function () {
1+
(function () {
22
var CanvasJS = window.CanvasJS || CanvasJS ? window.CanvasJS : null;
33
if (CanvasJS) {
4-
CanvasJS.Chart.prototype.exportAsCSV = function (fileName) {
4+
CanvasJS.Chart.prototype.exportAsCSV = function (fileName) {
55
CanvasJSDataAsCSV(this, fileName);
66
}
77
}
@@ -11,13 +11,13 @@
1111
var exportCSV = document.createElement('div');
1212
var text = document.createTextNode("Save as CSV");
1313
console.log(chart)
14-
exportCSV.setAttribute("style", "padding: 12px 8px; background-color: white; color: black")
14+
exportCSV.setAttribute("style", "padding: 12px 8px; background-color: " + chart.toolbar.backgroundColor + "; color: " + chart.toolbar.fontColor);
1515
exportCSV.appendChild(text);
1616
exportCSV.addEventListener("mouseover", function () {
17-
exportCSV.setAttribute("style", "padding: 12px 8px; background-color: #2196F3; color: white")
17+
exportCSV.setAttribute("style", "padding: 12px 8px; background-color: " + chart.toolbar.backgroundColorOnHover + "; color: " + chart.toolbar.fontColorOnHover);
1818
});
1919
exportCSV.addEventListener("mouseout", function () {
20-
exportCSV.setAttribute("style", "padding: 12px 8px; background-color: white; color: black")
20+
exportCSV.setAttribute("style", "padding: 12px 8px; background-color: " + chart.toolbar.backgroundColor + "; color: " + chart.toolbar.fontColor);
2121
});
2222
exportCSV.addEventListener("click", function () {
2323
parseCSV({
@@ -31,16 +31,16 @@
3131
var base64Img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEgSURBVEhL3dM/SgNBFMfxBS8gWkYb0dJSyBGCwdIzRPAKgrZKINdIkVJB0qqteIdYCYoHEPX74P1gMszuzG5SiD/4wM6/99jJpvq3GeIVPwUu0ToLpIrVad1EB3Pp3KRLA1PcRAdyCYtLURNtziUsHMqmeGOUxnNtPs2cZNp+mk2S0eIteu7O5y5wgFN8Yw8vePZnnZVktLiDJzxi1+cOfe4GHxhhgjHOoLOSTLgYbjZz7OPaxzOc4Nif4/3JaNHe4MHpDc7xiW284R1b2IS9ka61MWpg925NrPi9z9mfx65pgC+fO0Lfn21/Nqt8RUo8XordZ9cmSjyuTfHGKH+nQe6qptiA5QqpPcbWkin5PXJNaot3Tdhk7cUVKxwUr6pfwprgQh4A9MYAAAAASUVORK5CYII=";
3232
var exportButton = document.createElement('button');
3333

34-
exportButton.style.cssText = "position:relative;display: inline-block;padding: 0px 4px;height: 27px;cursor: pointer;text-align: center;text-decoration: none;background-color: #fff;border: 1px solid rgb(33, 150, 243);left:" + (chart.container.clientWidth - (chart.options.zoomEnabled ? 115 : 60)) + "px; top: 1px";
34+
exportButton.style.cssText = "position:relative;display: inline-block;padding: 0px 4px;height: 27px;cursor: pointer;text-align: center;text-decoration: none;background-color:" + chart.toolbar.backgroundColor + ";border: 1px solid " + chart.toolbar.borderColor + ";left:" + (chart.container.clientWidth - (chart.options.zoomEnabled ? 115 : 60)) + "px; top: 1px";
3535

3636
var img = document.createElement("IMG");
3737
img.setAttribute("src", base64Img);
3838
exportButton.appendChild(img);
3939
exportButton.addEventListener("mouseover", function () {
40-
this.style.cssText = this.style.cssText + "background-color: rgb(33, 150, 243)";
40+
this.style.cssText = this.style.cssText + "background-color: " + chart.toolbar.backgroundColorOnHover;
4141
});
4242
exportButton.addEventListener("mouseout", function () {
43-
this.style.cssText = this.style.cssText + "background-color: #fff;";
43+
this.style.cssText = this.style.cssText + "background-color: " + chart.toolbar.backgroundColor;
4444
});
4545
exportButton.addEventListener("click", function () {
4646
parseCSV({

0 commit comments

Comments
 (0)