Skip to content

Commit 3c16488

Browse files
authored
Support to Dark Themes
Export as JSON button wasn't changing color according to theme hence not matching with other export button colors
1 parent f4afff7 commit 3c16488

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/CanvasJS Data As JSON.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
if (chart.options.exportEnabled) {
1111
var exportJSON = document.createElement('div');
1212
var text = document.createTextNode("Save as JSON");
13-
exportJSON.setAttribute("style", "padding: 12px 8px; background-color: white; color: black")
13+
exportJSON.setAttribute("style", "padding: 12px 8px; background-color: " + chart.toolbar.backgroundColor + "; color: " + chart.toolbar.fontColor);
1414
exportJSON.appendChild(text);
1515
exportJSON.addEventListener("mouseover", function () {
16-
exportJSON.setAttribute("style", "padding: 12px 8px; background-color: #2196F3; color: white")
16+
exportJSON.setAttribute("style", "padding: 12px 8px; background-color: " + chart.toolbar.backgroundColorOnHover + "; color: " + chart.toolbar.fontColorOnHover);
1717
});
1818
exportJSON.addEventListener("mouseout", function () {
19-
exportJSON.setAttribute("style", "padding: 12px 8px; background-color: white; color: black")
19+
exportJSON.setAttribute("style", "padding: 12px 8px; background-color: " + chart.toolbar.backgroundColor + "; color: " + chart.toolbar.fontColor);
2020
});
2121
exportJSON.addEventListener("click", function () {
2222
parseJSON({
@@ -31,15 +31,15 @@
3131
var exportButton = document.createElement('button');
3232
var chartBound = chart.container.getBoundingClientRect();
3333

34-
exportButton.style.cssText = "position:relative;display: inline-block;padding: 0px 4px;width: 35px;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;width: 35px;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
var img = document.createElement("IMG");
3636
img.setAttribute("src", base64Img);
3737
exportButton.appendChild(img);
3838
exportButton.addEventListener("mouseover", function () {
39-
this.style.cssText = this.style.cssText + "background-color: rgb(33, 150, 243)";
39+
this.style.cssText = this.style.cssText + "background-color: " + chart.toolbar.backgroundColorOnHover;
4040
});
4141
exportButton.addEventListener("mouseout", function () {
42-
this.style.cssText = this.style.cssText + "background-color: #fff;";
42+
this.style.cssText = this.style.cssText + "background-color: " + chart.toolbar.backgroundColor;
4343
});
4444
exportButton.addEventListener("click", function () {
4545
parseJSON({

0 commit comments

Comments
 (0)