Closed workingbuddy10 closed 2 months ago
You can just set "tool"
setting on the drawing tool instance:
selectedDrawingControl.set("tool", "Horizontal Line");
Did same in the codepen @martynasma It didn't wokred : https://codepen.io/Ansh-m-the-reactor/pen/JjQyrqB
It does work. It switches the tool, but it does not enable drawing mode. If you need it enabled, you need to do enable by setting active: true
on drawing control:
drawingControl.setAll({
active: true,
tool: "Horizontal Line"
});
Related docs: https://www.amcharts.com/docs/v5/charts/stock/toolbar/drawing-control/#Enabling_draw_mode
@martynasma As you can see in the below video :
https://github.com/user-attachments/assets/b72a01f7-eb60-4be3-8247-a96f0afd8cce
https://github.com/user-attachments/assets/c3985da2-b868-4bc2-a2ac-7a7f0f630731
@martynasma
And the second issue :
button.get("background").setAll({
forceHidden: true
});
codepen link : https://codepen.io/Ansh-m-the-reactor/pen/JjQyrqB?editors=0010
Hey @martynasma ,Sorry for tagging! Any lead on this would be very helpful!!
So will be able to draw the line via clicking on the button? As explained here https://github.com/amcharts/amcharts5/issues/1673#issuecomment-2293182147
If yes, then how it will look like?
I'll let you know the details, when the new version is out later this week.
Implemented in 5.10.2.
panSensitivity
added to AxisRenderer
(default: 1
).maxPanOut
added to ZoomableContainer
(default: 0.4
).addLine(tool, panel, point)
added DrawingControl
. Allows adding line drawings via API. Supports ("Line"
, "Horizontal Line"
, "Horizontal Ray"
, "Vertical Line"
tools). More info.minBulletDistance
of a XYSeries
was ignored when base axis was CategoryAxis
and other axis was DateAxis
.Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.
Refer to this tutorial for info and example: https://www.amcharts.com/docs/v5/charts/stock/toolbar/drawing-control/#Adding_line_drawings
@martynasma a minor enhancement : as you know we can create a horizontal line by clicking on the plus button.
In Trading Technology charts, one can draw the same line by double clicking on the valueAxis. So it will be drawn at that price point. Can we have this, any function?
You can add a dblclick
event on an axis, and use addLine()
in the event handler.
Sorry, I should have framed the question in a better way. Yes, I can draw the line on ddclick on valueAxis. I want to show the label at which price the line is marked. Like this :
And if I click on the eraser button of drawings, both the line and its respective label should get delete. If I click on the delete all, the all the drawings with respect to its label should get removed.
In that case you should probably add an axis range rather than horizontal line drawing.
Currently on the button click I want to initiate the 'Horizontal Line' .
I tried looking in the codebase there is a protected function _setTool which does the job : https://github.com/amcharts/amcharts5/blob/1e2243d7153ef537807abeced990b66dbc01fce3/src/.internal/charts/stock/toolbar/DrawingControl.ts#L838
I tried doing this in my codebase but it is taking 2 steps and it didn't worked :
To be more precise my code snippet looks like this :
I want if I click on my button (BT) the horizontal line draws. codepen : https://codepen.io/Ansh-m-the-reactor/pen/JjQyrqB