def create_scatter_chart()

in visualize/generate.py [0:0]


def create_scatter_chart(Type:str,datas: List):
    
    scatter = Scatter()
    if Type == "commtype":
        index = 0
        index_y = 2
        _title="Commtype_Scatter"
    elif Type == "group" :
        index = 2
        index_y = 0
        _title="Commgroup_Scatter"
    x_data = list(dict.fromkeys([item[index] for item in datas])) 
    scatter.add_xaxis(x_data)

    # colors = {group: generate_color() for group in groups}

    # Add y data to scatter with its size and color (commtype, size, group, busbw, count)    
    for data in datas:
        y = [None] * len(x_data)
        sizes = [None] * len(x_data)
        
        if data[index] in x_data:
            y[x_data.index(data[index])] = math.log(data[1], 2)
            sizes[x_data.index(data[index])] = data[1]
            scatter.add_yaxis(
                series_name=data[index_y],
                y_axis=y,
                symbol_size=30,  
                label_opts=opts.LabelOpts(is_show=False),
                itemstyle_opts=opts.ItemStyleOpts(color=colors_group[data[index_y]]),  # set group color
                tooltip_opts=opts.TooltipOpts(
                    formatter=f"msg_size: {data[1]}<br>busbw: {data[3]}<br>count: {data[4]}"  
                )
            )

    # Set global options    
    max_y_value =math.ceil((max(math.log(data[1], 2) for data in datas)))
    min_y_value = min(math.log(data[1], 2) for data in datas)
    scatter.set_global_opts(
        title_opts=opts.TitleOpts(title=_title),
        xaxis_opts=opts.AxisOpts(
            name="Comm_type", 
            type_="category",
            name_location="middle",
            name_gap=30, 
            name_textstyle_opts=opts.TextStyleOpts(
                font_size="15px",  
                font_weight='bold'  
            )),  
        yaxis_opts=opts.AxisOpts(
            name="log(msg_size)", 
            min_=0, 
            max_=max_y_value,
            name_location="middle",
            name_gap=30, 
            name_textstyle_opts=opts.TextStyleOpts(
                font_size="15px",  
                font_weight='bold'  
            )),  
        legend_opts=opts.LegendOpts(
            type_="scroll",
            pos_left="right",
            orient="vertical",
        ),

    )

    return scatter