Home > Mobile >  How to disable axis labels of line series (cartesian chart)?
How to disable axis labels of line series (cartesian chart)?

Time:11-30

I'm using a lineseries chart from LiveCharts for WPF, How can I remove the values on the side and bottom of the chart to only display the lineseries being updated

Screenshot

<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; }

CodePudding user response:

To disable the labels of an axis, you must define this axis explicitly and then disable the labels by setting Axis.ShowLabels to 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>
  • Related