WPF 自定义控件完成库容表盘显示效果

先看一下显示效果:

       需要注意的地方有以下几点:

  1. 表盘的刻度分部,长刻度和短刻度显示。
  2. 在数值80W时,需要更改刻度盘的颜色渐变。
  3. 在数值80W时,更改库容总数背景的显示,也是颜色渐变。刻度盘控件属性定义:

刻度盘的定义:

using Microsoft.Expression.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;namespace Dashboard_Demo
{/// <summary>/// 刻度盘控件/// </summary>/// <remarks>add by zhidanfeng 2017.2.19</remarks>[TemplatePart(Name = "PART_IncreaseCircle", Type = typeof(Arc))]public class Dashboard : Control{private Arc PART_IncreaseCircle;/// <summary>/// 保存角度变化前的角度值(用于动画)/// </summary>private double OldAngle;#region Constructorsstatic Dashboard(){DefaultStyleKeyProperty.OverrideMetadata(typeof(Dashboard), new FrameworkPropertyMetadata(typeof(Dashboard)));}#endregion#region 依赖属性#region Angle 刻度盘起始角度/// <summary>/// 刻度盘起始角度依赖属性/// </summary>public static readonly DependencyProperty StartAngleProperty =DependencyProperty.Register("StartAngle",typeof(double),typeof(Dashboard),new PropertyMetadata(0d));/// <summary>/// 刻度盘起始角度/// </summary>public double StartAngle{get { return (double)GetValue(StartAngleProperty); }set { SetValue(StartAngleProperty, value); }}#endregion#region Angle 刻度盘结束角度依赖属性/// <summary>/// 刻度盘结束角度依赖属性/// </summary>public static readonly DependencyProperty EndAngleProperty =DependencyProperty.Register("EndAngle",typeof(double),typeof(Dashboard),new PropertyMetadata(0d));/// <summary>/// 刻度盘结束角度依赖属性/// </summary>public double EndAngle{get { return (double)GetValue(EndAngleProperty); }set{SetValue(EndAngleProperty, value);}}#endregion#region Minimum 最小值/// <summary>/// 最小值依赖属性,用于Binding/// </summary>public static readonly DependencyProperty MinimumProperty =DependencyProperty.Register("Minimum",typeof(double),typeof(Dashboard),new PropertyMetadata(0.0));/// <summary>/// 获取或设置最小值./// </summary>/// <value>最小值.</value>public double Minimum{get { return (double)GetValue(MinimumProperty); }set { SetValue(MinimumProperty, value); }}#endregion#region Maximum 最大值/// <summary>/// 最大值依赖属性,用于Binding/// </summary>public static readonly DependencyProperty MaximumProperty =DependencyProperty.Register("Maximum",typeof(double),typeof(Dashboard),new PropertyMetadata(100.0));/// <summary>/// 获取或设置最大值./// </summary>/// <value>最大值.</value>public double Maximum{get { return (double)GetValue(MaximumProperty); }set { SetValue(MaximumProperty, value); }}#endregion#region Value 当前值/// <summary>/// 最大值依赖属性,用于Binding/// </summary>public static readonly DependencyProperty ValueProperty =DependencyProperty.Register("Value",typeof(double),typeof(Dashboard),new PropertyMetadata(0.0, new PropertyChangedCallback(OnValuePropertyChanged)));/// <summary>/// 获取或设置当前值/// </summary>public double Value{get{if (PART_IncreaseCircle == null)return (double)GetValue(ValueProperty);if ((double)GetValue(ValueProperty) > 800000d){LinearGradientBrush brush = new LinearGradientBrush();brush.StartPoint = new Point(0, 0);brush.EndPoint = new Point(1, 0);brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#f0b046"), 0));brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#e83a2d"), 1));PART_IncreaseCircle.Stroke = brush;}else{LinearGradientBrush brush = new LinearGradientBrush();brush.StartPoint = new Point(0, 0);brush.EndPoint = new Point(1, 0);brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#1ccabd"), 0));brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#458ffc"), 1));PART_IncreaseCircle.Stroke = brush;}return (double)GetValue(ValueProperty);}set { SetValue(ValueProperty, value); }}private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){Dashboard dashboard = d as Dashboard;dashboard.OldAngle = dashboard.Angle;dashboard.SetAngle();dashboard.TransformAngle();}#endregion#region LongTickCount 长刻度个数public static readonly DependencyProperty LongTickCountProperty =DependencyProperty.Register("LongTickCount",typeof(int),typeof(Dashboard),new PropertyMetadata(5));/// <summary>/// 获取或设置长刻度个数,用于设置刻度盘显示几个长刻度/// </summary>public int LongTickCount{get { return (int)GetValue(LongTickCountProperty); }set { SetValue(LongTickCountProperty, value); }}#endregion#region ShortTickCount 短刻度个数public static readonly DependencyProperty ShortTickCountProperty =DependencyProperty.Register("ShortTickCount",typeof(int),typeof(Dashboard),new PropertyMetadata(3));/// <summary>/// 获取或设置两个长刻度之间的短刻度的个数/// </summary>public int ShortTickCount{get { return (int)GetValue(ShortTickCountProperty); }set { SetValue(ShortTickCountProperty, value); }}#endregion#region TickDurtion 刻度改变时的动画显示时长public static readonly DependencyProperty TickDurtionProperty = DependencyProperty.Register("TickDurtion", typeof(Duration), typeof(Dashboard),new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(400))));/// <summary>/// 刻度改变时的动画显示时长/// </summary>public Duration TickDurtion{get { return (Duration)GetValue(TickDurtionProperty); }set { SetValue(TickDurtionProperty, value); }}#endregion#region ShortTicksBrush 短刻度颜色public static readonly DependencyProperty ShortTicksBrushProperty = DependencyProperty.Register("ShortTicksBrush", typeof(Brush), typeof(Dashboard));/// <summary>/// 短刻度颜色/// </summary>public Brush ShortTicksBrush{get { return (Brush)GetValue(ShortTicksBrushProperty); }set { SetValue(ShortTicksBrushProperty, value); }}#endregion#region LongTicksBrush 长刻度颜色public static readonly DependencyProperty LongTicksBrushProperty = DependencyProperty.Register("LongTicksBrush", typeof(Brush), typeof(Dashboard));/// <summary>/// 长刻度颜色/// </summary>public Brush LongTicksBrush{get { return (Brush)GetValue(LongTicksBrushProperty); }set { SetValue(LongTicksBrushProperty, value); }}#endregion#region Contentpublic object Content{get { return (object)GetValue(ContentProperty); }set { SetValue(ContentProperty, value); }}public static readonly DependencyProperty ContentProperty =DependencyProperty.Register("Content", typeof(object), typeof(Dashboard));#endregion#region ContentTemplatepublic DataTemplate ContentTemplate{get { return (DataTemplate)GetValue(ContentTemplateProperty); }set { SetValue(ContentTemplateProperty, value); }}public static readonly DependencyProperty ContentTemplateProperty =DependencyProperty.Register("ContentTemplate", typeof(DataTemplate), typeof(Dashboard));#endregion#endregion#region Private依赖属性#region Angle 刻度盘当前值所对应的角度/// <summary>/// 刻度盘当前值所对应的角度依赖属性/// </summary>public static readonly DependencyProperty AngleProperty =DependencyProperty.Register("Angle",typeof(double),typeof(Dashboard),new PropertyMetadata(0d));/// <summary>/// 刻度盘当前值所对应的角度/// </summary>public double Angle{get { return (double)GetValue(AngleProperty); }private set { SetValue(AngleProperty, value); }}#endregion#region ShortTicks 短刻度线集合/// <summary>/// 短刻度线依赖属性,用于Binding/// </summary>public static readonly DependencyProperty ShortTicksProperty =DependencyProperty.Register("ShortTicks",typeof(IList<object>),typeof(Dashboard),new PropertyMetadata(null));/// <summary>/// 获取或设置短刻度线,用于绑定PathListBox的ItemsSource/// </summary>/// <value>短刻度线.</value>public IList<object> ShortTicks{get { return (IList<object>)GetValue(ShortTicksProperty); }private set { SetValue(ShortTicksProperty, value); }}#endregion#region LongTicks 长刻度线集合/// <summary>/// 长刻度线依赖属性,用于Binding/// </summary>public static readonly DependencyProperty LongTicksProperty =DependencyProperty.Register("LongTicks",typeof(IList<object>),typeof(Dashboard),new PropertyMetadata(null));/// <summary>/// 获取或设置长刻度线,用于绑定PathListBox的ItemsSource/// </summary>/// <value>长刻度线.</value>public IList<object> LongTicks{get { return (IList<object>)GetValue(LongTicksProperty); }private set { SetValue(LongTicksProperty, value); }}#endregion#region LongTicks 长刻度线上显示的数字/// <summary>/// 长刻度线依赖属性,用于Binding/// </summary>public static readonly DependencyProperty NumberListProperty =DependencyProperty.Register("NumberList",typeof(IList<object>),typeof(Dashboard),new PropertyMetadata(null));/// <summary>/// 获取或设置长刻度线,用于绑定PathListBox的ItemsSource/// </summary>/// <value>长刻度线.</value>public IList<object> NumberList{get { return (IList<object>)GetValue(NumberListProperty); }private set { SetValue(NumberListProperty, value); }}#endregion#endregion#region 重载public override void OnApplyTemplate(){base.OnApplyTemplate();this.PART_IncreaseCircle = GetTemplateChild("PART_IncreaseCircle") as Arc;this.SetTicks();this.SetAngle();this.TransformAngle();}#endregion#region Private方法/// <summary>/// 设置刻度线/// </summary>private void SetTicks(){List<object> numbers = new List<object>();List<object> shortticks = new List<object>();List<object> longticks = new List<object>();for (int i = 0; i < this.LongTickCount; i++){numbers.Add(Math.Round(this.Minimum + (this.Maximum - this.Minimum) / (this.LongTickCount - 1) * i));longticks.Add(new object());}for (int i = 0; i < (this.LongTickCount - 1) * (this.ShortTickCount + 1) + 1; i++){shortticks.Add(new object());}this.ShortTicks = shortticks;this.LongTicks = longticks;this.NumberList = numbers;}/// <summary>/// 根据当前值设置圆弧的EndAngle/// </summary>private void SetAngle(){if (this.Value < this.Minimum){this.Angle = this.StartAngle;return;}if (this.Value > this.Maximum){this.Angle = this.EndAngle;return;}var diff = this.Maximum - this.Minimum;var valueDiff = this.Value - this.Minimum;this.Angle = this.StartAngle + (this.EndAngle - this.StartAngle) / diff * valueDiff;}/// <summary>/// 角度值变化动画/// </summary>private void TransformAngle(){if (this.PART_IncreaseCircle != null){DoubleAnimation doubleAnimation = new DoubleAnimation(this.OldAngle, this.Angle, this.TickDurtion);this.PART_IncreaseCircle.BeginAnimation(Arc.EndAngleProperty, doubleAnimation);}}#endregion}
}

设置刻度盘的style:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"xmlns:ec="http://schemas.microsoft.com/expression/2010/controls" xmlns:local ="clr-namespace:Dashboard_Demo"><!--  流量盘  --><ControlTemplate x:Key="Flow" TargetType="{x:Type local:Dashboard}"><Grid><!--  刻度盘完整圆弧  --><ed:Arc x:Name="DoubleCircle" Margin="50" ArcThickness="3" ArcThicknessUnit="Pixel"EndAngle="{TemplateBinding EndAngle}"SnapsToDevicePixels="True"StartAngle="{TemplateBinding StartAngle}"Stretch="None" Stroke="#002266" Opacity="0.16" StrokeThickness="3" UseLayoutRounding="True" /><!--  刻度盘当前值对应的圆弧  --><ed:Arc x:Name="PART_IncreaseCircle" Margin="50" ArcThickness="3" ArcThicknessUnit="Pixel"RenderTransformOrigin="0.5,0.5"StartAngle="{TemplateBinding StartAngle}"Stretch="None"  StrokeThickness="3" /><!--  短刻度  --><ec:PathListBox x:Name="ShoartTick" IsHitTestVisible="False"ItemsSource="{TemplateBinding ShortTicks}"><ec:PathListBox.ItemTemplate><DataTemplate><Border Width="1" Height="8"Background="{Binding ShortTicksBrush,RelativeSource={RelativeSource AncestorType={x:Type local:Dashboard}}}"SnapsToDevicePixels="True" UseLayoutRounding="False" /></DataTemplate></ec:PathListBox.ItemTemplate><ec:PathListBox.LayoutPaths><ec:LayoutPath Distribution="Even" Orientation="OrientToPath"SourceElement="{Binding ElementName=ShortTickPath}" /></ec:PathListBox.LayoutPaths></ec:PathListBox><!--  长刻度  --><ec:PathListBox x:Name="LongTick" IsHitTestVisible="False"ItemsSource="{TemplateBinding LongTicks}"><ec:PathListBox.ItemTemplate><DataTemplate><Border Width="1" Height="13"Background="{Binding LongTicksBrush,RelativeSource={RelativeSource AncestorType={x:Type local:Dashboard}}}"SnapsToDevicePixels="True" UseLayoutRounding="False" /></DataTemplate></ec:PathListBox.ItemTemplate><ec:PathListBox.LayoutPaths><ec:LayoutPath Distribution="Even" Orientation="OrientToPath"SourceElement="{Binding ElementName=LongTickPath}" /></ec:PathListBox.LayoutPaths></ec:PathListBox><!--  刻度上显示的数字  --><ec:PathListBox x:Name="Number" IsHitTestVisible="False"ItemsSource="{TemplateBinding NumberList}"><ec:PathListBox.ItemTemplate><DataTemplate><TextBlock RenderTransformOrigin="0.5,0.5" Text="{Binding}"></TextBlock></DataTemplate></ec:PathListBox.ItemTemplate><ec:PathListBox.LayoutPaths><ec:LayoutPath Distribution="Even" Orientation="OrientToPath"SourceElement="{Binding ElementName=NumberPath}" /></ec:PathListBox.LayoutPaths></ec:PathListBox><!--#region 路径--><ed:Arc x:Name="ShortTickPath" Margin="30" ArcThickness="0" ArcThicknessUnit="Pixel"EndAngle="{TemplateBinding EndAngle}"StartAngle="{TemplateBinding StartAngle}"Stretch="None" /><ed:Arc x:Name="LongTickPath" Margin="25" ArcThickness="0" ArcThicknessUnit="Pixel"EndAngle="{TemplateBinding EndAngle}"StartAngle="{TemplateBinding StartAngle}"Stretch="None" /><ed:Arc x:Name="NumberPath" Margin="10" ArcThickness="0" ArcThicknessUnit="Pixel"EndAngle="{TemplateBinding EndAngle}"StartAngle="{TemplateBinding StartAngle}"Stretch="None" /><!--#endregion--><ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" /></Grid></ControlTemplate><DataTemplate x:Key="DefaultLabelPanel" x:Shared="False"><Border Width="70" Margin="0,0,0,20" HorizontalAlignment="Center" VerticalAlignment="Bottom"BorderBrush="#00A0FB" BorderThickness="1" CornerRadius="3" Padding="0,2"SnapsToDevicePixels="True" UseLayoutRounding="True"><TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Agency FB" Foreground="White"Text="{Binding Path=Value,StringFormat={}{0:N1}KW,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:Dashboard}}}" /></Border></DataTemplate><Style TargetType="{x:Type local:Dashboard}"><Setter Property="StartAngle" Value="-140" /><Setter Property="EndAngle" Value="140" /><Setter Property="Foreground" Value="#929093" /><Setter Property="BorderBrush" Value="#746E7A" /><Setter Property="ShortTicksBrush" Value="#746E7A" /><Setter Property="LongTicksBrush" Value="#746E7A" /><Setter Property="Template" Value="{StaticResource Flow}" /><Setter Property="ContentTemplate" Value="{StaticResource DefaultLabelPanel}" /></Style><LinearGradientBrush x:Key="LargeArcCenterBackground" StartPoint="0.0,0" EndPoint="0,1"><GradientStop Color="#d84a36" Offset="0"/><GradientStop Color="#ec7c6c" Offset="1"/></LinearGradientBrush><LinearGradientBrush x:Key="LargeOutArcBackground" StartPoint="0.0,0" EndPoint="0,1"><GradientStop Color="#e2aaa3" Offset="0"/><GradientStop Color="#e4b4ac" Offset="1"/></LinearGradientBrush><LinearGradientBrush x:Key="LargeBorderArcBackground" StartPoint="0.0,0" EndPoint="0,1"><GradientStop Color="#e3d5d3" Offset="0"/><GradientStop Color="#e4d8d6" Offset="1"/></LinearGradientBrush><LinearGradientBrush x:Key="SmallArcCenterBackground" StartPoint="0.0,0" EndPoint="0,1"><GradientStop Color="#389cfa" Offset="0"/><GradientStop Color="#73b8fd" Offset="1"/></LinearGradientBrush><LinearGradientBrush x:Key="SmallOutArcBackground" StartPoint="0.0,0" EndPoint="0,1" Opacity="0.4"><GradientStop Color="#389AfC" Offset="0"/><GradientStop Color="#78AEFC" Offset="1"/></LinearGradientBrush><LinearGradientBrush x:Key="SmallBorderArcBackground" StartPoint="0.0,0" EndPoint="0,1" Opacity="0.1"><GradientStop Color="#389AfC" Offset="0"/><GradientStop Color="#78AEFC" Offset="1"/></LinearGradientBrush>
</ResourceDictionary>
  • 库容总数背景渐变实现:
  • <DataTemplate x:Key="Small"><Grid Margin="0,110,0,0" HorizontalAlignment="Center"><Ellipse x:Name="ellipse1" Width="166" Height="166" Fill="{StaticResource SmallBorderArcBackground}" Margin="0 -43" VerticalAlignment="Top"/><Ellipse x:Name="ellipse2" Width="147" Height="147" Fill="{StaticResource SmallOutArcBackground}" Margin="0 -33" VerticalAlignment="Top"/><Ellipse x:Name="ellipse3" Width="133" Height="133" Fill="{StaticResource SmallArcCenterBackground}" Margin="0 -25" VerticalAlignment="Top"/><TextBlock Margin="0,30" HorizontalAlignment="Center" FontSize="24" Foreground="White" FontWeight="Bold"Text="{Binding Path=Value,StringFormat={}{0:N0},ElementName=dashboard1}" /></Grid></DataTemplate><DataTemplate x:Key="Large"><Grid Margin="0,110,0,0" HorizontalAlignment="Center"><Ellipse x:Name="ellipse1" Width="166" Height="166" Fill="{StaticResource LargeBorderArcBackground}" Margin="0 -43" VerticalAlignment="Top"/><Ellipse x:Name="ellipse2" Width="147" Height="147" Fill="{StaticResource LargeOutArcBackground}" Margin="0 -33" VerticalAlignment="Top"/><Ellipse x:Name="ellipse3" Width="133" Height="133" Fill="{StaticResource LargeArcCenterBackground}" Margin="0 -25" VerticalAlignment="Top"/><TextBlock Margin="0,30" HorizontalAlignment="Center" FontSize="24" Foreground="White" FontWeight="Bold"Text="{Binding Path=Value,StringFormat={}{0:N0},ElementName=dashboard1}" /></Grid></DataTemplate>

    实现效果(低于80W):

  • 高于80W时显示:

  • csdn下载地址:https://download.csdn.net/download/chulijun3107/88058570

  • github:GitHub - chulijun3107/Dashboard_Demo: WPF userControl

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/3079.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

HarmonyOS课程体验官招募(第四期),寻找乐于分享,精益求精的伙伴

华为开发者联盟HarmonyOS课程体验官&#xff08;第四期&#xff09;活动&#xff0c;开始招募啦&#xff01; 如果你精益求精、乐于分享&#xff1b;如果你愿意为学堂课程优化改进出谋划策&#xff0c;那就快来加入我们吧&#xff01;学堂期待与你共同成长、一起进步&#xff0…

11、动手学深度学习——语言模型和数据集:代码详解

我们了解了如何将文本数据映射为词元&#xff0c;以及将这些词元可以视为一系列离散的观测&#xff0c;例如单词或字符。 假设长度为 T T T的文本序列中的词元依次为 x 1 , x 2 , … , x T x_1, x_2, \ldots, x_T x1​,x2​,…,xT​。于是&#xff0c; x t x_t xt​&#xff08…

如何在Linux中配置网络?

在 Linux 中配置网络可以通过多种方式进行&#xff0c;以下是其中几种常见的方法&#xff1a; 使用网络管理工具&#xff1a; 大多数常见的 Linux 发行版都提供了图形界面的网络管理工具&#xff0c;如 NetworkManager 或 systemd-networkd。这些工具通常集成在系统设置&#x…

git常用命令汇总

git init: 初始化一个新的Git仓库。在项目目录中执行该命令&#xff0c;将创建一个空的Git仓库&#xff0c;用于版本控制。git clone <repository>: 克隆&#xff08;Clone&#xff09;一个远程仓库到本地。将远程仓库的代码完整地复制到本地&#xff0c;可以是一个公共的…

GPT与人类:人工智能是否能够真正复制人类语言?

人类语言是一种复杂的系统&#xff0c;它不仅包含着无数单词和语法规则&#xff0c;更重要的是具有丰富的含义和上下文。这些语言特征涉及到常识、文化、情感和经验等方面&#xff0c;是人类在长期进化和文明发展中所积累起来的丰富知识和经验的体现。然而&#xff0c;人工智能…

C/C++学习资料推荐

语言学习 C程序设计语言&#xff08; Dennis M. Ritchie 和Brian W. Kernighan&#xff09; C语言程序设计现代方法 C陷阱与缺陷 C Primer &#xff08;这本书是久负盛名的 C 经典教程。书是有点厚&#xff0c;前面 1/3 讲 C 语言&#xff0c;后面讲 C。C 的知识点实在是太多了…

ThreadLocal---线程Thread的局部变量

什么是ThreadLocal? 1、前言 在学习ThreadLocal之前&#xff0c;我们需要先确认一个事情&#xff0c;就是客户端发送的每次http请求&#xff0c;对应的在服务端都会分配一个新的线程来处理&#xff0c;在处理过程中涉及到下面类中的方法都属于相同的一个线程: LoginCheckFi…

SpringCloud学习路线(7)—— 统一网关Gateway

一、引言 &#xff08;一&#xff09;需求&#xff1a; 服务器中的微服务只允许内部人员调用或是内网人员进行调用&#xff0c;拒绝外网人员访问。 &#xff08;二&#xff09;如何实现需求&#xff1f; 网关 &#xff08;三&#xff09;网关的功能 身份认证和权限校验服务…

TJUACM假期集训个人赛(八)(cf789a-c cf791a-c)

这场打一半回宿舍有点事润了&#xff0c;态度不端正&#xff0c;下次改正 A. Anastasia and pebbles 题面 签到题&#xff0c;枚举每类石头即可&#xff0c; w a wa wa了一次因为判断错了&#xff0c;分两天取是 > k >k >k,不是 ≥ k \ge k ≥k #include<bits/s…

uniapp scroll-view滑到底部加载更多数据

官网 必须设置下面两个属性 1. scroll-y"true" 2. height:90vh; //lowerBottom触底事件 <scroll-view scrolltolower"lowerBottom" style"height:90vh;" scroll-y"true">//list:展示的数据<view class"list" v-f…

java线上故障排查套路总结

线上故障主要会包括cpu、磁盘、内存以及网络问题&#xff0c;而大多数故障可能会包含不止一个层面的问题&#xff0c;所以进行排查时候尽量四个方面依次排查一遍。同时例如jstack、jmap等工具也是不囿于一个方面的问题的&#xff0c;基本上出问题就是df、free、top 三连&#x…

Principle Component Analysis

简述PCA的计算过程 输入&#xff1a;数据集X{x1&#xff0c;x2&#xff0c;...&#xff0c;xn}&#xff0c;需降到k维 ① 去中心化&#xff08;去均值&#xff0c;即每个特征减去各自的均值&#xff09; ② 计算协方差矩阵1/nX*X^T&#xff08;1/n不影响特征向量&#xff09…

day39-Oracle分区表

0目录 Oracle分区表 1.2.3 1. Oracle分区表 1.1 作用&#xff1a; Oracle数据库的分区把表中的数据行按照分区划成几个区域&#xff0c;提高大数据量下表的性能 1.2 应用场景&#xff1a;常应用于数据量大的表 1.3 分类&#xff1a;Oracle中有范围分区&#xff08;最常见…

vue使用docxtemplater导出word实现使用textarea输入的内容换行

注:本文只做导出word并且换行操作&#xff0c;不做vue引入docxtemplater步骤 先看一下实现效果 这是文本域输入的 这是导出来的结果 可以看出来导出来的结果也是换行的呢 接下来我们手摸手操作一下流程 首先咱们捋一捋思路 知道文本域的换行的换行标识符&#xff0c;我们发…

[深度学习入门]什么是神经网络?[神经网络的架构、工作、激活函数]

目录 一、前言二、神经网络的架构——以手写数字识别三、神经网络的工作1、单输入单输出感知器函数2、二维输入参数3、三维输入参数 四、激活函数1、激活函数2、ReLU激活函数3、非线性激活函数&#xff08;1&#xff09;二输入二输出的神经网络的架构&#xff08;2&#xff09;…

基于预测控制模型的自适应巡航控制仿真与机器人实现(Matlab代码实现)

目录 &#x1f4a5;1 概述 &#x1f4da;2 运行结果 &#x1f389;3 参考文献 &#x1f468;‍&#x1f4bb;4 Matlab代码 &#x1f4a5;1 概述 自适应巡航控制技术为目前由于汽车保有量不断增长而带来的行车安全、驾驶舒适性及交通拥堵等问题提供了一条有效的解决途径&am…

数据结构(王道)——数据结构之 二叉树的存储结构

一、顺序存储 静态顺序存储 顺序存储的二叉树结构特性&#xff1a; 顺序存储的非完全二叉树特性 不完全二叉树的可能会浪费大量空间&#xff0c;所以一般顺序存储二叉树比较少用。 图示为什么很少用顺序存储来存二叉树 顺序存储的二叉树总结&#xff1a; 二、链式存储 二叉链表…

TCP的三次握手过程

TCP 是面向连接的协议&#xff0c;所以使用 TCP 前必须先建立连接&#xff0c;而建立连接是通过三次握手来进行的。三次握手的过程如下图&#xff1a; 刚开始客户端处于 closed 的状态&#xff0c;服务端处于 listen 状态。 第一次握手&#xff1a;客户端给服务端发一个 SYN 报…

Jest单元测试(二)

Jest 使用匹配器 新建 using-matchers.test.js 测试文件 普通匹配 - toEqual // using-matchers.test.js// toBe 使用 Object.is 来测试精确相等 test(two plus two is four, () > {expect(2 2).toBe(4); });// 如果您想要检查对象的值&#xff0c;请使用 toEqual, toEq…

stb_image简单使用

简介stb_image stb_image 是一个非常轻量级的、单文件的图像加载库&#xff0c;用于加载和解码多种图像格式&#xff08;如BMP、JPEG、PNG、GIF等&#xff09;的图像数据。它由Sean T. Barrett开发&#xff0c;并以公共领域&#xff08;Public Domain&#xff09;许可发布&…