### Headless Chart Creation and Rendering Setup (C#) Source: https://lightningchart.com/net-charts/docs/inDetail/headless-mode Example of creating a LightningChart instance in headless mode, setting dimensions, initializing the rendering device, and setting up an event handler for rendering completion. This is typically used in Windows Services or background applications. ```csharp private LightningChart _chart = null; private void CreateChart() { _chart = new LightningChart(new RenderingSettings() { HeadlessMode = true }); _chart.BeginUpdate(); _chart.InitializeRenderingDevice(); _chart.Width = 600; _chart.Height = 500; _chart.ViewXY.XAxes[0].ValueType = AxisValueType.Number; _chart.ViewXY.XAxes[0].SetRange(0, 10); PointLineSeries lineSeries = new PointLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]); _chart.ViewXY.PointLineSeries.Add(lineSeries); _chart.AfterRendering += _chart_AfterRendering; _chart.EndUpdate(); } int count = 0; private void _chart_AfterRendering(object sender, AfterRenderingEventArgs e) { _chart.CopyToClipboard(); // OR bool bSaved = _chart.SaveToFile(Directory.GetCurrentDirectory() + "\" + (count++).ToString() +".png"); } ``` -------------------------------- ### Open and Start SignalReader Source: https://lightningchart.com/net-charts/docs/inDetail/signal-tools Opens a WAV file and starts playback. Ensure the file path is correct and the file format is supported. Playback can be stopped using StopRequest(). ```csharp signalReader.OpenFile(@"c:\\wavedata\\audioclip1.wav"); signalReader.Start(); ``` -------------------------------- ### UWP Chart Configuration with Namespaces Source: https://lightningchart.com/net-charts/docs/beginners%20guide/chartEditionsV11 Example of configuring a LightningChart in UWP using defined namespaces for views and axes. ```xml ``` -------------------------------- ### Initiate SHP Data Conversion Source: https://lightningchart.com/net-charts/docs/inDetail/geographic-maps Call this method to start the file selection and conversion process for SHP data. It returns a boolean indicating success. ```csharp public bool SelectFilesAndConvert() ``` -------------------------------- ### Create LightningChart UWP Component in Code Source: https://lightningchart.com/net-charts/docs/inDetail/creating-UWP-project Example of creating a LightningChart instance and adding it to a UWP application's content grid. Ensure to use BeginUpdate() and EndUpdate() for configuration. ```csharp using LightningChartLib.UWP.ChartingMVVM; namespace ExampleProject { public sealed partial class MainPage : Page { private LightningChart _chart = null; public MainPage() { InitializeComponent(); CreateChart(); } private void CreateChart() { _chart = new LightningChart(); // Chart control into the parent container. (Content as Grid).Children.Add(_chart); // Disable rendering until the whole chart is set up correctly. _chart.BeginUpdate(); // Configure chart here. // Allow rendering the chart. _chart.EndUpdate(); } } } ``` -------------------------------- ### Configure HalfDonut Color Palette and Properties Source: https://lightningchart.com/net-charts/docs/inDetail/half-donut Demonstrates setting the color scale (HSV, HSVA, Slice), color step, saturation, starting color value, main value, and alpha for HalfDonut charts. ```csharp // Setting colors. donut.SelectedColorPalette = HalfDonut.ColorScale.HSVA; donut.ColorStep = 5; donut.Saturation = 0.9; donut.StartingColorValue = 30; donut.Value = 0.6; donut.Alpha = 0.4; ``` -------------------------------- ### Create Custom Color Theme (Method 1) Source: https://lightningchart.com/net-charts/docs/inDetail/color-theme Create a custom color theme by getting the CustomDynamicTheme, modifying its properties, and then updating the chart. This method allows granular control over theme elements. ```javascript ThemeBasics theme = _chart.CustomDynamicTheme; theme.BackgroundColor = Colors.Black; theme.ChartTitleColor = Colors.Green; _chart.CustomDynamicTheme = theme; _chart.UpdateCustomTheme(); ``` -------------------------------- ### Create WinForms Chart in Code Source: https://lightningchart.com/net-charts/docs/beginners%20guide/creating-chart-in-code Instantiate a WinForms LightningChart object and set its parent and docking properties in code behind. Use BeginUpdate() and EndUpdate() to control rendering during setup. ```csharp using LightningChartLib.WinForms.Charting; namespace WinFormsApp1 { public partial class Form1 : Form { //Chart private LightningChart _chart = null; public Form1() { InitializeComponent(); CreateChart(); } private void CreateChart() { _chart = new LightningChart(); //Disable rendering, strongly recommended before updating chart properties _chart.BeginUpdate(); //Chart parent must be set _chart.Parent = this; //Fill parent area with chart _chart.Dock = DockStyle.Fill; // Configure chart here. //Allow chart rendering _chart.EndUpdate(); } } } ``` -------------------------------- ### Ideal Dispose Pattern for Complex Application Source: https://lightningchart.com/net-charts/docs/inDetail/dispose-pattern This example demonstrates the comprehensive dispose method for a complex application, including handling background workers, clearing UI elements, and disposing of various chart-related objects and collections. ```csharp /// /// Dispose charts. /// public void Dispose() { if (_backGroundWorker != null) { _running = false; _backGroundWorker.Dispose(); _backGroundWorker = null; } if (_ChartList == null) return; // Remove first from UI. ChartPlace3D.Children.Clear(); ChartPlaceEEG.Children.Clear(); ChartPlacePowerSpectrum.Children.Clear(); ChartHead2D0.Children.Clear(); ChartHead2D1.Children.Clear(); ChartHead2D2.Children.Clear(); ChartHead2D3.Children.Clear(); ChartHead2D4.Children.Clear(); // And dispose after removed from UI. _ChartList[2].View3D.SurfaceMeshSeries3D[0].ContourPalette.Dispose(); for (int i = 0; i < _ChartList.Count; i++) { _ChartList[i].MouseClick -= Chart_MouseClick; _ChartList[i].Dispose(); } _ChartList = null; _reader = null; _spectrumCalculator.Dispose(); _spectrumCalculator = null; _gads2D = null; _sensorLocations = null; _modelGeometryAdditionalData = null; _dataPointSeries.Dispose(); _dataPointSeries = null; _points = null; _paletteStepColors = null; _ThemeStepColors = null; GC.Collect(); } ``` -------------------------------- ### Set Inner Circle Radius Percentage for Polar Axis Source: https://lightningchart.com/net-charts/docs/inDetail/data-clipping-polar Adjust the InnerCircleRadiusPercentage property for a specific amplitude axis to define the starting point of the data clipping near the center of the polar chart. This example sets the percentage to 10. ```javascript chart.ViewPolar.Axes[0].InnerCircleRadiusPercentage = 10; ``` -------------------------------- ### Create and Add HalfDonutControlPanel Source: https://lightningchart.com/net-charts/docs/inDetail/half-donut Demonstrates the creation of a HalfDonutControlPanel and adding it to a UI container, followed by associating an existing HalfDonut object with the control panel. ```csharp // Creating a HalfDonutControlPanel HalfDonutControlPanel cp = new HalfDonutControlPanel(); // Adding to a grid element _controlGrid.Children.Add(cp); // Add an existing half donut object. cp.HalfDonuts.Add(donut); ``` -------------------------------- ### Construct and Add HalfDonut Source: https://lightningchart.com/net-charts/docs/inDetail/half-donut Demonstrates how to create a new HalfDonut object, add it to a container like a Grid, and configure it within BeginUpdate/EndUpdate calls for efficient rendering. ```csharp HalfDonut donut = new HalfDonut(); (Content as Grid).Children.Add(donut); donut.BeginUpdate(); // Configure half donut chart here donut.EndUpdate(); ``` -------------------------------- ### Handle Legend Box MouseUp Event and Get Interaction Data Source: https://lightningchart.com/net-charts/docs/inDetail/legend-box-properties This example shows how to attach a MouseUp event handler to a legend box and use GetLegendBoxInteractionDataAtMouseEvent to determine what was clicked within the legend. The CreateEventString helper method processes different event argument types and interaction data. ```csharp _chart.ViewXY.LegendBoxes[0].MouseUp += LegendBox_MouseUp; private void LegendBox_MouseUp(object? sender, MouseEventArgs e) { CreateEventString("LegendBox_MouseUp", e as Object); } private void CreateEventString(string strEvent, object arg) { StringBuilder sb = new StringBuilder(); sb.AppendLine($"{DateTime.Now.ToLongTimeString()}; {strEvent}"); if (arg is MouseEventArgs) { MouseEventArgs e = (MouseEventArgs)arg; sb.AppendLine($"Button: {e.Button}, ClickCount: {e.Clicks}; Position: {e.X},{e.Y};"); } if (arg is SeriesTitleUserActionEventArgs) { SeriesTitleUserActionEventArgs e = (SeriesTitleUserActionEventArgs)arg; sb.AppendLine($"Series: {e.Series}, ButtonsState: {e.UserEventArguments.ButtonsState}; " + $"Position: {e.UserEventArguments.Position.X},{e.UserEventArguments.Position.Y}; " + $"EventType: {e.UserEventArguments.EventType}, Handled: {e.UserEventArguments.Handled}"); } if (arg is CheckBoxStateChangedEventArgs) { CheckBoxStateChangedEventArgs e = (CheckBoxStateChangedEventArgs)arg; sb.AppendLine($"Series: {e.Series}; IsChecked: {e.IsChecked};"); } LegendBoxInteractionData data = _chart.ViewXY.LegendBoxes[0].GetLegendBoxInteractionDataAtMouseEvent(); sb.AppendLine($"{strEvent}: {data.Type} | {GetSeriesTitle(data)}"); PrintString(sb); } ``` -------------------------------- ### Create and Configure PointLineSeries with Palette Source: https://lightningchart.com/net-charts/docs/inDetail/advanced-line-coloring Demonstrates how to create a PointLineSeries and enable palette-based coloring. The Y-axis can also be colored using the same palette by assigning the series to PaletteSeries. ```csharp PointLineSeries pls = new PointLineSeries(_chart.ViewXY, axisX, _chart.ViewXY.YAxes[0]) { UsePalette = true }; pls.LineStyle.Width = 5; pls.ValueRangePalette = CreatePalette(pls); //Color the Y axis too with the same palette _chart.ViewXY.YAxes[0].PaletteSeries = pls; _chart.ViewXY.YAxes[0].UsePalette = true; ``` -------------------------------- ### Get Graph Segment Information Source: https://lightningchart.com/net-charts/docs/inDetail/axis-layout-options Retrieves the top and bottom coordinates of each graph segment using the GetGraphSegmentInfo method. ```javascript // Getting top and bottom coordinates of every segment float[] topCoords = chart.ViewXY.GetGraphSegmentInfo().SegmentTops; float[] bottomCoords = chart.ViewXY.GetGraphSegmentInfo().SegmentBottoms; ``` -------------------------------- ### Set Y-Axes Layout to Stacked Source: https://lightningchart.com/net-charts/docs/inDetail/axis-layout-options Configures the Y-axes to use the Stacked layout, where each Y-axis gets its own equal vertical space. ```javascript chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked; ``` -------------------------------- ### Creating and Adding LiteZoomBar Source: https://lightningchart.com/net-charts/docs/inDetail/zoom-bar Demonstrates how to create a LiteZoomBar instance and add it to a form. Ensure the CustomControls namespace is used. ```csharp using LightningChartLib.WinForms.Charting.CustomControls; _Window = new Form(); _Window.Location = new Point(this.Left + 50, this.Top + 50); LiteZoomBar liteZoomBar = new LiteZoomBar(ref _chart); liteZoomBar.Dock = DockStyle.Fill; _Window.Controls.Add(liteZoomBar); ``` -------------------------------- ### Change Axis Value Type Source: https://lightningchart.com/net-charts/docs/inDetail/axis-class-properties Sets the value type for an axis, controlling how labels are displayed. This example changes the first Y-axis to use DateTime formatting. ```csharp // Changing axis value type chart.ViewXY.YAxes[0].ValueType = AxisValueType.DateTime; ``` -------------------------------- ### Set Y-Axes Layout to Layered Source: https://lightningchart.com/net-charts/docs/inDetail/axis-layout-options Defines how multiple Y axes are vertically aligned. Use YAxesLayout.Layered so all Y axes start from the top and stretch to the bottom, sharing the same vertical space. ```javascript chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Layered; ``` -------------------------------- ### Change Chart Render Options GPUPreference Source: https://lightningchart.com/net-charts/docs/how-to/debug-troubleshoot Shows how to set a preferred GPU for rendering to work around specific hardware issues. This is useful if multiple GPUs are available. ```csharp chart.ChartRenderOptions.GPUPreference = GPUPreference.Integrated; // or chart.ChartRenderOptions.GPUPreference = GPUPreference.Discrete; ``` -------------------------------- ### Set MeshModel Scaling Factor Source: https://lightningchart.com/net-charts/docs/how-to/resize-mesh-model Use the Size property to set the scaling factor for a MeshModel. This example demonstrates setting a uniform scaling factor across all axes. ```csharp float sizeFactor = 40f; // Model scaling // Set Scaling factor model.Size.SetValues(sizeFactor, sizeFactor, sizeFactor); ``` -------------------------------- ### Limit Zooming with ViewXY.Zoomed Event Source: https://lightningchart.com/net-charts/docs/how-to/limit-axis-range Use the ViewXY.Zoomed event to enforce axis range limits after zooming. This example prevents the X-axis from zooming out beyond a specified range. ```csharp private void View_Zoomed(object sender, ZoomedXYEventArgs e) { double min = 0; double max = 1000; ViewXY view = _chart.ViewXY; double currentMin = view.XAxes[0].Minimum; double currentMax = view.XAxes[0].Maximum; if (min > currentMin || max < currentMax) { if (min > currentMin) currentMin = min; if (max < currentMax) currentMax = max; _chart.BeginUpdate(); view.XAxes[0].SetRange(currentMin, currentMax); _chart.EndUpdate(); } } ``` -------------------------------- ### Start Drawing a Yellow Trend Line Source: https://lightningchart.com/net-charts/docs/inDetail/trading-chart Initiates the drawing of a yellow TrendLine on the chart. The tool is added to the chart's drawing tools collection and then its drawing mode is activated. ```csharp // Start drawing a yellow Trend line. TrendLine trendLine = new TrendLine(); trendLine.LineColor = Colors.Yellow; _chart.DrawingTools.Add(trendLine); trendLine.StartDrawing(); ``` -------------------------------- ### View Pie Chart in 2D Source: https://lightningchart.com/net-charts/docs/inDetail/view-pie-3D Set the camera to a predefined view from the top to display the pie chart as a 2D representation. ```csharp chart.ViewPie3D.Camera.SetPredefinedCamera(PredefinedCamera.PieTop); ``` -------------------------------- ### Getting the last point from a limited FreeformPointLineSeries Source: https://lightningchart.com/net-charts/docs/how-to/limit-point-count Directly retrieve the most recent point added to a FreeformPointLineSeries that has its point count limited. This is a convenient method for accessing the latest data point. ```csharp var lastPoint = series.GetLastPoint(); ``` -------------------------------- ### Add DigitalLineSeries and Data Source: https://lightningchart.com/net-charts/docs/inDetail/digital-line-series This snippet demonstrates how to create and configure a DigitalLineSeries, set its Y-values, sampling frequency, and add binary data using the AddBits method. Use this when you need to visualize binary data streams efficiently. ```csharp // Adding a DigitalLineSeries. DigitalLineSeries dls = new DigitalLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]); dls.Color = Colors.Yellow; dls.Width = 2; dls.FirstSampleTimeStamp = 0; dls.DigitalLow = 0; dls.DigitalHigh = 1; dls.SamplingFrequency = 32; uint[] data = new uint[] { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xa54df810, 0x00000000, 0xFFFFFFFF }; dls.AddBits(data, false); _chart.ViewXY.DigitalLineSeries.Add(dls); ``` -------------------------------- ### Incorrect: Sharing SeriesEventMarker Between Series Source: https://lightningchart.com/net-charts/docs/inDetail/sharing-objects This example shows the incorrect practice of adding the same SeriesEventMarker object to the collections of multiple series. The correct method is to create distinct markers for each series. ```csharp SeriesEventMarker marker = new SeriesEventMarker(); chart.ViewXY.PointLineSeries[0].SeriesEventMarkers.Add(marker); chart.ViewXY.PointLineSeries[1].SeriesEventMarkers.Add(marker); ``` -------------------------------- ### C++ LightningChart creation and configuration Source: https://lightningchart.com/net-charts/docs/how-to/cpp-application This C++ code demonstrates how to create a LightningChart instance, configure its axes, add a PointLineSeries, populate it with random data, and display it within a Windows Form. Ensure LightningChart's WinForms DLL is referenced and relevant namespaces are included. ```cpp protected: LightningChart ^ _chart; void CreateChart() { _chart = gcnew LightningChart(); //Disable repaints for every property change _chart->BeginUpdate(); //Set parent window by window handle _chart->Parent = this; //Fill the form area _chart->Dock = DockStyle::Fill; _chart->ActiveView = ActiveView::ViewXY; // Configure x-axis. AxisX^ axisX = _chart->ViewXY->XAxes[0]; axisX->SetRange(0, 20); axisX->ScrollMode = XAxisScrollMode::None; axisX->ValueType = AxisValueType::Number; // Configure y-axis. AxisY^ axisY = _chart->ViewXY->YAxes[0]; axisY->SetRange(0, 100); PointLineSeries^ pls1 = gcnew PointLineSeries(_chart->ViewXY, axisX, axisY); pls1->LineStyle->Color = Color::Yellow; pls1->Title->Text = "New Title"; pls1->PointsVisible = true; pls1->LineVisible = true; _chart->ViewXY->PointLineSeries->Add(pls1); // Generate random data. Random rand; int pointCount = 21; array ^ points = gcnew array(pointCount); for (int point = 0; point < pointCount; point++) { points[point].X = (double)point; points[point].Y = 100.0 * rand.NextDouble(); } pls1->Points = points; // Allow chart rendering. _chart->EndUpdate(); } ``` -------------------------------- ### Incorrect: Sharing Fill Object Between Annotations Source: https://lightningchart.com/net-charts/docs/inDetail/sharing-objects This example demonstrates the incorrect usage of sharing a Fill object between two AnnotationXY objects. The correct approach is to copy properties of ValueType. ```csharp AnnotationXY annotation1 = new AnnotationXY(); chart.ViewXY.Annotations.Add(annotation1); AnnotationXY annotation2 = new AnnotationXY(); annotation2.Fill = annotation1.Fill; chart.ViewXY.Annotations.Add(annotation2); ``` -------------------------------- ### Basic Headless Mode Initialization Source: https://lightningchart.com/net-charts/docs/inDetail/headless-mode Activate headless mode by setting the HeadlessMode flag to true in RenderingSettings during chart instantiation. This is useful for background rendering in applications without a UI. ```javascript var chart = new LightningChart(new RenderingSettings() { HeadlessMode = true }); ``` -------------------------------- ### Dispose Individual Series from Chart Source: https://lightningchart.com/net-charts/docs/inDetail/dispose-pattern This example shows how to remove and dispose of specific PointLineSeries from a chart's collection. Ensure the chart is updated using `BeginUpdate()` and `EndUpdate()` for these operations. ```csharp //Do cleanup... Remove and dispose 3 series _chart.BeginUpdate(); List listSeriesToBeRemoved = new List(); listSeriesToBeRemoved.Add(_chart.ViewXY.PointLineSeries[1]); listSeriesToBeRemoved.Add(_chart.ViewXY.PointLineSeries[3]); listSeriesToBeRemoved.Add(_chart.ViewXY.PointLineSeries[4]); foreach (PointLineSeries pls in listSeriesToBeRemoved) { _chart.ViewXY.PointLineSeries.Remove(pls); pls.Dispose(); } _chart.EndUpdate(); ``` -------------------------------- ### Initialize ZoomBar with a Chart Reference Source: https://lightningchart.com/net-charts/docs/inDetail/zoom-bar Instantiate a ZoomBar and associate it with a LightningChart object. The ZoomBar requires a reference to the main chart it will control. ```C# using LightningChartLib.WPF.Charting.CustomControls; // Creating a LightningChart object, then adding a Zoom bar referring to it. LightningChart _chart = new LightningChart(); mainGrid.Children.Add(_chart); zoomBarGrid.Children.Add(new ZoomBar(ref _chart)); ``` -------------------------------- ### Create and Use FIR Filter Source: https://lightningchart.com/net-charts/docs/inDetail/signal-tools Demonstrates how to create a FIR filter object and use its FilterData method to filter raw signal data. Ensure SignalProcessing namespace is imported. ```csharp using LightningChartLib.Wpf.SignalProcessing; // Creating a FIR filter and filtersamples with it. FIRFilter _firFilter = new FIRFilter(); double[] filteredSamples; _firFilter.FilterData(rawData, out filteredSamples); ``` -------------------------------- ### Add LiteLineSeries with Random Data Points Source: https://lightningchart.com/net-charts/docs/inDetail/lite-line-series Demonstrates how to create a LiteLineSeries, set its appearance, generate random data, and add it to the chart. Ensure data points are in progressive order. ```csharp LiteLineSeries lls = new LiteLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]); lls.Width = 2; lls.Color = Colors.Lime; double[,] values = new double[21, 2]; for (int i = 0; i < 21; i++) { values[i, 0] = i; // x-value values[i, 1] = rand.NextDouble() * 100; // y-value } lls.AddPoints(values, false); _chart.ViewXY.LiteLineSeries.Add(lls); ``` -------------------------------- ### Get Channel Count from DataGenerated Event Source: https://lightningchart.com/net-charts/docs/inDetail/signal-tools Demonstrates how to determine the number of channels available in the data stream received from the DataGenerated event by checking the length of the first dimension of the samples array. ```csharp channelCount = args.Samples.Length; ``` -------------------------------- ### Import New Layer with Configuration File Source: https://lightningchart.com/net-charts/docs/inDetail/geographic-maps Imports a new map layer from a shape file using a specified configuration file. This method allows for pre-defined map configurations. ```csharp public MapConverter.ConversionResult ImportNewLayer(String shpFilename, int targetLayerIndex, String configFile) ``` -------------------------------- ### Getting Segments at a Specific Point Source: https://lightningchart.com/net-charts/docs/inDetail/line-collection Use the GetSegmentsAtPoint method to identify which line segments in a LineCollection are located at a given coordinate. This method returns a list of integer indexes corresponding to the segments. ```csharp List list = _chart.ViewXY.LineCollections[0].GetSegmentsAtPoint(xCoordinate, yCoordinate); ``` -------------------------------- ### Convert DIP to Pixels (DpiHelper) Source: https://lightningchart.com/net-charts/docs/inDetail/dpi-handling Use the DpiHelper.DipToPx method to convert Device Independent Pixels (DIPs) to actual screen pixels based on the system's DPI settings. This is useful for scaling UI elements accurately. ```csharp double pixelValue = DpiHelper.DipToPx(dipValue); ``` -------------------------------- ### Track Specific Series with Predicate Source: https://lightningchart.com/net-charts/docs/inDetail/line-series-cursor Use TrackLineSeries with a Predicate to control which ITrackable series the cursor should resolve and draw track points for. This example tracks only series assigned to the first Y-axis. ```javascript cursor.TrackLineSeries = new Predicate(TrackableSeriesSelection); private bool TrackableSeriesSelection(ITrackable obj) { return (obj as SeriesBaseXY).AssignYAxisIndex == 0 || (bool)!checkBoxTrackLineSeries.IsChecked; } ``` -------------------------------- ### Create PersistentSeriesRenderingLayer Source: https://lightningchart.com/net-charts/docs/inDetail/persistent-layer Instantiate a PersistentSeriesRenderingLayer by providing the ViewXY object and the XAxis to be used with the series. This layer is not a sub-property of ViewXY and must be created in code. ```csharp using LightningChartLib.[edition].Charting.Views.ViewXY; PersistentSeriesRenderingLayer layer = new PersistentSeriesRenderingLayer (m_chart.ViewXY, m_chart.ViewXY.XAxes[0]); ``` -------------------------------- ### Access and Modify Internal Text Style Source: https://lightningchart.com/net-charts/docs/inDetail/half-donut Illustrates how to access and modify the style of internal text elements, like the left side text, of a HalfDonut chart using specific Get methods. ```csharp // Changing the internal annotation object. donut.GetLeftSideText().TextStyle.Color = Colors.LimeGreen; ``` -------------------------------- ### Set Tile Size and PPI Source: https://lightningchart.com/net-charts/docs/inDetail/geographic-maps Configures the size of the tile images (256 or 512) and the Pixels Per Inch (PPI) for rendering labels and icons (100, 200, or 400). ```csharp TileLayers[i].Size = TileImageSize.Image512; TileLayers[i].PPI = TilePPI.PPI400; ``` -------------------------------- ### Apply Deployment Key in WinForms Application Source: https://lightningchart.com/net-charts/docs/beginners%20guide/deployment This C# code snippet demonstrates how to apply the deployment key for various LightningChart components within the static constructor of a WinForms application's Program class. Ensure the deployment key is set before components are used. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace WindowsFormsApplication1 { static class Program { static Program() { //Set Deployment Key for LightningChart components string deploymentKey = "VMalgCAAO6kO1RgiNIBJABVcG.R..Kikfd..."; Arction.WinForms.Charting.LightningChart.SetDeploymentKey(deploymentKey); Arction.WinForms.SignalProcessing.SignalGenerator.SetDeploymentKey(deploymentKey); Arction.WinForms.SignalProcessing.AudioInput.SetDeploymentKey(deploymentKey); Arction.WinForms.SignalProcessing.AudioOutput.SetDeploymentKey(deploymentKey); Arction.WinForms.SignalProcessing.SpectrumCalculator.SetDeploymentKey(deploymentKey); Arction.WinForms.SignalProcessing.SignalReader.SetDeploymentKey(deploymentKey); Arction.WinForms.SignalProcessing.FilterRoutines.SetDeploymentKey(deploymentKey); Arction.CustomControls.Trader.WinForms.TradingChart.SetDeploymentKey(deploymentKey); } // Rest of the class ... } } ``` -------------------------------- ### Setting Line Segments for LineCollection Source: https://lightningchart.com/net-charts/docs/inDetail/line-collection Assign an array of SegmentLine structures to the Lines property of a LineCollection to define the line segments. Each SegmentLine defines the start (AX, AY) and end (BX, BY) points of a line segment. ```csharp lineCollection.Lines = new SegmentLine[] { new SegmentLine(6,25,8,30), new SegmentLine(8,30,7,40), new SegmentLine(7,40,10,40), new SegmentLine(10,40,12,28) }; ``` -------------------------------- ### Initialize MapConverter for SHP Data Source: https://lightningchart.com/net-charts/docs/inDetail/geographic-maps Instantiate the MapConverter class to begin the SHP data import process. Subscribe to the ConversionStateChanged event for progress updates. ```csharp MapConverter mapConverter = new MapConverter(false); mapConverter.ConversionStateChanged += mapConverter_ConversionStateChanged; ``` -------------------------------- ### Forward SignalGenerator Data to LightningChart Source: https://lightningchart.com/net-charts/docs/inDetail/signal-tools This example illustrates how to process the data received from the SignalGenerator's DataGenerated event and add it to SampleDataSeries in LightningChart for real-time visualization. It also updates the chart's scroll position. ```csharp private void m_signalGenerator_DataGenerated(DataGeneratedEventArgs args) { chart.BeginUpdate(); int channelIndex = 0; int sampleBundleCount = args.Samples[0].Length; foreach (SampleDataSeries series in chart.ViewXY.SampleDataSeries) { series.AddSamples(args.Samples[channelIndex++], false); } //Set latest scroll position x newestX = args.FirstSampleTimeStamp + (double)(sampleBundleCount - 1) / generatorSamplingFrequency; chart.ViewXY.XAxes[0].ScrollPosition = newestX; chart.EndUpdate(); } ``` -------------------------------- ### Construct MeshModel Programmatically (Positions, Texture Coordinates, Bitmap, Indices) Source: https://lightningchart.com/net-charts/docs/inDetail/mesh-model Create a 3D mesh model with vertex positions, texture coordinates, a bitmap for texturing, and optional indices. Texture wrap mode can also be specified. ```javascript const positions = [ { x: 0, y: 0, z: 0 }, { x: 1, y: 0, z: 0 }, { x: 0, y: 1, z: 0 } ]; const textureCoordinates = [ { u: 0, v: 0 }, { u: 1, v: 0 }, { u: 0, v: 1 } ]; const bitmap = new Bitmap("path/to/texture.png"); const indices = [0, 1, 2]; const meshModel = MeshModel.create(positions, textureCoordinates, bitmap, TextureWrapMode.Repeat, indices); ``` -------------------------------- ### Configure X Axis Scrolling Gap Source: https://lightningchart.com/net-charts/docs/inDetail/axis-class-properties Defines the gap in percentage of graph width before continuous scrolling begins in 'Scrolling' mode. A gap of 0 means scrolling starts immediately when the scroll position reaches the end. ```javascript chart.ViewXY.XAxes[0].ScrollingGap = 15; ``` -------------------------------- ### Set GPU Preference Source: https://lightningchart.com/net-charts/docs/beginners%20guide/chart-render-options Configure GPU usage for systems with multiple graphics adapters. Defaults to SystemSetting. ```javascript chart.ChartRenderOptions.GPUPreference = GPUPreference.SystemSetting; ``` -------------------------------- ### Nested BeginUpdate/EndUpdate Calls Source: https://lightningchart.com/net-charts/docs/inDetail/updating-chart Demonstrates how nested BeginUpdate() and EndUpdate() calls allow for multiple batch updates within a single redraw cycle. This is useful for organizing updates across different methods. ```csharp void MainMethod() { chart.BeginUpdate(); chart.Title.Text = “My title”; chart.ViewXY.XAxes[0].AxisColor = Colors.Red; UpdateSeriesColors(); chart.EndUpdate(); // Repaints only once. } private void buttonCreate_Click(object sender, EventArgs e) { UpdateSeriesColors(); // Repaints only once } void UpdateSeriesColors() { chart.BeginUpdate(); foreach(PointLineSeries series in chart.ViewXY.PointLineSeries) { series.LineStyle.Color = Color.Yellow; } chart.EndUpdate(); } ``` -------------------------------- ### Set Date Origin for Axis Source: https://lightningchart.com/net-charts/docs/inDetail/axis-class-properties Configures the starting point for date and time values on an axis. This is crucial for accurate date-based charting. You can set the origin using a DateTime object or individual year, month, and day properties. ```csharp xAxis.SetDateOrigin(new DateTime(2019, 12, 17)); // or xAxis.DateOriginYear = 2019; xAxis.DateOriginMonth = 12; xAxis.DateOriginDay = 17; ```