Drayton
Posts: 3
Joined: Sat Mar 13, 2021 9:30 am

Flags question in HighStock?

I have two questions about flags.
First is in this example: https://stackblitz.com/edit/highcharts- ... mponent.ts
When I click on the flag button in the stockTools gui then set flag in the diagram and enter the title/name of the flag. How can I get these values (flag title, name) later?
I think something like this :

Code: Select all

flags[0].getTitle()
.

Second question is that how can I set flags with click event without stockTools gui? Example I choose value with select option in html and set flag with click event which title is option value.

Code: Select all

    series: [
      {
        type: "line",
        data: [1, 2, 3, 4, 5],
        point: {
          events: {
            click: (function(component) {
              return function() {
                let point = this;
                let x = point.x;
                let y = point.y;
                if (component.option == "a") {
                  // if I choose 'a' option I would like to set flag with 'a' title on diagram
                } else if (component.option == "b") {
                  // if I choose 'b' option I would like to set flag with 'b' title on diagram
                }
              };
            })(this)
          }
        }
      }
    ]
So my example: https://stackblitz.com/edit/highcharts- ... mponent.ts
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Flags question in HighStock?

Hi!
Thanks for contacting us with your question.

Flags are added as new series type flags, I suppose the GUI works the same, try to find this series in.
I recommend using redrawing events that work after each change of the chart.

Demo:
https://stackblitz.com/edit/highcharts- ... mponent.ts

Look at this article and an example of how flags works, should be useful.
https://www.highcharts.com/docs/stock/flag-series
https://jsfiddle.net/gh/get/library/pur ... s-general/

Documentation:
https://api.highcharts.com/highstock/plotOptions.flags

Let me know how are you going with this.
Best regards.
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Stock”