Comments (13)
the empty space is not caused by the axis, it is caused by the series, notice all the series have a blank distance between the start of the axis and the first point of the series.
Series.DataPadding
should do the trick, docs are not ready yet, but you can try something like:
new LineSeries<int>
{
Values = new []{ 1, 5, 4, 2, 7, 4, 6, 8 },
DataPadding = new System.Drawing.PointF(0, 1)
}
for both X
and Y
axes: 0
means nothing, 1
means the Axis tick
, an Axis tick
is the distance between the labels in the axis (even if there are not visible labels, the tick is calculated).
from livecharts2.
@beto-rodriguez thank you. It's works great. And thank for continuing the project.
from livecharts2.
I have also seen this issue, I am not sure yet, but I think this is an Avalonia issue.
The problem is when the chart clears the canvas with a transparent color, Avalonia has not drawn anything behind our chart control, then we get this result.
The workaround I built for the library, is that based on the Background color of the chart I pull a color to clear the canvas:
This is the workaround, and it is not working in your case because it was not able to build a color from null
, just set a color for now, or open an issue in Avalonia, I am not completely sure yet, but I am almost sure that the issue is theirs.
https://github.com/beto-rodriguez/LiveCharts2/blob/master/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs#L325
from livecharts2.
@beto-rodriguez
I would wantn't to open a new issue, but i have a question.
I set Background="{x:Null}" for CartesianChart to achieve a background of my window, but the CartesianChart is ignoring backround of the window and becomes completely transparent. I need to get the translucent, black background.
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
xmlns:cm="using:AvaloniaTest"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaTest.MainWindow" Title="AvaloniaTest" TransparencyLevelHint="AcrylicBlur" Background="{x:Null}">
<Window.DataContext>
<cm:ChartModel />
</Window.DataContext>
<Grid>
<Rectangle Fill="Black" Stroke="Black" Opacity="0.7" />
<lvc:CartesianChart Series="{Binding Series}" XAxes="{Binding YAxis}"
YAxes="{Binding XAxis}" IsHitTestVisible="False"
Background="{x:Null}">
</lvc:CartesianChart>
</Grid>
</Window>
Without CartesianChart
With CartesianChart
from livecharts2.
Thanks for answered. I solved the problem by setting a color with alpha-canal.
CartesianChart cartesianChart = this.FindControl<CartesianChart>("CartesianChart");
cartesianChart.Background = new SolidColorBrush(new Color(128,0, 0, 0));
from livecharts2.
@beto-rodriguez, sorry. I have one more question.
I'm using LiveChart 2 for real time chart and watching a memory leak and increasing cpu load.
I'm add a new ObservablePoint and remove a first in a ObservableCollection every second.
Should i somehow clearing CartesianChart or do some other an actions for to free the memory?
from livecharts2.
it should be handled automatically by tue library, let me try to reproduce
from livecharts2.
Thanks for the report again @FanIT I found 2 issues, one that was affecting all the platforms, and another one that was an Avalonia specific issue, you were facing both in your case.
Please let me know if everything is working properly now.
fixed somewhere in 387892f
from livecharts2.
I builded LiveChartsCore.SkiaSharpView.dll and LiveChartsCore.SkiaSharpView.Avalonia.dll from fresh source code and tested with JetBrains dotMemory.
I still watching a memory leak.
Total used:
Start - 51.4 mb
10 minutes - 80.9 mb
20 minutes - 114.3 mb
30 minutes - 150.8 mb
40 minutes - 180.5 mb
50 minutes - 215.6 mb
End - Total used 291.7 mb, Heap generation 2 - 235 mb.
Maybe i'm doing something wrong?
I can provide my test code or any required data.
My chart model.
class ChartModel
{
private Random random;
private int index = 0;
public ObservableCollection<ObservablePoint> observableValues { get; set; }
public ChartModel()
{
random = new Random();
observableValues = new();
for (byte b = 0; b < 50; b++)
{
observableValues.Add(new ObservablePoint(index++, b));
}
Series = new ObservableCollection<ISeries>
{
new LineSeries<ObservablePoint>
{
Values = observableValues,
Fill = new SolidColorPaintTask(SKColors.Blue),
Stroke = null,
GeometryFill = null,
GeometryStroke = null,
DataPadding = new PointF(0, 1)
}
};
}
public void Add()
{
observableValues.RemoveAt(0);
observableValues.Add(new ObservablePoint(index++, random.NextDouble()));
}
public ObservableCollection<ISeries> Series { get; set; }
public List<Axis> XAxis { get; set; } = new List<Axis>
{
new Axis
{
IsVisible = false
}
};
public List<Axis> YAxis { get; set; } = new List<Axis>
{
new Axis
{
IsVisible = false
}
};
}
from livecharts2.
OK I'll keep investigating.
from livecharts2.
@FanIT How are you calling the Add
method, I just tested the AvaloniaSample
project, in the lines AutomaticUpdates
sample, just clicked on "Constant changes", this sample is similar to the code you shared, I see no memory leak after 30 mins running.
I will let it more time running, and will document my results here, but at first instance I think that the issue is gone.
from livecharts2.
50 mins running, no memory leak found, tested with dot memory 2021.1
from livecharts2.
Many thanks you and sorry. Probably the problem was in Avalonia. I updated to Avalonia 0.10.4 and no longer see the memory leak.
I'm calling Add in DispatcherTimer of Avalonia.Threading a every second.
Avalonia.Threading.DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += (object? sender, EventArgs e) => { chart.Add(); };
timer.Start();
I tested 1 hour and every 10 minutes doing snapshot.
from livecharts2.
Related Issues (20)
- custom point of Label of RectangularSection
- Livechart width doesn't autofit in Listview HOT 1
- Column/Bars MinWidth
- how to draw a color between two line?
- How to make DrawMarginFrame only show left and bottom borders?
- ChartPointPointerDown event issue with scatter series
- https://blazor-livecharts.controli.app/ TLS cert expired.
- LiveChartsCore.SkiaSharpView.Uno.WinUI causes build issue in Uno 5.3.90 HOT 1
- maui livecharts not working .net7
- The operation of the ScrollViewer container
- Scatter Series geometry size calculation - option to consider all series
- Enhanced Flexibility for Legend Positioning
- Making LegendPosition not hidden for CartesianChart causes crash in Avalonia HOT 1
- Classic Tooltips
- Does not work HOT 2
- How do I integrate User Control? HOT 1
- How do I make it work? HOT 1
- in desk chinese characters work well,but in browser (wasm) chinese become square HOT 4
- Chart was unable to show up correctly while using WPF sample.
- License Issue and Password Recovery Assistance Needed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from livecharts2.