// 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_906c`,
		Function: `function __templ_GenerateChart_906c(idDiv, udata){htmx.onLoad(function(elt) {
        console.log("elt ",elt)
        var element = document.getElementById(idDiv);
        console.log("element ",element)
        if (element) {
            element.style.height = "450px";
            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_906c`, idDiv, udata),
		CallInline: templ.SafeScriptInline(`__templ_GenerateChart_906c`, idDiv, udata),
	}
}

func ShowChartFixed(idDiv string, udata string, width string, height 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_Var3 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var3 == nil {
			templ_7745c5c3_Var3 = 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_Var4 string
		templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(idDiv)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\chart\chart.templ`, Line: 33, Col: 19}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
		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 = GenerateChartFixed(idDiv, udata, width, height).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 GenerateChartFixed(idDiv string, udata string, width string, height string) templ.ComponentScript {
	return templ.ComponentScript{
		Name: `__templ_GenerateChartFixed_c5bf`,
		Function: `function __templ_GenerateChartFixed_c5bf(idDiv, udata, width, height){htmx.onLoad(function(elt) {
        // console.log("elt ",elt)
        var element = document.getElementById(idDiv);
        // console.log("element ",element)
        if (element) {
            element.style.height = height;
            element.style.width = width;
        }

        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_GenerateChartFixed_c5bf`, idDiv, udata, width, height),
		CallInline: templ.SafeScriptInline(`__templ_GenerateChartFixed_c5bf`, idDiv, udata, width, height),
	}
}

func ShowChartResponsiveWidth(idDiv string, udata string, height 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_Var5 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var5 == nil {
			templ_7745c5c3_Var5 = 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_Var6 string
		templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(idDiv)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\chart\chart.templ`, Line: 62, Col: 19}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"mx-auto\" style=\"width: 100%;\"></div>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		templ_7745c5c3_Err = GenerateChartResponsive(idDiv, udata, height).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 GenerateChartResponsive(idDiv string, udata string, height string) templ.ComponentScript {
	return templ.ComponentScript{
		Name: `__templ_GenerateChartResponsive_fa78`,
		Function: `function __templ_GenerateChartResponsive_fa78(idDiv, udata, height){htmx.onLoad(function(elt) {
        // console.log("elt ",elt)
        var element = document.getElementById(idDiv);
        // console.log("element ",element)
        if (element) {
            element.style.height = height;
        }

        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);
        if (option[idDiv]['series']['radius']) {
            option[idDiv]['series']['radius'] = ['30%', '55%'];
        } else {
            option[idDiv]['series'][0]['radius'] = ['30%', '55%'];
        }
    
        myChart[idDiv].setOption(option[idDiv]);

        var resizeObserver = new ResizeObserver(function() {
            myChart[idDiv].resize();
        });

        resizeObserver.observe(element);
    });
}`,
		Call:       templ.SafeScript(`__templ_GenerateChartResponsive_fa78`, idDiv, udata, height),
		CallInline: templ.SafeScriptInline(`__templ_GenerateChartResponsive_fa78`, idDiv, udata, height),
	}
}
