amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
356 stars 95 forks source link

Different types of display in DrawingControl buttons? #1133

Closed GustavoCunhaLacerda closed 1 year ago

GustavoCunhaLacerda commented 1 year ago

Is there any way to put another type of display in DrawingControl buttons? I want put this controls in flex but i looked the source code and the "block" option is hard coded.

image

// @amcharts/amcharts5/.internal/charts/stock/toolbar/DrawingControl.js
// Line 425
this.getPrivate("toolsContainer").style.display = "block";
martynasma commented 1 year ago

There's no way to do that via code.

However, you could probably still override it using CSS !important modifier.

GustavoCunhaLacerda commented 1 year ago

Ok, i solved the problem with:

drawingControl.events.on("click", () => {
      self.$data.isDrawActive = Boolean(drawingControl.get("active"));
});

This code in the control div class:

!isDrawActive ? 'hide-draw-controls' : 'show-draw-controls'

And finally css:

.hide-draw-controls .am5stock-control-drawing-tools {
  display: none !important;
}

.show-draw-controls .am5stock-control-drawing-tools {
  display: flex !important;
}

Looks like a trick and not the final solution. But if there is no other way this will be the final solution.

Have a chance to add a property to change the style of those intern divs in a future update? Can i open a PR if necessary?