Multiple marker from json file

37 Views Asked by At

I'm new in coding world, I have done to add a marker to chart, but not for multiple marker.

I try to add multiple marker from json data like this, but I'm no luck. there's someone can help.

this json file

{
    "tandaa": [
        {
            "time": "11 January 2024",
            "position": "below",
            "color": "green",
            "shape": "arrowUp",
            "text": "UP",

        },
        {
            "time": "12 December 2023",
            "position": "below",
            "color": "red",
            "shape": "arrowDown",
            "text": "Down",
         },
        {
            "time": "12 November 2023",
            "position": "above",
            "color": "red",
            "shape": "arrowDown",
            "text": "UP",
        }
    ]
}

this is code

import json
from lightweight_charts.widgets import StreamlitChart
import pandas as pd


with open('C:\\Users\\trade\\latihan\\.venv\\data.json') as f:
    data = json.load(f)
 
print(data)

if __name__ == '__main__':
    chart = StreamlitChart(width=900, height=600)
    index = "C:/Users/trade/latihan/.venv/TVC_BXY.csv"
    df = pd.read_csv(index)
    chart.watermark(text=index, font_size=33, color='white')

    chart.set(df)
    for mark in data['tandaa']:
        chart.marker(mark['time'], mark['position'], mark['color'], mark['shape'], mark['text'])
    
    chart.load() ```
0

There are 0 best solutions below