### Run Demo Examples Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/QUICKSTART.md Executes the provided demo application from the examples directory. ```bash cd examples go run main.go ``` -------------------------------- ### Install FyneSimpleChart and Fyne Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/01-getting-started.md Install the FyneSimpleChart library and the Fyne toolkit using go get. ```bash go get github.com/alexiusacademia/fynesimplechart go get fyne.io/fyne/v2 ``` -------------------------------- ### Practical Example: Temperature Comparison Chart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/05-multiple-series.md This example demonstrates creating a chart to compare indoor and outdoor temperatures over a 24-hour period, showing two distinct series with custom line widths. ```go package main import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Temperature Comparison") w.Resize(fyne.NewSize(900, 650)) // Indoor temperature indoor := []fynesimplechart.Node{ *fynesimplechart.NewNode(0, 22), *fynesimplechart.NewNode(4, 21), *fynesimplechart.NewNode(8, 22), *fynesimplechart.NewNode(12, 24), *fynesimplechart.NewNode(16, 25), *fynesimplechart.NewNode(20, 23), *fynesimplechart.NewNode(24, 22), } indoorPlot := fynesimplechart.NewPlot(indoor, "Indoor (°C)") indoorPlot.ShowLine = true indoorPlot.LineWidth = 2.5 // Outdoor temperature outdoor := []fynesimplechart.Node{ *fynesimplechart.NewNode(0, 15), *fynesimplechart.NewNode(4, 12), *fynesimplechart.NewNode(8, 16), *fynesimplechart.NewNode(12, 22), *fynesimplechart.NewNode(16, 25), *fynesimplechart.NewNode(20, 20), *fynesimplechart.NewNode(24, 16), } outdoorPlot := fynesimplechart.NewPlot(outdoor, "Outdoor (°C)") outdoorPlot.ShowLine = true outdoorPlot.LineWidth = 2.5 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{ *indoorPlot, *outdoorPlot, }) chart.SetChartTitle("24-Hour Temperature Monitoring") w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Run Demo Application Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/15-enhanced-features.md Execute the tutorial example from the command line. ```bash cd examples go run tutorial15_example.go ``` -------------------------------- ### Install Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/01-getting-started.md Verify your Go installation by checking the version. Requires Go 1.22.0 or later. ```bash go version ``` -------------------------------- ### Use Configuration Structs for Chart Setup Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/12-best-practices.md Organize chart configuration parameters into structs for cleaner and more manageable setup. This promotes modularity. ```go type ChartConfig struct { Title string ShowGrid bool WindowSize fyne.Size } func createChart(plots []fynesimplechart.Plot, config ChartConfig) *fynesimplechart.ScatterPlot { chart := fynesimplechart.NewGraphWidget(plots) chart.SetChartTitle(config.Title) chart.ShowGrid = config.ShowGrid chart.Resize(config.WindowSize) return chart } ``` -------------------------------- ### Practical Example: Temperature Monitor Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/11-realtime-data.md A practical example demonstrating a real-time temperature monitor. It simulates temperature readings using a sine wave with noise and updates the chart every 500 milliseconds, keeping the last 30 readings. Requires `time`, `math`, `fyne.io/fyne/v2`, and `github.com/alexiusacademia/fynesimplechart`. ```go package main import ( "time" "math" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Temperature Monitor") w.Resize(fyne.NewSize(900, 650)) nodes := []fynesimplechart.Node{} plot := fynesimplechart.NewPlot(nodes, "Temperature (°C)") plot.ShowLine = true plot.ShowPoints = true plot.LineWidth = 2 plot.PointSize = 3 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.SetChartTitle("Live Temperature Monitoring") // Simulate temperature sensor go func() { t := 0.0 for { // Simulate temperature with sine wave + noise baseTemp := 22.0 + math.Sin(t/10.0)*3 noise := (math.Sin(t*7) + math.Sin(t*13)) * 0.5 temp := float32(baseTemp + noise) nodes = append(nodes, *fynesimplechart.NewNode( float32(len(nodes)), temp, )) // Keep last 30 readings if len(nodes) > 30 { nodes = nodes[1:] for i := range nodes { nodes[i].X = float32(i) } } plot.Nodes = nodes chart.Refresh() t += 0.5 time.Sleep(500 * time.Millisecond) } }() w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Professional Dashboard Example Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/15-enhanced-features.md A complete example demonstrating a professional dashboard with sales comparison for two quarters. It includes features like custom bar colors, data labels, legend positioning, and fixed axis ranges for consistent comparison. ```go package main import ( "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Professional Dashboard") // Create sales data for two quarters q1Sales := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 45), *fynesimplechart.NewNode(2, 52), *fynesimplechart.NewNode(3, 48), *fynesimplechart.NewNode(4, 61), } q2Sales := []fynesimplechart.Node{ *fynesimplechart.NewNode(1.3, 48), *fynesimplechart.NewNode(2.3, 55), *fynesimplechart.NewNode(3.3, 51), *fynesimplechart.NewNode(4.3, 64), } // Q1 Plot with all features q1 := fynesimplechart.NewPlot(q1Sales, "Q1 2024") q1.ShowBars = true q1.BarWidth = 0.25 q1.ShowDataLabels = true q1.LabelFormat = "$%.0fK" q1.LabelSize = 9 q1.PlotColor = color.RGBA{R: 31, G: 119, B: 180, A: 255} // Q2 Plot with all features q2 := fynesimplechart.NewPlot(q2Sales, "Q2 2024") q2.ShowBars = true q2.BarWidth = 0.25 q2.ShowDataLabels = true q2.LabelFormat = "$%.0fK" q2.LabelSize = 9 q2.PlotColor = color.RGBA{R: 255, G: 127, B: 14, A: 255} // Create chart with all enhancements chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*q1, *q2}) // 1. Chart title chart.SetChartTitle("Quarterly Sales Comparison") // 2. Axis titles chart.XAxisTitle = "Region" chart.YAxisTitle = "Sales ($K)" // 3. Legend positioning chart.LegendPosition = fynesimplechart.LegendTop // 4. Manual axis ranges for consistency minY := float32(0) maxY := float32(80) chart.MinY = &minY chart.MaxY = &maxY chart.Resize(fyne.NewSize(800, 600)) w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Data Label Format String Examples Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/15-enhanced-features.md Provides examples of various format strings for data labels, including decimals, currency, percentages, scientific notation, and custom formats. ```go // Decimals plot.LabelFormat = "%.1f" // "12.5" plot.LabelFormat = "%.2f" // "12.50" plot.LabelFormat = "%.0f" // "13" // Currency plot.LabelFormat = "$%.2f" // "$12.50" plot.LabelFormat = "$%.0fK" // "$13K" plot.LabelFormat = "€%.2f" // "€12.50" // Percentage plot.LabelFormat = "%.0f%%" // "13%" plot.LabelFormat = "%.1f%%" // "12.5%" // Scientific plot.LabelFormat = "%.2e" // "1.25e+01" // Custom plot.LabelFormat = "%.1f°C" // "12.5°C" plot.LabelFormat = "%.0f units" // "13 units" ``` -------------------------------- ### Full Revenue Growth Chart Example Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/03-line-charts.md A complete implementation showing how to initialize an application and render a chart. ```go package main import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Revenue Growth") w.Resize(fyne.NewSize(700, 500)) revenue := []float32{45000, 52000, 48000, 61000, 58000, 67000} nodes := []fynesimplechart.Node{} for quarter, amount := range revenue { nodes = append(nodes, *fynesimplechart.NewNode( float32(quarter+1), amount, )) } plot := fynesimplechart.NewPlot(nodes, "Revenue ($)") plot.ShowLine = true plot.ShowPoints = true plot.LineWidth = 2.5 plot.PointSize = 4 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.SetChartTitle("Quarterly Revenue Growth") w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Complete Chart Styling Example in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md This example demonstrates a fully styled chart, including setting a custom plot color, enabling lines and points, adjusting line width and point size, and setting a chart title with grid visibility. ```go package main import ( "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Styled Chart") w.Resize(fyne.NewSize(800, 600)) nodes := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 3), *fynesimplechart.NewNode(2, 5), *fynesimplechart.NewNode(3, 4), *fynesimplechart.NewNode(4, 7), *fynesimplechart.NewNode(5, 6), } plot := fynesimplechart.NewPlot(nodes, "Revenue") // Complete styling plot.PlotColor = color.RGBA{R: 31, G: 119, B: 180, A: 255} // Blue plot.ShowLine = true plot.ShowPoints = true plot.LineWidth = 2.5 plot.PointSize = 5 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.SetChartTitle("Q1 2024 Revenue Analysis") chart.ShowGrid = true w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Install FyneSimpleChart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/QUICKSTART.md Use this command to fetch the library dependency for your Go project. ```bash go get github.com/alexiusacademia/fynesimplechart ``` -------------------------------- ### Implement Financial Dashboard Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md A full example showing how to create a window with multiple plots for a financial dashboard. ```go package main import ( "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Financial Dashboard") w.Resize(fyne.NewSize(900, 650)) // Revenue data revenue := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 45), *fynesimplechart.NewNode(2, 52), *fynesimplechart.NewNode(3, 48), *fynesimplechart.NewNode(4, 61), } revPlot := fynesimplechart.NewPlot(revenue, "Revenue ($K)") revPlot.PlotColor = color.RGBA{R: 76, G: 175, B: 80, A: 255} // Green (positive) revPlot.ShowLine = true revPlot.ShowPoints = true revPlot.LineWidth = 3 revPlot.PointSize = 5 // Expenses data expenses := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 32), *fynesimplechart.NewNode(2, 35), *fynesimplechart.NewNode(3, 33), *fynesimplechart.NewNode(4, 38), } expPlot := fynesimplechart.NewPlot(expenses, "Expenses ($K)") expPlot.PlotColor = color.RGBA{R: 244, G: 67, B: 54, A: 255} // Red (negative) expPlot.ShowLine = true expPlot.ShowPoints = true expPlot.LineWidth = 3 expPlot.PointSize = 5 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*revPlot, *expPlot}) chart.SetChartTitle("Q1 2024 Financial Overview") chart.ShowGrid = true w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Department Budget Chart Pattern Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/14-bar-charts.md Example implementation of a standard department budget visualization. ```go departments := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 120), // Marketing *fynesimplechart.NewNode(2, 95), // Sales *fynesimplechart.NewNode(3, 150), // Engineering *fynesimplechart.NewNode(4, 80), // HR *fynesimplechart.NewNode(5, 65), // Operations } plot := fynesimplechart.NewPlot(departments, "Budget ($K)") plot.ShowBars = true plot.BarWidth = 0.7 plot.PlotColor = color.RGBA{R: 44, G: 160, B: 44, A: 255} plot.BarBorderWidth = 2 plot.ShowPoints = false plot.ShowLine = false ``` -------------------------------- ### Corporate Color Theme Example in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md This example demonstrates creating a corporate color theme by assigning specific company colors (Blue and Gold) to different plots. It uses `color.RGBA` to define the custom colors. ```go // Company colors: Blue and Gold corporateBlue := color.RGBA{R: 0, G: 71, B: 171, A: 255} corporateGold := color.RGBA{R: 255, G: 184, B: 28, A: 255} plot1 := fynesimplechart.NewPlot(data1, "Division A") plot1.PlotColor = corporateBlue plot2 := fynesimplechart.NewPlot(data2, "Division B") plot2.PlotColor = corporateGold ``` -------------------------------- ### Create a Simple Scatter Plot Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/readme.md This example demonstrates how to create a basic scatter plot with custom data points and display it in a Fyne window. ```go package main import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("My First Chart") // Create data points nodes := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 2), *fynesimplechart.NewNode(2, 4), *fynesimplechart.NewNode(3, 3), *fynesimplechart.NewNode(4, 5), } // Create plot plot := fynesimplechart.NewPlot(nodes, "My Data") // Create chart chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.Resize(fyne.NewSize(600, 400)) w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Create Chart Widget Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/01-getting-started.md Instantiate the GraphWidget, which can display one or more plots. This example shows a single plot. ```go chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) ``` -------------------------------- ### Track Progress Data Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/03-line-charts.md Example of plotting incremental progress metrics. ```go // Example: Weight loss tracking weights := []float32{85.5, 84.8, 84.2, 83.9, 83.5, 83.0} nodes := []fynesimplechart.Node{} for week, weight := range weights { nodes = append(nodes, *fynesimplechart.NewNode( float32(week+1), weight, )) } plot := fynesimplechart.NewPlot(nodes, "Weight (kg)") plot.ShowLine = true plot.LineWidth = 2.5 ``` -------------------------------- ### Basic Real-time Data Example Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/11-realtime-data.md Demonstrates a basic real-time chart update. It adds a new data point every second, keeps the last 20 points, and refreshes the chart. Requires `time`, `math/rand`, `fyne.io/fyne/v2`, and `github.com/alexiusacademia/fynesimplechart`. ```go package main import ( "time" "math/rand" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Real-time Data") w.Resize(fyne.NewSize(800, 600)) nodes := []fynesimplechart.Node{} plot := fynesimplechart.NewPlot(nodes, "Live Data") plot.ShowLine = true plot.LineWidth = 2 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.SetChartTitle("Real-time Monitoring") // Update data every second go func() { x := float32(0) for { // Add new data point y := float32(rand.Float64()*10 + 50) nodes = append(nodes, *fynesimplechart.NewNode(x, y)) // Keep only last 20 points if len(nodes) > 20 { nodes = nodes[1:] // Adjust X coordinates for i := range nodes { nodes[i].X = float32(i) } } // Update plot and refresh plot.Nodes = nodes chart.Refresh() x++ time.Sleep(1 * time.Second) } }() w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Compare Color Contrast Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md Examples of color combinations that provide good versus poor visual contrast. ```go // Good contrast - easy to distinguish blue := color.RGBA{R: 31, G: 119, B: 180, A: 255} orange := color.RGBA{R: 255, G: 127, B: 14, A: 255} // Bad contrast - hard to distinguish lightBlue := color.RGBA{R: 150, G: 180, B: 200, A: 255} lightGreen := color.RGBA{R: 150, G: 200, B: 180, A: 255} ``` -------------------------------- ### Plot Mathematical Functions Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/03-line-charts.md Example of generating data points from a mathematical function. ```go // Example: Exponential growth nodes := []fynesimplechart.Node{} for x := 0.0; x <= 5.0; x += 0.2 { y := math.Exp(x / 2) // e^(x/2) nodes = append(nodes, *fynesimplechart.NewNode( float32(x), float32(y), )) } plot := fynesimplechart.NewPlot(nodes, "e^(x/2)") plot.ShowLine = true plot.ShowPoints = false plot.LineWidth = 2 ``` -------------------------------- ### Common Custom Color Examples in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md Demonstrates setting various common colors like Red, Green, Blue, Purple, Orange, and Cyan for plots using `color.RGBA`. ```go // Red plot.PlotColor = color.RGBA{R: 255, G: 0, B: 0, A: 255} // Green plot.PlotColor = color.RGBA{R: 0, G: 255, B: 0, A: 255} // Blue plot.PlotColor = color.RGBA{R: 0, G: 0, B: 255, A: 255} // Purple plot.PlotColor = color.RGBA{R: 128, G: 0, B: 128, A: 255} // Orange plot.PlotColor = color.RGBA{R: 255, G: 165, B: 0, A: 255} // Cyan plot.PlotColor = color.RGBA{R: 0, G: 255, B: 255, A: 255} ``` -------------------------------- ### Basic Chart Template Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/01-getting-started.md A concise template for creating a basic chart with FyneSimpleChart, including data point creation, plot setup, and widget instantiation. ```go // Basic chart template nodes := []fynesimplechart.Node{ *fynesimplechart.NewNode(x, y), } plot := fynesimplechart.NewPlot(nodes, "Title") chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) ``` -------------------------------- ### Chart Title Best Practices in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md Provides examples of effective chart titles that are specific and descriptive, contrasting them with generic titles to avoid. Good titles enhance data interpretation. ```go // Good titles - specific and descriptive chart.SetChartTitle("Q1 2024 Revenue by Region") chart.SetChartTitle("Customer Satisfaction Trend") chart.SetChartTitle("Temperature Monitoring - Building A") // Avoid - too generic chart.SetChartTitle("Chart") chart.SetChartTitle("Data") ``` -------------------------------- ### Revenue/Profit Chart Fill Configuration Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/09-area-fills.md Example configuration for a revenue or profit chart where the area is filled from the plot line down to the zero axis. Uses a green color for the fill. ```go plot.FillArea = true plot.FillToZero = true plot.PlotColor = color.RGBA{R: 76, G: 175, B: 80, A: 255} // Green ``` -------------------------------- ### Create New Project Directory Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/01-getting-started.md Set up a new project by creating a directory and initializing Go modules. ```bash mkdir my-chart-app cd my-chart-app go mod init my-chart-app ``` -------------------------------- ### Create a Business Dashboard with FyneSimpleChart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/13-integration-examples.md Demonstrates building a dashboard layout with multiple side-by-side charts and helper functions for node creation. ```go package main import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Business Dashboard") w.Resize(fyne.NewSize(1200, 800)) // Revenue chart revenueData := []float32{45, 52, 48, 61, 58, 67} revenueNodes := createNodes(revenueData) revenuePlot := fynesimplechart.NewPlot(revenueNodes, "Revenue ($K)") revenuePlot.ShowLine = true revenuePlot.LineWidth = 2.5 revenueChart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*revenuePlot}) revenueChart.SetChartTitle("Monthly Revenue") revenueChart.Resize(fyne.NewSize(550, 350)) // Users chart usersData := []float32{1200, 1350, 1420, 1560, 1650, 1780} usersNodes := createNodes(usersData) usersPlot := fynesimplechart.NewPlot(usersNodes, "Active Users") usersPlot.ShowLine = true usersPlot.LineWidth = 2.5 usersChart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*usersPlot}) usersChart.SetChartTitle("User Growth") usersChart.Resize(fyne.NewSize(550, 350)) // Layout topRow := container.NewGridWithColumns(2, revenueChart, usersChart) // Add some metrics metrics := widget.NewLabel("Key Metrics: Revenue +15% | Users +48%") content := container.NewBorder(nil, metrics, nil, nil, topRow) w.SetContent(content) w.ShowAndRun() } func createNodes(data []float32) []fynesimplechart.Node { nodes := []fynesimplechart.Node{} for i, val := range data { nodes = append(nodes, *fynesimplechart.NewNode( float32(i+1), val, )) } return nodes } ``` -------------------------------- ### Common Axis Title Patterns Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/15-enhanced-features.md Examples of standard axis labeling for different data types. ```go // Time series chart.XAxisTitle = "Time (hours)" chart.YAxisTitle = "Value" // Scientific data chart.XAxisTitle = "Distance (m)" chart.YAxisTitle = "Force (N)" // Business metrics chart.XAxisTitle = "Month" chart.YAxisTitle = "Revenue ($K)" // Performance data chart.XAxisTitle = "Iteration" chart.YAxisTitle = "Execution Time (ms)" ``` -------------------------------- ### Plot Time Series Data Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/03-line-charts.md Example of mapping sequential time-based data to chart nodes. ```go // Example: Website traffic over time traffic := []int{1200, 1350, 1280, 1420, 1560, 1490, 1630} nodes := []fynesimplechart.Node{} for day, visits := range traffic { nodes = append(nodes, *fynesimplechart.NewNode( float32(day+1), float32(visits), )) } plot := fynesimplechart.NewPlot(nodes, "Daily Visitors") plot.ShowLine = true plot.ShowPoints = true plot.LineWidth = 2 ``` -------------------------------- ### Create Chart with Bottom Legend Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/15-enhanced-features.md Example of configuring a wide chart with a bottom-positioned legend for better readability. ```go func createBottomLegendChart() *fynesimplechart.ScatterPlot { // Create three series series1 := []fynesimplechart.Node{} series2 := []fynesimplechart.Node{} series3 := []fynesimplechart.Node{} for i := 0; i <= 20; i++ { x := float32(i) series1 = append(series1, *fynesimplechart.NewNode(x, 10+x*0.5)) series2 = append(series2, *fynesimplechart.NewNode(x, 15+x*0.3)) series3 = append(series3, *fynesimplechart.NewNode(x, 8+x*0.7)) } plot1 := fynesimplechart.NewPlot(series1, "Product A") plot1.ShowLine = true plot1.LineWidth = 2 plot2 := fynesimplechart.NewPlot(series2, "Product B") plot2.ShowLine = true plot2.LineWidth = 2 plot3 := fynesimplechart.NewPlot(series3, "Product C") plot3.ShowLine = true plot3.LineWidth = 2 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot1, *plot2, *plot3}) chart.SetChartTitle("Sales Trends by Product") // Bottom legend for wide chart chart.LegendPosition = fynesimplechart.LegendBottom return chart } ``` -------------------------------- ### Create a basic line chart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/03-line-charts.md Initializes a Fyne application window and renders a line chart with sequential data points. ```go package main import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Line Chart") w.Resize(fyne.NewSize(700, 500)) // Create sequential data points nodes := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 3), *fynesimplechart.NewNode(2, 5), *fynesimplechart.NewNode(3, 4), *fynesimplechart.NewNode(4, 7), *fynesimplechart.NewNode(5, 6), *fynesimplechart.NewNode(6, 8), } plot := fynesimplechart.NewPlot(nodes, "Sales") // Enable line connections plot.ShowLine = true plot.LineWidth = 2 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.SetChartTitle("Monthly Sales Trend") w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Implement temperature monitoring chart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/03-line-charts.md Generates a 24-hour temperature profile using a sine wave calculation. ```go package main import ( "math" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Temperature Monitoring") w.Resize(fyne.NewSize(800, 600)) // Generate 24-hour temperature data nodes := []fynesimplechart.Node{} for hour := 0; hour <= 24; hour++ { // Simulate temperature variation using sine wave // Lowest at 4 AM, highest at 4 PM x := float32(hour) baseline := float32(20.0) variation := float32(math.Sin((float64(hour)-4)*math.Pi/12) * 8) y := baseline + variation nodes = append(nodes, *fynesimplechart.NewNode(x, y)) } plot := fynesimplechart.NewPlot(nodes, "Temperature (°C)") plot.ShowLine = true plot.ShowPoints = false // Smooth line without points plot.LineWidth = 2.5 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.SetChartTitle("24-Hour Temperature Profile") w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Create Basic Fyne Chart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/01-getting-started.md Create a simple Fyne application that displays a line chart with predefined data points. Ensure Fyne and FyneSimpleChart are imported. ```go package main import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { // Create a new Fyne application a := app.New() w := a.NewWindow("My First Chart") w.Resize(fyne.NewSize(600, 400)) // Create some data points nodes := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 2), *fynesimplechart.NewNode(2, 4), *fynesimplechart.NewNode(3, 3), *fynesimplechart.NewNode(4, 5), *fynesimplechart.NewNode(5, 7), } // Create a plot plot := fynesimplechart.NewPlot(nodes, "My Data") // Create the chart widget chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) // Display the chart w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Configure Plot and Chart Settings Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md Demonstrates how to adjust visual properties for plots and the overall chart widget. ```go plot := fynesimplechart.NewPlot(nodes, "Title") // Color plot.PlotColor = color.RGBA{R: 255, G: 0, B: 0, A: 255} // Points plot.ShowPoints = true // true/false plot.PointSize = 4 // 1.0 to 10.0 (recommended: 2-6) // Lines plot.ShowLine = true // true/false plot.LineWidth = 2.5 // 0.5 to 5.0 (recommended: 1.5-3.0) // Chart-level settings chart.SetChartTitle("My Chart") // String or "" chart.ShowGrid = true // true/false ``` -------------------------------- ### Use Case Configurations Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/14-bar-charts.md Basic property settings for common chart types. ```go // Perfect for showing sales trends by month plot.ShowBars = true plot.BarWidth = 0.8 ``` ```go // Great for displaying response counts plot.ShowBars = true plot.BarBorderWidth = 1 // Add borders for clarity ``` -------------------------------- ### Good Contrast Colors Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/08-color-palettes.md Example of defining colors that ensure good visual distinction between plot elements. ```go // Good contrast blue := color.RGBA{R: 31, G: 119, B: 180, A: 255} orange := color.RGBA{R: 255, G: 127, B: 14, A: 255} ``` -------------------------------- ### Create Styled Product Sales Comparison Chart in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md This Go code snippet demonstrates how to create a Fyne application window and display a chart comparing sales data for three products. It customizes the color and line width for each product's data series to visually represent their performance. ```go package main import ( "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Product Comparison") w.Resize(fyne.NewSize(800, 600)) // Product A - Leader dataA := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 85), *fynesimplechart.NewNode(2, 90), *fynesimplechart.NewNode(3, 92), *fynesimplechart.NewNode(4, 95), } plotA := fynesimplechart.NewPlot(dataA, "Product A") plotA.PlotColor = color.RGBA{R: 76, G: 175, B: 80, A: 255} // Green plotA.ShowLine = true plotA.LineWidth = 3.5 // Product B - Competitive dataB := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 70), *fynesimplechart.NewNode(2, 72), *fynesimplechart.NewNode(3, 75), *fynesimplechart.NewNode(4, 78), } plotB := fynesimplechart.NewPlot(dataB, "Product B") plotB.PlotColor = color.RGBA{R: 255, G: 152, B: 0, A: 255} // Orange plotB.ShowLine = true plotB.LineWidth = 2.5 // Product C - Struggling dataC := []fynesimplechart.Node{ *fynesimplechart.NewNode(1, 45), *fynesimplechart.NewNode(2, 42), *fynesimplechart.NewNode(3, 40), *fynesimplechart.NewNode(4, 38), } plotC := fynesimplechart.NewPlot(dataC, "Product C") plotC.PlotColor = color.RGBA{R: 244, G: 67, B: 54, A: 255} // Red plotC.ShowLine = true plotC.LineWidth = 1.5 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plotA, *plotB, *plotC}) chart.SetChartTitle("Quarterly Product Sales Comparison") w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Run Go Application Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/01-getting-started.md Execute your Go application to display the Fyne chart. Ensure you are in the project directory. ```bash go run main.go ``` -------------------------------- ### Differentiate Series by Color Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/05-multiple-series.md Colors are automatically assigned to series when added to the chart. This example shows how different plots receive distinct default colors. ```go // Colors are assigned automatically plot1 := fynesimplechart.NewPlot(data1, "Series 1") // Blue plot2 := fynesimplechart.NewPlot(data2, "Series 2") // Orange plot3 := fynesimplechart.NewPlot(data3, "Series 3") // Green ``` -------------------------------- ### Setting a Main Chart Title in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md To add a title to your chart, use the `SetChartTitle` method on the `GraphWidget`. This example sets a descriptive title for the chart. ```go chart := fynesimplechart.NewGraphWidget(plots) chart.SetChartTitle("Monthly Sales Report") ``` -------------------------------- ### Goroutine Management with Context Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/11-realtime-data.md Illustrates how to manage goroutines for real-time updates using `context` for clean shutdown. This pattern ensures that background update loops can be properly terminated when the application closes. ```go // Use context for clean shutdown ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { for { select { case <-ctx.Done(): return default: // Update data time.Sleep(1 * time.Second) } } }() ``` -------------------------------- ### Professional Color Palette Examples in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md Presents a selection of professionally curated colors that harmonize well together, suitable for use in charts. Each color is defined using `color.RGBA`. ```go // Professional Blue color.RGBA{R: 31, G: 119, B: 180, A: 255} // Professional Orange color.RGBA{R: 255, G: 127, B: 14, A: 255} // Professional Green color.RGBA{R: 44, G: 160, B: 44, A: 255} // Professional Red color.RGBA{R: 214, G: 39, B: 40, A: 255} // Professional Purple color.RGBA{R: 148, G: 103, B: 189, A: 255} // Professional Brown color.RGBA{R: 140, G: 86, B: 75, A: 255} // Professional Pink color.RGBA{R: 227, G: 119, B: 194, A: 255} // Professional Gray color.RGBA{R: 127, G: 127, B: 127, A: 255} // Professional Olive color.RGBA{R: 188, G: 189, B: 34, A: 255} // Professional Cyan color.RGBA{R: 23, G: 190, B: 207, A: 255} ``` -------------------------------- ### Implement Marketing Presentation Chart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md Creates a bold chart style suitable for presentations by using thick lines and disabling grid lines. ```go // Bold, presentation-ready style plot := fynesimplechart.NewPlot(engagement, "User Engagement") plot.PlotColor = color.RGBA{R: 255, G: 87, B: 34, A: 255} // Bright orange plot.ShowLine = true plot.ShowPoints = false // Clean lines only plot.LineWidth = 4 // Thick, visible from distance chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot}) chart.SetChartTitle("2024 User Engagement Growth") chart.ShowGrid = false // Clean, minimal look ``` -------------------------------- ### Creating a Multi-Function Graph in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/10-mathematical-functions.md Demonstrates how to display multiple plots, such as sine and cosine, on a single graph widget. ```go package main import ( "math" "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/alexiusacademia/fynesimplechart" ) func main() { a := app.New() w := a.NewWindow("Mathematical Functions") w.Resize(fyne.NewSize(900, 650)) // Sine function sineNodes := []fynesimplechart.Node{} for i := 0; i <= 60; i++ { x := float32(i) / 10.0 y := float32(math.Sin(float64(x))) sineNodes = append(sineNodes, *fynesimplechart.NewNode(x, y)) } sinePlot := fynesimplechart.NewPlot(sineNodes, "sin(x)") sinePlot.ShowLine = true sinePlot.ShowPoints = false sinePlot.LineWidth = 2 sinePlot.PlotColor = color.RGBA{R: 255, G: 99, B: 71, A: 255} // Cosine function cosineNodes := []fynesimplechart.Node{} for i := 0; i <= 60; i++ { x := float32(i) / 10.0 y := float32(math.Cos(float64(x))) cosineNodes = append(cosineNodes, *fynesimplechart.NewNode(x, y)) } cosinePlot := fynesimplechart.NewPlot(cosineNodes, "cos(x)") cosinePlot.ShowLine = true cosinePlot.ShowPoints = false cosinePlot.LineWidth = 2 cosinePlot.PlotColor = color.RGBA{R: 65, G: 105, B: 225, A: 255} chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{ *sinePlot, *cosinePlot, }) chart.SetChartTitle("Trigonometric Functions") w.SetContent(chart) w.ShowAndRun() } ``` -------------------------------- ### Compare Chart Styles Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/07-grid-and-axes.md Demonstrates the difference between analytical and presentation styles by toggling grid visibility. ```go // Analytical style chart1 := fynesimplechart.NewGraphWidget(plots) chart1.ShowGrid = true chart1.SetChartTitle("Detailed Analysis") // Presentation style chart2 := fynesimplechart.NewGraphWidget(plots) chart2.ShowGrid = false chart2.SetChartTitle("Executive Summary") ``` -------------------------------- ### Troubleshooting: Plots Added to Chart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/09-area-fills.md For any fill to be rendered, the plots involved must be correctly added to the chart widget. This example shows a source plot filling to a target plot. ```go // 4. Plots must be added to chart chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{ *targetPlot, // Index 0 *sourcePlot, // This one has FillToPlotIdx = 0 }) ``` -------------------------------- ### Create Before/After Optimization Chart Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/05-multiple-series.md Use this to compare two datasets, such as performance before and after an optimization. Both plots are configured to show lines and have a specified line width. ```go before := fynesimplechart.NewPlot(beforeData, "Before Optimization") before.ShowLine = true before.LineWidth = 2 after := fynesimplechart.NewPlot(afterData, "After Optimization") after.ShowLine = true after.LineWidth = 2 chart := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{ *before, *after, }) chart.SetChartTitle("Performance Improvement") ``` -------------------------------- ### Setting a Custom Plot Color in Go Source: https://github.com/alexiusacademia/fynesimplechart/blob/master/tutorials/04-customizing-appearance.md You can set a specific color for a plot using the `color.RGBA` type. Ensure you import the `image/color` package. This example sets a custom red color. ```go import "image/color" plot := fynesimplechart.NewPlot(nodes, "My Data") // Set a custom color (RGB + Alpha) plot.PlotColor = color.RGBA{R: 220, G: 20, B: 60, A: 255} ```