// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.924 // templui component chart - version: v0.84.0 installed by templui v0.84.0 package chart //lint:file-ignore SA4006 This context is only used if a nested component is present. import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import "git.jmbit.de/jmb/scanfile/server/web/templui/utils" type Variant string const ( VariantBar Variant = "bar" VariantLine Variant = "line" VariantPie Variant = "pie" VariantDoughnut Variant = "doughnut" VariantRadar Variant = "radar" ) type Dataset struct { Label string `json:"label"` Data []float64 `json:"data"` BorderWidth int `json:"borderWidth,omitempty"` BorderColor interface{} `json:"borderColor,omitempty"` BackgroundColor interface{} `json:"backgroundColor,omitempty"` Tension float64 `json:"tension,omitempty"` Fill bool `json:"fill,omitempty"` Stepped bool `json:"stepped,omitempty"` } type Options struct { Responsive bool `json:"responsive,omitempty"` Legend bool `json:"legend,omitempty"` } type Data struct { Labels []string `json:"labels"` Datasets []Dataset `json:"datasets"` } type Config struct { Type Variant `json:"type"` Data Data `json:"data"` Options Options `json:"options,omitempty"` ShowLegend bool `json:"showLegend,omitempty"` ShowXAxis bool `json:"showXAxis"` ShowYAxis bool `json:"showYAxis"` ShowXLabels bool `json:"showXLabels"` ShowYLabels bool `json:"showYLabels"` ShowXGrid bool `json:"showXGrid"` ShowYGrid bool `json:"showYGrid"` Horizontal bool `json:"horizontal"` Stacked bool `json:"stacked"` } type Props struct { ID string Variant Variant Data Data Options Options ShowLegend bool ShowXAxis bool ShowYAxis bool ShowXLabels bool ShowYLabels bool ShowXGrid bool ShowYGrid bool Horizontal bool Stacked bool Class string Attributes templ.Attributes } func Chart(props ...Props) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var1 := templ.GetChildren(ctx) if templ_7745c5c3_Var1 == nil { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) var p Props if len(props) > 0 { p = props[0] } if p.ID == "" { p.ID = "chart-" + utils.RandomID() } canvasId := p.ID + "-canvas" dataId := p.ID + "-data" var templ_7745c5c3_Var2 = []any{utils.TwMerge( "chart-container relative", p.Class), } templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } chartConfig := Config{ Type: p.Variant, Data: p.Data, Options: p.Options, ShowLegend: p.ShowLegend, ShowXAxis: p.ShowXAxis, ShowYAxis: p.ShowYAxis, ShowXLabels: p.ShowXLabels, ShowYLabels: p.ShowYLabels, ShowXGrid: p.ShowXGrid, ShowYGrid: p.ShowYGrid, Horizontal: p.Horizontal, Stacked: p.Stacked, } templ_7745c5c3_Err = templ.JSONScript(dataId, chartConfig).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } func Script() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var7 := templ.GetChildren(ctx) if templ_7745c5c3_Var7 == nil { templ_7745c5c3_Var7 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate