FlexChart set line marker position based on data item

Posted by: metrik on 9 October 2019, 7:23 am EST

    • Post Options:
    • Link

    Posted 9 October 2019, 7:23 am EST

    Hello,

     in my chart I am having a LineMarker. I want to set its position based on the data item displayed in chart. I know that specific data item is present in chart and I even know it's index. But I don't see how to set LineMarker to the position of this data item in chart.
    

    Is there any way to achieve this?

    Thank you!

  • Posted 10 October 2019, 8:38 am EST

    Hi,

    We are working on your case and will update you as soon as possible.

  • Posted 11 October 2019, 2:41 am EST

    Hi Ashwin,

    actually I have already found a way to do this.

    Assuming that you have a class with a chart and reference to vertical line marker:

    
    selectItemByIndex(index: number) {
            if (this.data && index < this.data.length && index >= 0) {
                const selectedItem = this.data[index];
                const x = this.chart.axisX.convert(selectedItem.date.valueOf());
                const percent = (x - this.chart._plotRect.left) / this.chart._plotRect.width;
                this.positionMarker.horizontalPosition = percent > 1 ? 1 : percent;
            }
        }
    
    

    Hope might be helpful for others.

  • Posted 11 October 2019, 5:39 am EST

    Hi Kirill,

    Thank you for the update. We are glad that you were able to resolve the issue.

    Let us know in case if you have any additional queries.

    ~regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels