Giter Site home page Giter Site logo

beto-rodriguez / livecharts2 Goto Github PK

View Code? Open in Web Editor NEW
3.9K 82.0 504.0 55.06 MB

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.

Home Page: https://livecharts.dev

License: MIT License

C# 99.24% HTML 0.33% CSS 0.17% TypeScript 0.03% PowerShell 0.22%
uno chart column-series line-series xamarin avalonia wpf winforms skia skiasharp

livecharts2's People

Contributors

alex4998 avatar ali50m avatar beto-rodriguez avatar btordz avatar chrispulman avatar code-factor avatar dependabot[bot] avatar erichiller avatar ghost1372 avatar heartacker avatar ilang-redler avatar jamsoft avatar jnayee avatar jp2masa avatar kalcey avatar kevin-seiden avatar labuzzmichal avatar marcf12 avatar mithrilman avatar orace avatar pkindruk avatar rafntor avatar raminmjj avatar samohamed avatar senti-mark-monteiro avatar swharden avatar trympet avatar vadimffe avatar wenya90 avatar zottel92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

livecharts2's Issues

Geared Package

Will there be a Geared Package or similiar performance approach for LiveCharts2?

Chart hanging

When data is like on picture.

ftt_chart_changing

Scrolling cause hanging WPF application. Chart trying to zoom and then hang program. Low value is about 5.0*10^-8 like on tip label.

Edit1:

Seems in Axis.cs loops:

for (var i = start; i <= max; i += s)

and

for (var i = start; i <= dataBounds.max; i += s)

cause hanging because variable 's' is in this case very, very small comparing to 'max'

Edit2:

I added before first for loop:
if (max / s > 1000) s = max / 1000;
and before second:
if (dataBounds.max / s > 1000) s = dataBounds.max / 1000;

It works (no hanging), but under high magnification Y axis labels disappear.

Heatseries

Will there be a heatseries chart in livecharts 2, as in livecharts 1?

In livecharts 1 it was not possible to set the heatseries items fill with a custom mapper, only by gradient stop collection.
To handle this with a custom mapper would be a great feature!

[WPF] Columns from ColumnSeries disappear from chart if Y axis is zoomed too much

User cant set MaxLimit on Y axis below particular level, otherwise columns are not visible.

Steps to reproduce the behavior:

  1. Add ColumnSeries and Y axis to the chart
        public IEnumerable<ISeries> Series { get; set; } = new ObservableCollection<ISeries>
        {
            new ColumnSeries<double>
            {
                
                Values = new ObservableCollection<double> { 5,6,7,8,5,6,7,8 },       
            }
        };

        public List<Axis> YAxes { get; set; } = new List<Axis>
        {
            new Axis
            {
                IsVisible = true,
                MaxLimit = 20,
                MinLimit = 0,
                ShowSeparatorLines = false,

            }
        };
  1. Add function allowing you to change MaxLimit
        public void Zoom()
        {
            YAxes[0].MaxLimit *= 0.8;
        }
  1. Columns should be visible
    image

  2. Call Zoom function several times. Columns shrink and disappear
    image

Expected behavior
Changing MaxLimit should not affect columns visibility

Desktop (please complete the following information):

  • OS: Windows 10 PRO
  • Version beta 10 WPF

Disable Animation

When plotting real time data fast the animation makes the plot hard to follow. IE if you change the wait duration of the autoupdate example to 100 ms the left hand side of the chart goes squirrely and it is difficult to get a good reading on the values being plotted.

Ideally there would be a feature to disable animation or set the animation time to 0.

What time will v2 released on nuget?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Installation

Describe the bug

What the recommended way of consuming this library at the moment? I can't seem to find any NuGets and the solution doesn't build at the moment. It's looking for C:\Users\beto ...

I think all the other build errors are due to this one.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Win 10
  • Browser [e.g. chrome, safari] FF

Is there a way to force the max and min range, like it use to be in LiveCharts?

Hi,
I have been using LiveCharts and trying to move to v2.
One problem I have is, I have a RowSeries chart with multiple series. I need to set Max and Min Range on it so that when values change and chart is updated, it doesn't adjusts the X or Y Axis, I want it to stay static just the bars to animate and redraw based on the new values. Values can range from -10 to 10 and I don't want to see decimal points.
Anyway that is possible?

regards
azhar

Is LiveCharts2 thread-safe?

I have been playing around with lvcharts2 quite a bit now, and I love the new architecture and changes.

In my application, I am updating the ObservableCollection from a worker thread:

int i = 0;
foreach (var item in points)
{
    ChartValues.Add(new ObservablePoint(i++, item.Value));
}

The most common error I see is related to collecting custom IEnumerables to arrays. Here is an example method (from PathGeometry.cs) which throws an out of bounds exception from the linq ToArray(this IEnumerable obj):

public override void Draw(SkiaSharpDrawingContext context)
{
    var toExecuteCommands = drawingCommands ?? (drawingCommands = commands.ToArray());
    ...
}

I tried fixing it with a simple lock, but it simply pushed the error to another enumeration somewhere else.

Is thread-safety within the scope of LiveCharts2, or are consumers expected to implement their own synchronization?

Gradient/mask on chart

Hi,

I am currently using LiveCharts v0 but its missing possibility to add gradient/mask on chart serie. I would like to accomplish something like this:
image

I know I could accomplish it by dividing my bars into smaller pieces but I believe that adding mask/gradient is much better approach. Is it possible in v2?

Best regards,
Michał

DataLabels do not get updated/removed

Describe the bug
When displaying datalabels and the series changes, the old datalabels won't disappear.

To Reproduce
Steps to reproduce the behavior:

  1. Go to ViewModelsSamples.Pies.AutoUpdate.ViewModel class
  2. Replaces series definition in constructor with
    Series = new ObservableCollection
    {
    new PieSeries { Values = new[] { new ObservableValue(2) }, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Start , DataLabelsPaint = new SolidColorPaintTask(new SKColor(45, 45, 45)), },
    new PieSeries { Values = new[] { new ObservableValue(5) }, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Start , DataLabelsPaint = new SolidColorPaintTask(new SKColor(45, 45, 45)), },
    new PieSeries { Values = new[] { new ObservableValue(3) }, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Start , DataLabelsPaint = new SolidColorPaintTask(new SKColor(45, 45, 45)), },
    new PieSeries { Values = new[] { new ObservableValue(7) }, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Start , DataLabelsPaint = new SolidColorPaintTask(new SKColor(45, 45, 45)), },
    new PieSeries { Values = new[] { new ObservableValue(4) }, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Start , DataLabelsPaint = new SolidColorPaintTask(new SKColor(45, 45, 45)), },
    new PieSeries { Values = new[] { new ObservableValue(3) }, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Start , DataLabelsPaint = new SolidColorPaintTask(new SKColor(45, 45, 45)), }
    };
  3. Go to method AddSeries and replace Series.Add(...) with
    Series.Add(
    new PieSeries { Values = new[] { new ObservableValue(random.Next(1, 10)) }, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Start, DataLabelsPaint = new SolidColorPaintTask(new SKColor(45, 45, 45)), });
  4. Run the WPF sample app -> Pies / AutoUpdate
  5. Click on "Constant changes"

Expected behavior
The datalabels for the series added / changed should adjust to current value, position, disappear, etc.

Screenshots
Start
grafik

After "constant changes"
grafik

Desktop (please complete the following information):

  • OS: Win 10 Pro

Additional context
This is also true for bar series.

Wrong layout in WinForms

Describe the bug
When starting the sample, with the "Axes/DateTimeScaled", the set of dates are not displayed.
It works with WPF... but not with WinForms

To Reproduce
Steps to reproduce the behavior:
Start the WinForms sample and choose "Axes/DateTimeScaled"

Screenshots

image

Legends Push Charts Out Of Visible Area

Describe the bug
Legends push charts out of control visible areas.

To Reproduce
Steps to reproduce the behavior:

  1. add LegendPosition="Top" to a chart.

Expected behavior
Chart should shrink in the view port.

Screenshots
If applicable, add screenshots to help explain your problem.

legendsbug

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 10 Pro

toolbar

It is recommended to add a toolbar in the new version, such as:

LiveCharts

Lazy load data on chart scroll

Is there are a possibility to "lazy load" data on bar/column chart scroll? If no, it would be very nice to have for big amount of positions to be visualized or some instruction how this can be done.

Sorry if this is already implemented. You can then remove this question/feature request.

Here is an example (not really a lazy loading, just to show an idea):

9161EF38-AB3C-4206-BA1A-F8B618F23D5F

Grouped Bar Chart

Hi,

I'm trying to use the grouped column chart. But it doesn't show on the interface after I click a button to display the chart.
Here is the code behind:

public ObservableCollection<ISeries> SeriesCollectionBar { get; set; }

SeriesCollectionBar = new System.Collections.ObjectModel.ObservableCollection<ISeries>();

foreach (DataColumn column in performanceTable.Columns)
{
    SeriesCollectionBar.Add(new ColumnSeries<double>
    {           
        Name = column.ColumnName,
        Values = new ObservableCollection<double> { 2, 4, 6, 1, 7, -2 }
    });
}

I also want to append a new value so I'm doing the following:
SeriesCollectionBar[column.Ordinal].Values.Append(3);
To append, I've declared an extension method as follows:

public static IEnumerable Append(this IEnumerable first, params object[] second)
{
    return first.OfType<object>().Concat(second);
}

The xaml code:
<lvc:CartesianChart Series="{Binding SeriesCollectionBar}"></lvc:CartesianChart>

Any help?

Thanks

Point Geometry

Good day. At some stage I saw an opportunity to set 1. Point Geometry 2. GeometryFill. By Index. Now there is no such possibility. Could you enable this feature?

LiveChartsGeared activator not working

I am trying to activate my license in order to work with the WPF Geared package. My company purchased the 5 seat license pack and I am the only one so far to have problems when I try to get a valid activation key. To give some background I had previously activated a Geared trial when I was evaluating the software to see if we wanted to purchase it.

The steps that I am taking to activate the license are:
-Follow the invite link sent from the purchase account.
-Sign in and download the activator.
-Run the activator and it brings up a webpage that tells me that my code is invalid. There is no information as to why, the page just tells me to try again.
-Attempting to troubleshoot the problem I try copying the part of the URL that looks like a key (xxxx-xxxx...) and pasting it into the activator console.
-I then try a similar thing with the invite code URL. Neither of these attempts work.

The other 2 people on my team had no issues activating their licenses when following these steps, one of them (like me) had previously activated a Geared trial before activating their license.

OS: Win10 pro
Version: 21H1
Build: 19043.1052
Browser: Mozilla FireFox 89.0

candlesticks/high performant line plot

Is your feature request related to a problem? Please describe.
I would like to render million of candlesticks (financial data). Currently it's not possible.

Describe the solution you'd like
Would be nice having this plot type built-in and optimized for high data record count..

Describe alternatives you've considered
In a meanwhile I tried rendering 10k of close price records, but the library is not performing well. Lot's of series are shown. If we were to increase the size to 500k records, this would surely crash my pc..

image

image

Additional context
I am really just looking into high-performant code that would allow to render lots of financial data. Candles and close prices are the basics. Here is the test code I am using:

        int totalPoints = 10_000;
        var sth = DataGen.RandomStockPrices(null, totalPoints);
        var sth2 = sth.Select(s => s.Close).ToList();
        var Series = new ObservableCollection<ISeries>
        {
            new LineSeries<double>
            {
                //Values = new ObservableCollection<double> { 200, 558, 458, 249, 457, 339, 587 },
                Values = sth2,
                Stroke = null,
                GeometrySize = 0,
                GeometryFill = null,
                GeometryStroke = null,
                // Fill = null,
                LineSmoothness = 0,
            },
        };

        var cartesianChart = new CartesianChart
        {
            Series = Series,
            ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X,
            Location = new System.Drawing.Point(0, 0),
            Size = new System.Drawing.Size(50, 50),
            Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
            AnimationsSpeed = TimeSpan.Zero,
        };

Animation, line smoothing are disabled. Zooming-in enabled.. but it's nearly impossible to use the plot.

Issue with chart labels on pan and zoom

I 'm facing an issue in viewing the label list properly in x-axis while using livecharts in wpf. The label list is proper, and before setting I clear the axis too.

The code used is:

EMT_Chart.AxisX.Clear();

int stepSize = 1;

Axis xAxis = new Axis()
{
FontSize = 12,
Separator = new LiveCharts.Wpf.Separator { Step = stepSize, IsEnabled = false },
ShowLabels = true,
Labels = labelList,
LabelsRotation = -90.0
};
EMT_Chart.AxisX.Add(xAxis);

And xaml is as below:

<lvc:CartesianChart x:Name="EMT_Chart"
Series="{Binding Series}"
LegendLocation="Bottom"
Zoom="XY" Pan="XY"/>

Basically on zooming out, the x-axis labels (list of string) are coming in a cyclic fashion which isnt intended. And on zooming in the value and label alignment gets messed up.

Please suggest.

This is the plot without zoom or pan

image

On zooming out or panning to the left the plot x-axis labels starts duplicating in a cyclic fashion only on the start and the plot too doesn't look proper

image

On zooming in or panning the plot x-axis labels and the values are not aligned

image

Customizing area around chart

In LiveCharts v0 there was a problem with creating a border around chart area which will stay between chart and axes. One could do it using AxisSection but it was rather a hack than real solution. Example from v0 could be visible on screen below:
image

Is it going to be supported in v2 ? I would love to have possibility to set something like ChartAreaBorder.
Below example from OxyPlot

image

Best regards,
Michał

p.s. I am testing nuget package and it works like a charm ! :)

[WinForms] tooltips are terribly blinking

Describe the bug
Tooltips are terribly blinking in WinForms demo app. In WPF all are ok.

To Reproduce
Run WinFormsSample, use any chart.

Expected behavior
No blinking on tooltip in WinForms.

Screenshots

LCB.mp4

Desktop (please complete the following information):

  • OS: Win 10 20H2

Cartesian chart zooming loses scale if zoomed in too much

In the Cartesian chart, when zooming in too much, the curve disappears, and zooming out does not bring it back.

To Reproduce

  1. Run the WPFSample (I have not tried with any others).
  2. Click on the Lines/Zoom example.
  3. With Ctrl-Mousewheel, zoom in until only 1 or no data point is still in the visible window.
    The curve disappears.
  4. Now with Ctrl-Mousewheel, zoom out again, try to get the curve back.
    The chart stays blank.

Expected behavior
The curve should not completely disappear. But if it does, at least it should reappear when zooming out.

Screen capture
https://user-images.githubusercontent.com/6622880/117813854-ef0f3a80-b2a6-11eb-8772-03c4b4423aa7.mp4

Desktop:

  • OS: Windows 10
  • Desktop application, WPFSample
  • Version : 70ff67e

Error adding chart to winform:

I created a new Winforms project with .net 5

Added nuget package LiveChartsCore.SkiaSharpView.WinForms, version 2.0.0-beta.14
When trying to add a cartesian chart from the toolbox I get the errror:
Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Constructor on type 'LiveChartsCore.KiaSharpView.Winforms.CartesianChart' not found.

Adding a default legend or motion canvas is possible.
Adding a pie chart gives the same error.

This is in the designer of VS2019

image

The difference between LiveCharts and LiveCharts2

Hi, I am very happy that this project has resumed.
If possible, please explain about the features of version 2 and its roadmap.
Will it be free? I hope this version also uses the MIT license.
thank you.

Answer Geared Package

I do not buy a Geared Package, because when many points on the poin Geometry plot are not visible, when you use scaling and the points become smaller, they appear, although there is no such in your standard plot. Please consider this possibility. Thanks!

[Feature request] StepLine Series

Hi, is LiveCharts2 going to support StepLine Series? I dont see it in a roadmap.
I would love to help with implementation if you are busy with more important stuff

Line Not Appearing on Line Chart

Describe the bug

I have added a CartesianChart to an Avalonia view and wired it up to a LineSeries with a collection of ObservableValues set. This is all working great. However, there is no line being rendered. Just points.

The samples don't seem to be doing anything in particular with styles or themes and the themes doc is empty at the moment. I've tried looking for likely properties or setting on the LineSeries but nothing seems to suggest anyhting related to a line other than LineSmoothness.

I've tried setting Fill but it didn't seem to effect anything in the render.

To Reproduce
Steps to reproduce the behavior:

  1. start a new avalonia app
  2. Add a chat and line series
  3. debug
  4. No line is rendered, only geometry points.

Expected behavior
I would expect a Line series to default to rendering a line.

Screenshots
If applicable, add screenshots to help explain your problem.

missingline

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] n/a

[WPF] Clearing underlying series collection breaks chart

Describe the bug
Calling "Clear" method on ObservableCollection bound to Series Values breaks chart funcationalities

To Reproduce
Steps to reproduce the behavior:

  1. Add LineSeries and Y axis to the chart
            Values = new ObservableCollection<double> { 5, 6, 7, 8, 5, 6, 7, 8 };
            Series = new ObservableCollection<ISeries>
            {
                new LineSeries<double>
                {
                    Values = Values,
                }
            };
            YAxes = new List<Axis>
            {
                new Axis
                {
                    IsVisible = true,
                    MaxLimit = 20,
                    MinLimit = 0,
                    ShowSeparatorLines = false,

                }
            };
  1. Add function allowing you to modify Values
        public void ClearValues()
        {
            Values.Clear();
        }
  1. Line serie should be visible

image

  1. Call Clear method. Whole application hangs and nothing could be clicked

image

  1. Repeat steps above WITHOUT binding YXaxes in chart. Chart is partially clreared but line still stays on chart

image

Expected behavior
Clearing underyling collection shouldn't hang whole application

Desktop (please complete the following information):

  • Windows 10 PRO
  • Beta 10 WPF

Additional context
There seems to be a lot of different problems somehow connected to MinLimit and MaxLimit as well. For example if you dont specify MinLimit in example above you will not see Line Serie

Candlestick Charts

Hello,

You have created a nice project, are there candlestick chart supported?
If not are you willing to implement them?

Keep up the good work,
Thanks

Xamarin.Mac interest?

Hi, great work on v2!

I am working on a Xamarin.Mac implementation. Is there any interest of bringing xamarin.mac controls or skiaview into the project? I already have a crude working implementation.

If so, it would require a separate build target and mac tooling if the API changes (i think). The best solution would probably be to have a LiveCharts2.Mac package.

[WPF] Calling Clear method on underlying empty Series Values change axes limits

Describe the bug
Calling Clear method on empty ObservableCollection bounded to Values property change axes limits

To Reproduce
Steps to reproduce the behavior:

  1. Define CartesianChart in xaml
    <lvc:CartesianChart ZoomMode="None" XAxes="{Binding XAxes}" YAxes="{Binding YAxes}" Series="{Binding Series}" />
  2. Define Series, YAxes and XAxes

            Values = new ObservableCollection<double> { 5, 6, 7, 8, 5, 6, 7, 8 };
            Series = new ObservableCollection<ISeries>
            {
                new ColumnSeries<double>
                {

                    Values = Values,
                }
            };
            YAxes = new List<Axis>
            {
                new Axis
                {
                    IsVisible = true,
                    MaxLimit = 20,
                    MinLimit = 0,
                    ShowSeparatorLines = false,

                }
            };

            XAxes  = new List<Axis>
            {
                new Axis
                {
                    IsVisible = true,
                    MaxLimit = 10,
                    ShowSeparatorLines = false,
                }
            };
  1. Define method allowing you to clear series underlying collection
        public void ClearValues()
        {
            Values.Clear();
        }
  1. Run application. Column series with defined values should be visible
    image

  2. Call ClearValues method several times. With every next Clear the axis change limits even though no data is available

image

Expected behavior
Axis limits shouldn't change if collection didnt change

Desktop (please complete the following information):

  • OS: Windows 10PRO
  • Version: Beta14 WPF

[WPF] [PRISM] Loading PRISM module with livecharts ends up with TDrawingContext being not registered

Describe the bug
When I load prism module with livecharts in my prism application I cant use DrawMarginFrame because its throws "TDrawingContext is not registered" exception

To Reproduce
Steps to reproduce the behavior:

  1. Create Prism application with at least one module (module A)
  2. Add CartesianChart with DrawMarginFrame defined in module A
  3. Load module A dynamicaly in application
  4. See error "TDrawingContext is not registered"

Expected behavior
DrawMarginFrame is possible to use out of the box

Desktop (please complete the following information):

  • OS: Windows 10PRO
  • Version: Beta14 WPF

Additional context
I am not sure whether its Livecharts or Prism issue but there is a workaround available. Exception is raised because there is not Theme defined so calling
LiveChartsSkiaSharp.DefaultPlatformBuilder(LiveChartsCore.LiveCharts.CurrentSettings)
solves the problem. But why isn't it called when the library is loaded dynamicaly ?
Nevertheless maybe its worth to add to documentation section about Livecharts Settings ?

Best regards,
Michal

Tooltip always on top, don't disappear on mouse out

Describe the bug
If you hover over a chart the tooltip will shine through to every application. The tooltip will not disappear on mouse out.

To Reproduce
Steps to reproduce the behavior:

  1. Start the WPFSample
  2. Pies/Basic
  3. Hover over a section of the chart until the tooltip appears
  4. Tap out and move another window above the chart
  5. See the tooltip shine through the window

Expected behavior
The tooltip doesn't appear on other application windows. The tooltip disappears when I leave the chart area.

Screenshots
grafik

Desktop (please complete the following information):

  • OS: Win 10 Pro

How hide labels?

Hello. I want to use LiveChart 2 in Avalonia project. I set IsVisible = false in XAxis and YAxis to hide labels, but now there is empty space. How can i hide it?
Thanks.
Screen

[Feature Request] Nuget Package

Hi, LiveCharts and LiveCharts2 are both very great projects. When will we have nuget package support for LiveCharts2? Thanks.

WPF - Cartesian chart - Performance issue when using DateTimePoints

Describe the bug
I'm using a Cartesian Chart to show a budget graph which is based on points which are only one hour apart. When I zoom in too close into the graph, the application gets stuck.

In the file: 'LiveCharts2-2.0.0-beta.14\src\LiveChartsCore\Axis.cs', Method 'GetPossibleSize' I found that the for loop is responsible for that. The value of s becomes way to small and the loop runs basically forever. Loop signature is: 'for (var i = start; i <= _dataBounds.Max; i += s)'

To Reproduce
Here's the code which I used:
Model initialization

     string DateTimeLabeler(double value)
        {
            DateTime dateTime = new DateTime((long)value);
            return $"{dateTime.ToString("dd.MM.yyyy HH:mm:ss")}";
        }
		
        void InitChart()
        {
            XAxes = new List<Axis>();
            YAxes = new List<Axis>();

            Axis xAxis = new Axis();
			xAxis.Labeler = DateTimeLabeler;
            XAxes.Add(xAxis);

            Axis yAxis = new Axis();
            yAxis.Labeler = (value) => Labelers.FormatCurrency(value, ".", "3", "Eupo");
            YAxes.Add(yAxis);

            DateTimeValues = new ObservableCollection<DateTimePoint>();
            DateTime start = DateTime.Now;
            DateTime current = start;
            
            for (int i = 0; i < 100; i++)
            {
                // Using AddSeconds instead of AddHours seems to make issues even worse
                current = current.AddHours(1);
                DateTimeValues.Add(new DateTimePoint(current, Randomizer.r.Next(5, 100)));
            }

            xAxis.LabelsRotation = -20;

            LineSeries< DateTimePoint > lines = new LineSeries<DateTimePoint>();
            lines.Values = DateTimeValues;

            lines.DataLabelsSize = 0;

            lines.Fill = null;
            Series = new ObservableCollection<ISeries> { lines };

            lines.Stroke = new SolidColorPaintTask(new SKColor(200, 100, 5))
            {
                StrokeThickness = 3
            };
        }		

XAML:

            <lc:CartesianChart Name="chart" Grid.Row="1" Series="{Binding Path=Series}" ZoomMode="X" 
                            XAxes="{Binding XAxes}" YAxes="{Binding Path=YAxes}"></lc:CartesianChart>

Expected behavior

  • Of course, my application shouldn't hang in an "endless loop".
  • Besides that, as Feature Request it would be nice to be able to specify a maximum zoom level (could also be a quick workaround for this issue). I mention this, because i noticed that labels start to overlap. At least with my quick bugfix below.

Desktop (please complete the following information):

  • OS: Windows
  • WPF
  • 10 something something

Additional context
Quick bugfix used during testing
To make sure I identified the correct place where the performance issue arises I added these lines right above the for-loop mentioned above to limit the amount of iterations:

            double max = _dataBounds.Max / 100000;
            s = Math.Max(s, max);
            System.Diagnostics.Debug.WriteLine("Count: " + _dataBounds.Max / s);

This has "fixed" it, but is definitelly not the right way to go. I guess the way s is calculated by the Tick function could need some improvement. But I didn't have time to dig too deep into this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.