### Install TeeChart NET for Avalonia via NuGet
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
This XML snippet shows how to add the Steema.TeeChart.NET.Avalonia NuGet package to your .NET project file for Avalonia applications. Ensure your project targets a compatible .NET framework.
```xml
WinExe
net6.0
enable
```
--------------------------------
### Setup TeeChart XAML Namespaces for Avalonia
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
This XML snippet demonstrates how to declare the necessary TeeChart namespaces in your Avalonia XAML files. This allows you to use TeeChart controls and series types declaratively.
```xml
```
--------------------------------
### Configure Chart Axes with Logarithmic Scale in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Configure chart axes in TeeChart XAML, including setting visibility, automatic minimum values, logarithmic scaling, and stroke styling. This example demonstrates how to customize the left axis with a logarithmic scale and the bottom axis with a specific increment.
```xml
```
--------------------------------
### Programmatically Manipulate Candle Series in C#
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Access internal series from code-behind to dynamically modify chart data and properties, such as setting labels and chart headers. This example demonstrates how to find a Candle series by name and update its data and appearance.
```csharp
using Avalonia.Controls;
using Avalonia.Interactivity;
using Steema.TeeChart.Styles;
using System;
public partial class MainWindow : Window
{
private TeeChart.Xaml.Avalonia.Series.Candle Candle11;
public MainWindow()
{
InitializeComponent();
}
private void CheckBoxChanged(object sender, RoutedEventArgs e)
{
if (!((CheckBox)sender).IsChecked.Value)
{
// Find controls by name
Candle11 = this.FindNameScope()?.Find("Candle1");
var tChartCandle = this.FindNameScope()?.Find("tChartCandle");
if (Candle11 != null)
{
SetLabelsNoWeekend((Steema.TeeChart.Styles.Candle)Candle11.InternalSeries);
}
Candle11.InternalSeries.Chart.Panel.MarginBottom = 20;
Candle11.InternalSeries.Chart.Header.Text = "Candle Series - no weekends";
}
}
private void SetLabelsNoWeekend(Steema.TeeChart.Styles.Candle theCandle)
{
StringList labels = new StringList(10);
labels.Add("25/04/2024");
labels.Add("26/04/2024");
labels.Add("29/04/2024");
// ... more labels
theCandle.XValues.DateTime = false;
theCandle.GetHorizAxis.Labels.Angle = 270;
Random r = new Random();
theCandle.Clear();
double tmpOpen;
DateTime dt = new DateTime(2024, 04, 25);
TimeSpan ts = TimeSpan.FromDays(1);
int count = 0;
for (int t = 0; t < 13; t++)
{
if (t == 0)
tmpOpen = r.Next(100);
else
tmpOpen = theCandle.CloseValues.Last + 5 - r.Next(10);
if (dt.DayOfWeek != DayOfWeek.Saturday && dt.DayOfWeek != DayOfWeek.Sunday)
{
++count;
var high = tmpOpen + r.Next(20);
var low = tmpOpen - r.Next(20);
theCandle.Add(count, tmpOpen, high, low, low + r.Next(10));
}
dt += ts;
}
theCandle.Labels = labels;
}
}
```
--------------------------------
### Dynamic ColorGrid Data ViewModel in C#
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Provides a ViewModel for the ColorGrid series, managing Series3DData and implementing dynamic updates via a DispatcherTimer for animated heatmap effects. Uses CommunityToolkit.Mvvm for observable properties.
```csharp
// ViewModel for ColorGrid data binding with animation
using System;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using TeeChart.Xaml.Avalonia.Series;
public class BindingDataPropertiesViewModel : ObservableRecipient
{
private const int Height = 20;
private const int Amount = 100;
private double _offset;
private readonly DispatcherTimer _timer;
public Series3DData[] Data { get; }
public BindingDataPropertiesViewModel()
{
Data = new Series3DData[Amount];
int i = 0;
for (int x = 0; x < 10; x++)
{
for (int z = 0; z < 10; z++)
{
Data[i] = new Series3DData {
X = x,
Y = Math.Sin(i / (double)Amount * Math.PI * 2) * Height,
Z = z
};
i++;
}
}
_timer = new DispatcherTimer(DispatcherPriority.Normal) {
Interval = TimeSpan.FromSeconds(0.05)
};
_timer.Tick += OnTick;
_timer.Start();
}
private void OnTick(object sender, EventArgs eventArgs)
{
_offset += 2;
for (var i = 0; i < Amount; i++)
{
Data[i].Y = Math.Sin((i + _offset) / Amount * Math.PI * 2) * Height;
}
}
}
```
--------------------------------
### ColorGrid Data Binding with MVVM in Avalonia
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Demonstrates binding a ColorGrid series to a Series3DData array for dynamic heatmap updates using the MVVM pattern. Supports real-time data changes and visual feedback.
```xml
```
--------------------------------
### Create Basic Bar Chart with Manual Values in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
This XAML code defines a basic Bar chart using TeeChart for Avalonia. It manually sets Y values for two separate Bar series, allowing for stacked or comparative visualizations.
```xml
```
--------------------------------
### Dynamic Sample Values with Binding in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Binds a Slider's value to the SampleValues property of a Bar series, allowing interactive data generation. Changes in the slider's value dynamically update the chart.
```xml
Sample Values:
```
--------------------------------
### Create Bar Chart with Labels in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
This XAML code shows how to add text labels to data points in a Bar chart using TeeChart for Avalonia. The Label property is used, and explicit X positions can be provided for precise placement.
```xml
```
--------------------------------
### 3D Surface Series Visualization in Avalonia XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Configures a 3D Surface series within a TeeChart component using XAML. Features include rainbow palettes, customizable side line colors, and 3D aspect ratio settings.
```xml
```
--------------------------------
### Generate Sample Values for TeeChart Series in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
This XAML code demonstrates how to automatically generate sample data for TeeChart series in Avalonia using the SampleValues property. You can specify -1 for the default amount or a specific count.
```xml
```
--------------------------------
### ColorGrid Series for Heatmaps in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Implements a ColorGrid series to visualize 2D data as a heatmap. It utilizes the 'Rainbow' palette and displays 3D data points (X, Y, Z).
```xml
```
--------------------------------
### Data Binding with ObservableCollection in XAML and C#
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Demonstrates data binding for TeeChart series using an ObservableCollection in C# and XAML. The XAML specifies the `ItemsSource` and uses `XPath` and `YPath` to map properties from custom data objects to the chart's series. The C# ViewModel provides the `ObservableCollection` and a command to add new data points.
```xml
```
```csharp
// ViewModel with ObservableCollection binding
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.ObjectModel;
public class BindingObservableCollectionViewModel : ObservableRecipient
{
public ObservableCollection DataArray { get; }
public RelayCommand AddDataCommand { get; }
private readonly Random _random;
public BindingObservableCollectionViewModel()
{
DataArray = new ObservableCollection();
_random = new Random();
// Initialize with sample data
for (var i = 0; i < 5; i++)
{
DataArray.Add(new Data {
A = _random.NextDouble() * 100,
B = _random.NextDouble() * 200
});
}
AddDataCommand = new RelayCommand(AddData);
}
private void AddData()
{
DataArray.Add(new Data {
A = _random.NextDouble() * 100,
B = _random.NextDouble() * 200
});
}
public class Data
{
public double A;
public double B;
public override string ToString() => $"({A:F2}, {B:F2})";
}
}
```
--------------------------------
### Create Points Series with X and Y Coordinates in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
This XAML snippet defines a Points series for a scatter plot in TeeChart for Avalonia. Both X and Y coordinates are specified for each data point using the SeriesData element.
```xml
```
--------------------------------
### Initialize TChart in Avalonia Code-Behind C#
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Initialize a UserControl in Avalonia and access the TChart component defined in XAML for programmatic series addition. This C# code snippet shows the basic structure for interacting with a TChart from code-behind.
```csharp
using Avalonia.Controls;
using Steema.TeeChart;
using Steema.TeeChart.Avalonia;
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
// Access chart1 for programmatic series addition
}
}
```
--------------------------------
### Configure Chart Header, Legend, and Panel Appearance in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Customize the visual appearance of a TeeChart chart by configuring its header, legend, and panel. This includes setting text for the header, and defining stroke and fill brushes for the legend and panel to control their borders and backgrounds.
```xml
```
--------------------------------
### Points Series with Custom Pointers in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Defines a Points series with custom marker pointers. The pointers have a specified size, stroke thickness, fill color (AntiqueWhite), and stroke color (DarkGray).
```xml
```
--------------------------------
### Create Bar Chart with Custom Colors in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
This XAML snippet demonstrates how to assign specific colors to individual data points within a Bar series in TeeChart for Avalonia. Each SeriesData element can have its Color property set.
```xml
```
--------------------------------
### Create TChart with 3D View in Avalonia XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Define a TChart component in Avalonia XAML with the View3D property enabled. This allows for programmatic access to the chart from code-behind for further customization.
```xml
```
--------------------------------
### Line Series with Styled Stroke in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Creates a Line series with a thick, semi-transparent red stroke. Customizes the line's appearance using a SolidColorBrush for the stroke color and opacity.
```xml
```
--------------------------------
### Enable Zoom and Scroll Interactivity in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Configure interactive zoom and scroll functionality for a TeeChart chart using XAML. This allows users to zoom in and out and scroll through chart data. Options include specifying the direction, mouse button, and visual styling for the zoom interaction.
```xml
```
--------------------------------
### Candlestick (OHLC) Financial Chart in Avalonia XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Implements a Candlestick series for financial data visualization in Avalonia XAML. Supports Open, High, Low, Close (OHLC) data points and customizable colors for up and down trends.
```xml
```
--------------------------------
### Bar Series with Arrow Style in XAML
Source: https://context7.com/steema/teechart-avalonia-samples/llms.txt
Configures a Bar series to use the 'Arrow' style for its bars. Customizes the fill (Aquamarine) and stroke (Pink) colors with semi-transparency.
```xml
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.