File size: 999 Bytes
19341ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8df1e9f
19341ef
 
 
 
 
 
 
 
 
 
 
 
8df1e9f
19341ef
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function sendValue(value) {
  Streamlit.setComponentValue(value)
}


function onRender(event) {
  if (true) {
    const {options,height} = event.detail.args
    Streamlit.setFrameHeight(height+20)
    document.getElementById("container").style.height=height+"px"
    let c = Highcharts.chart('container', options);

    let points = c.series[0].data.map((p) => 
      ({ x: Math.round(p.x),
         y: Math.round(p.y),
          color:p.color,
         name:p.name} ));
    sendValue(points);

    console.log(c.series[0].data);

    c.series[0].data.forEach((point, i) => {

      point.graphic.element.onclick = () => {

        let points = c.series[0].data.map((p) => 
         ({ x: Math.round(p.x),
            y: Math.round(p.y),
            color:p.color,
            name:p.name} ));

        console.log(points);
        sendValue(points);

      }
    })
    window.rendered = true
  }
}

Streamlit.events.addEventListener(Streamlit.RENDER_EVENT, onRender)
Streamlit.setComponentReady()