amcharts / amcharts5

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

How to lock (draggble drawingSeries)? #1677

Closed tranmanhhungdn1201 closed 2 months ago

tranmanhhungdn1201 commented 2 months ago
function lockDrawing() {
  drawingSeries.set("draggable", false);
  drawingSeries.set("interactive", false);
  drawingSeries._markDirtyKey('draggable');
  drawingSeries._markDirtyKey('interactive');
}

How to lock (draggble in drawingSeries)?

Thank you.

martynasma commented 2 months ago

Try this:

drawingSeries.set("forceInactive", true);
drawingSeries.strokes.template.set("forceInactive", true);
drawingSeries.fills.template.set("forceInactive", true);
drawingSeries.hitLines.template.set("forceInactive", true);
drawingSeries.bulletsContainer.set("forceInactive", true);
workingbuddy10 commented 2 months ago

@martynasma What If I want to lock any specific drawings? By pointing the drawing id. And beforehand only I know the id's of the drawing which I want to block. For example : Below is the data of an horizontal line, I want specifically want to lock this

{
                    "__tool": "Horizontal Line",
                    "__panelIndex": 0,
                    "__drawing": [
                        {
                            "stroke": {
                                "type": "Template",
                                "settings": {
                                    "stroke": {
                                        "type": "Color",
                                        "value": "#FFA500"
                                    },
                                    "strokeOpacity": 1,
                                    "strokeDasharray": [],
                                    "strokeWidth": 1
                                }
                            },
                            "fill": {
                                "type": "Template",
                                "settings": {
                                    "fill": {
                                        "type": "Color",
                                        "value": "#FFA500"
                                    },
                                    "fillOpacity": 0.5
                                }
                            },
                            "index": 1,
                            "showExtension": true,
                            "corner": "e",
                            "__parse": true
                        },
                        {
                            "valueY": 4998,
                            "valueX": 1599004800000,
                            "corner": "p1",
                            "index": 600,
                            "drawingId": "600",
                            "__parse": true
                        },
                        {
                            "valueY": 4998,
                            "valueX": 1724284800000,
                            "corner": "p2",
                            "index": 600,
                            "drawingId": "600",
                            "__parse": true
                        }
                    ]
                },
martynasma commented 2 months ago

I'm not aware of a way to lock specific drawing.

tranmanhhungdn1201 commented 2 months ago

image

Hi again,

I would like the red circle button to remain hidden by default. It should only become visible when the drawing is initiated by clicking on it. How can I achieve this using your code? Thank you

martynasma commented 2 months ago

Let's keep this place clutter-free, both for our own sake and the other's. If you have other questions, not directly related to original topic, please post a separate issue.