Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use WPF Chart LiveChart

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the "WPF Chart LiveChart how to use" related knowledge, Xiaobian through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope this "WPF Chart LiveChart how to use" article can help you solve the problem.

Import LiveChart.Wpf

NuGet searches for the LiveChart package and installs LiveChart.Wpf.

Quote LiveChart.Wpf

Reference LiveChart.Wpf 's class library in the interface you are using

Xmlns:lvc= "clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"

For example, histograms and broken lines belong to a type of Series under CartesianChart, such as line charts, as follows:

LinSeries binding data can be set to Values. If you can see it with s, it means that it is a plural collection type, which is inherited from IChartValues, so the final bound data conforms to ChartValues. The following figure binds a collection of numeric types:

The interface appears as follows:

Next, take LineSeries as an example to expand and add the definition display of X and Y coordinates.

Add a title to the X and Y axes of LiveChart

The effect is as follows:

Chart display Settings

1. Where the legend is displayed: LegendLocation= "Top" / / shown at the top

two。 Background color of the chart: Background= "# FFEFD5"

As follows:

3. Add visual element: VisualElements

Add a text to the chart as follows:

Hello!, this is a note merged in the chart.

Display effect:

LineSeries style settin

1. Line display value: DataLabels= "True"

two。 Whether the line is bent: LineSmoothness= "0" or "1"

3. Color of lines: Stroke= "Red" / / sets the color of lines to red

4. Color below the line: Fill= "Pink" / / the color below the line

5. Each point of the line: PointGeometrySize= "20" / / sets the data point size

6. Display data font color: Foreground= "Red"

7. Color of the data point: PointForeground= "# FF6347"

8. Line dotted line: the larger the StrokeDashArray= "5" / / value, the larger the interval, as shown in the green dotted line

9. The shape of the bar point: PointGeometry / / as shown below, set to a rectangle for the data point

The effect is as follows:

X, Y coordinate style settin

1. Whether to display coordinate points: ShowLabels= "False"

two。 Rotation angle of coordinate points: LabelsRotation= "45"

3. Axis label: Labels= "A, B, C, D, E, F" / / example

4. Custom display format: LabelFormatter

Whether the chart shows background X and Y lines:

The following code sets a solid red line with a width of 1 on the X and Y axes:

The effect is as follows:

Define pie chart

Since the pie chart does not have the concept of X and Y axes, if you need to use a pie chart, use PieChart.

1. Set the format of the display data: LabelPoint / / the binding is a Func delegate

Xaml binding:

Background code and display effect:

This is the end of the introduction to "how to use WPF Chart LiveChart". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report