我正在使用 LiveCharts for WPF 中的线系列图表,如何删除图表侧面和底部的值以仅显示正在更新的线系列
<lvc:CartesianChart
x:Name="chrtCPU"
Width="250"
Height="55"
Foreground="#13192F"
LegendLocation="None">
<lvc:CartesianChart.Series>
<lvc:LineSeries LineSmoothness="0"
AreaLimit="15000" Values="{Binding Values}" />
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
Values = new GearedValues<double>().WithQuality(Quality.High);
var sw = new Stopwatch();
sw.Start();
Action readFromTread = () =>
{
while (true)
{
var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", Environment.MachineName);
cpuCounter.NextValue();
Thread.Sleep(500);
//we add the lecture based on our StopWatch instance
var first = Values.DefaultIfEmpty(0).FirstOrDefault();
if (Values.Count > keepRecords - 1) Values.Remove(first);
if (Values.Count < keepRecords) Values.Add(cpuCounter.NextValue());
}
};
Task.Factory.StartNew(readFromTread);
DataContext = this;
public GearedValues<double> Values { get; set; }
要禁用轴的标签,您必须显式定义该轴,然后通过将
Axis.ShowLabels
设置为 false
来禁用标签:
<lvc:CartesianChart>
<lvc:CartesianChart.Series>
<lvc:LineSeries Values="{Binding Values}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisX>
<lvc:Axis ShowLabels="False" />
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis ShowLabels="False" />
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>