You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I edit the view model implementation of Axes/Shared example in the project.
Moving or zooming the chart would probably left ghost labels painted.
Code for ViewModel.cs:
usingSkiaSharp;usingLiveChartsCore;usingLiveChartsCore.SkiaSharpView;usingLiveChartsCore.SkiaSharpView.Painting;usingLiveChartsCore.Drawing;usingLiveChartsCore.Measure;usingSystem;usingSystem.Linq;usingLiveChartsCore.Defaults;usingSystem.Threading.Tasks;usingSystem.Collections.ObjectModel;namespaceWpfApp{publicclassViewModel{publicISeries[]SeriesCollection1{get;set;}publicISeries[]SeriesCollection2{get;set;}publicAxis[]X1{get;set;}publicAxis[]X2{get;set;}publicMarginDrawMargin{get;set;}publicViewModel(){varvalues1=newObservableCollection<ObservablePoint>(Fetch().Take(3));varvalues2=Fetch();SeriesCollection1=newISeries[]{newScatterSeries<ObservablePoint>{Values=values1,DataLabelsPaint=newSolidColorPaint(SKColors.Black,1f),DataLabelsFormatter= i =>$"Value: {i.Model.X}",Stroke=newSolidColorPaint(SKColors.Red,1f),EasingFunction=null,AnimationsSpeed=TimeSpan.Zero,Fill=null,GeometrySize=4}};SeriesCollection2=newISeries[]{newColumnSeries<ObservablePoint>{Values=values2}};// ideally, when sharing an axis, you should set the // mark// initial limits for all the axes involved. // markvarpadding=3;varstart=0-padding;varend=values1.Count-1+padding;X1=newAxis[]{newAxis{MinLimit=start,MaxLimit=end,CrosshairLabelsBackground=SKColors.OrangeRed.AsLvcColor(),CrosshairLabelsPaint=newSolidColorPaint(SKColors.White),CrosshairPaint=newSolidColorPaint(SKColors.OrangeRed.WithAlpha(50),4),CrosshairPadding=newPadding(8),Labeler= value =>value.ToString("N2")}};X2=newAxis[]{newAxis{MinLimit=start,MaxLimit=end,CrosshairPaint=newSolidColorPaint(SKColors.OrangeRed.WithAlpha(50),4)}};SharedAxes.Set(X1[0],X2[0]);// Force the chart to use 70px margin on the left, this way we can align both charts Y axes. // markDrawMargin=newMargin(70,Margin.Auto,Margin.Auto,Margin.Auto);// Advanced alternative:// you can also ask an axis its posible dimensions to determine the margin you need.// First you need to get a chart from the UI// in this sample we use the in-memory chart provided by the library.// var cartesianChart = new SKCartesianChart();// var axis = cartesianChart.YAxes.First() as Axis;// var size = axis.GetPossibleSize(cartesianChart.Core);// finally instead of using the static 70px, we can use the actual width of the axis.// DrawMargin = new Margin(size.Width, Margin.Auto, Margin.Auto, Margin.Auto);// normally you would need measure all the axes involved, and use the greater width to// calculate the required margin.Task.Run(async()=>{varr=newRandom();while(true){awaitTask.Delay(100);values1[0]=newObservablePoint{X=r.NextDouble()*10,Y=r.NextDouble()*10,};}});}privatestaticObservablePoint[]Fetch(){varvalues=newObservablePoint[50];varr=newRandom();for(vari=0;i<50;i++)values[i]=newObservablePoint{X=r.NextDouble()*10,Y=r.NextDouble()*10};returnvalues;}}}
The text was updated successfully, but these errors were encountered:
c0nstexpr
changed the title
Reassign Element in Series Values Get Ghost Label
Reassign Element in Series Values Get Ghost Labels
Dec 10, 2024
c0nstexpr
changed the title
Reassign Element in Series Values Get Ghost Labels
Reassign Element of Series Values Collection Get Ghost Labels
Dec 10, 2024
I edit the view model implementation of Axes/Shared example in the project.
Moving or zooming the chart would probably left ghost labels painted.
Code for
ViewModel.cs
:The text was updated successfully, but these errors were encountered: