// Code generated by templ - DO NOT EDIT.

// templ: version: v0.2.663
package chart

//lint:file-ignore SA4006 This context is only used if a nested component is present.

import "github.com/a-h/templ"
import "context"
import "io"
import "bytes"

func ShowChart(idDiv string, udata string) templ.Component {
	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
		if !templ_7745c5c3_IsBuffer {
			templ_7745c5c3_Buffer = templ.GetBuffer()
			defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
		}
		ctx = templ.InitializeContext(ctx)
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var1 == nil {
			templ_7745c5c3_Var1 = templ.NopComponent
		}
		ctx = templ.ClearChildren(ctx)
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var2 string
		templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(idDiv)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\chart\chart.templ`, Line: 4, Col: 19}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"mx-auto\"></div>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		templ_7745c5c3_Err = GenerateChart(idDiv, udata).Render(ctx, templ_7745c5c3_Buffer)
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		if !templ_7745c5c3_IsBuffer {
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
		}
		return templ_7745c5c3_Err
	})
}

func GenerateChart(idDiv string, udata string) templ.ComponentScript {
	return templ.ComponentScript{
		Name: `__templ_GenerateChart_4c73`,
		Function: `function __templ_GenerateChart_4c73(idDiv, udata){htmx.onLoad(function(elt) {
        console.log("elt ",elt)
        var element = document.getElementById(idDiv);
        console.log("element ",element)
        if (element) {
            element.style.height = "400px";
            element.style.width = "100%";
        }

        var myChart = {}; 
        var option = {};

        // var myChart_001 = echarts.init(document.getElementById(idDiv));
        myChart[idDiv] = echarts.init(element);

        // var option_001 = JSON.parse(udata);
        option[idDiv] = JSON.parse(udata);
        console.log("option ", option)
        // myChart_001.setOption(option_001);
        myChart[idDiv].setOption(option[idDiv]);
    });
}`,
		Call:       templ.SafeScript(`__templ_GenerateChart_4c73`, idDiv, udata),
		CallInline: templ.SafeScriptInline(`__templ_GenerateChart_4c73`, idDiv, udata),
	}
}
