Giter VIP home page Giter VIP logo

h.oxyplot's Introduction

Language License Build Status

UWP/WinUI/Uno support for latest OxyPlot core library.
It combines the abandoned OxyPlot UWP code with the current WPF code, trying to match the latter as closely as possible in behavior.

Additional features:

  • Dark Theme support

NuGet

NuGet
NuGet
NuGet
NuGet

Install-Package H.OxyPlot.Uno
Install-Package H.OxyPlot.Uno.WinUI
Install-Package H.OxyPlot.Uwp
Install-Package H.OxyPlot.WinUI

Usage

xmlns:oxy="using:OxyPlot"
<oxy:PlotView Model="{Binding Model}"/>

Preview

There's a test application there: https://havendv.github.io/H.OxyPlot/ image

Contacts

h.oxyplot's People

Contributors

dependabot[bot] avatar havendv 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

Watchers

 avatar  avatar  avatar  avatar

h.oxyplot's Issues

Serious memory leak using LineSeries

Steps to reproduce
Create WinUI3 desktop application.
Install OxyPlot.WinUI 0.9.3
Create and bind it to a PlotModel containing a LineSeries
Run a timer that adds one DataPoint every second.
Platform:
.NET version: 6.0

Expected behaviour
No memory leak.

Actual behaviour
Huge memory leak. Was tested side-by-side using Microcharts, which displayed no memory leak.

1

oxyplot/oxyplot#2025

WinUI 3 Desktop compatibility

I'm trying to use H.OxyPlot.WinUI in a WinUI 3 Desktop application. I don't get any errors and all bindings are OK, but the PlotView remains empty. It responds to properties like Height and Background, but it never displays the Model.

Is it too soon to use this package in this environment?

Problem rendering the CategoryAxis

This feature worked correctly under OxyPlot 2.0/UWp

Platform:
H.OxyPlot.WinUI (0.9.16)

Steps to reproduce:
Please see the sample attached.
App2.zip

Expected behaviour:
See the correct rendering under 2.0
IntelligentOneScreenshot17

Question: Is a PlotView/PlotModel suppposed to work in a (filteted) ListView

Describe the bug

I have a couple of objects (each with a PlotModel) in a ListView. This seems to work ok. But as soon as I apply a filter, I get an exception: This PlotModel is already in use by another PlotView control.
I am new to this, but for me it sounds like a PlotView is getting reused without destroying the binding to the previous binding.

Q.: Is this scenario not supposed to work at all? Am I doing something wrong?

In case you need more information, please let me know.

P.S.: Because my project is WinUI 3, i can't say wether this behaviour is different in the original Oxyplot or not

Steps to reproduce the bug

in the xaml:

            <ListView x:Name="FolderListView"
              ItemsSource="{x:Bind ViewModel.Channels, Mode=OneWay}"
                <ListView.ItemTemplate>
                    <DataTemplate x:DataType="vm:chanItem">
                                    <oxy:PlotView Model="{x:Bind Model}" Height="200"/>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

In the ViewModel there is a ObservableCollection:

public ObservableCollection<chanItem> Channels { get { if (hasFilter()) { var flt = getFilter(); return new ObservableCollection<chanItem>(channels.Where(i => i.filter(flt))); } else { return channels; } } }
And the chanItem has oxy:PlotModel Model (I think any Model will do)

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

Platform

WinUI

IDE

Visual Studio 2022

Additional context

No response

Can it be used in android?

Describe the bug

Thank you for porting OxyPlot to UNO!
I've used this great control on UWP, but when I run it with the android emulator the graph doesn't show up, am I doing something wrong?

XAML

<oxy:PlotView Model="{x:Bind Model}"></oxy:PlotView>

CS

public sealed partial class RealtimeLine2 : Page
    {
        public RealtimeLine2()
        {
            this.InitializeComponent();
            this.DataContext = this;
            Model = new PlotModel() { Title = "Simple Example", Subtitle = "using OxyPlot" };
            var series1 = new LineSeries { Title = "温度", MarkerType = MarkerType.Circle, InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline };
            var series2 = new LineSeries { Title = "湿度", MarkerType = MarkerType.Circle, InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline };
            var dateTimeAxis1 = new DateTimeAxis { Title = "Time"};
            Model.Axes.Add(dateTimeAxis1);
            Model.Series.Add(series1);
            Model.Series.Add(series2);

            Random rd = new Random();
            Task.Run(
                async () =>
                {
                    while (true)
                    {
                        series1.Points.Add(DateTimeAxis.CreateDataPoint(DateTime.Now, rd.Next(10, 30)));
                        series2.Points.Add(DateTimeAxis.CreateDataPoint(DateTime.Now, rd.Next(10, 30)));
                        //if (series1.Points.Count > 100)
                        //{
                        //    series1.Points.RemoveAt(0);
                        //    series2.Points.RemoveAt(0);
                        //}
                        Model.InvalidatePlot(true);
                        await Task.Delay(1000);
                    }
                });
        }

        private PlotModel _model;
        public PlotModel Model
        {
            get { return _model; }
            set { _model = value; }
        }
    }

Steps to reproduce the bug

.net6 mobile

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

Platform

Uno

IDE

Visual Studio 2022

Additional context

No response

Uno v5 support

Describe the bug

Hi @HavenDV!
I get the following error by just installing H.OxyPlot.Uno NuGet package on an Uno v5 project.

Project "D:\Andrew.nuget\packages\uno.ui\4.4.13\buildTransitive\net6.0-android30.0\Uno.UI.SourceGenerators.props" was not imported by "D:\Andrew.nuget\packages\uno.ui\4.4.13\buildTransitive\net6.0-android30.0\uno.winui.common.targets" at (17,2), due to the file not existing.

It seems that Uno v4 is supported but v5 is not. Any plans for v5 support?

Steps to reproduce the bug

  1. Create an Uno v5 project.
  2. Install H.OxyPlot.Uno.

Expected behavior

Works on Uno Platform apps.

Screenshots

No response

NuGet package version

No response

Platform

Uno

IDE

Visual Studio 2022-preview

Additional context

No response

Oxyplot PlotView Doesn't Redraw when triggered by System.Timers.Timer (WinUI

Describe the bug

PlotModel.Invalidate(true) fails to update the UI when called from a timer.

  • Plot fails to redraw, and remains frozen
  • The chart will successfully redraw, but only on window resize.
  • This method works for UWP apps

ChartViewModel.cs

{
    [ObservableProperty]
    public PlotModel chartModel = new();
    
    private readonly System.Timers.Timer timer;


    // Data Source
    public SignalGenerator source = new(3,100,10);
    int currentPoint = 0;

    public ChartViewModel()
    {
        // Create chart model
        ChartModel = new PlotModel()
        {
            // ... Just creates a new model
        };

        //start Source data stream (just spits out a sine wave)
        source.Start();


        timer = new System.Timers.Timer(100);
        timer.Elapsed += UpdateSeriesEvent;
        timer.Start();
    }

    public void UpdateSeriesEvent(object sender, System.Timers.ElapsedEventArgs e)()
    {
        // Adds new point to lines series from a data source
        currentPoint++;
        LineSeries data = (LineSeries)ChartModel.Series[0];
        while (data.Points.Count > 100)
        {
            data.Points.RemoveAt(0);
        }

        
        data.Points.Add(new DataPoint(currentPoint, source.Value));
        ChartModel.InvalidatePlot(true);
        ChartModel.ResetAllAxes();
    }
    
}

ChartPage.xaml

<Page
    x:Class="MVVMToolkitTestAPp.Pages.ChartPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MVVMToolkitTestAPp.Pages"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:oxy ="using:OxyPlot"
    xmlns:models="using:MVVMToolkitTestAPp.DataModels"
    mc:Ignorable="d"
    
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Page.DataContext>
        <models:ChartViewModel x:Name="ViewModel"/>
    </Page.DataContext>

    <Grid>
        <oxy:PlotView x:Name="plots" Model="{x:Bind ViewModel.ChartModel}"/>
    </Grid>
</Page>

Steps to reproduce the bug

  1. Create a Blank WinUI Desktop Application
  2. Install H.Oxyplot and MVVM.Toolkit

Expected behavior

PlotView chart area should automatically redraw after Plot.Invalidate() is called

Screenshots

No response

NuGet package version

H.Oxyplot.WinUI 0.9.30

Platform

WinUI

IDE

Visual Studio 2022

Additional context

No response

Axis lines are not drawn

If you make the PlotAreaBorderColor transparent, then you notice that not a single axis line is drawn. Setting an AxislineColor has no effect. This applies to all types, so it is not the same issue as #4. I don't see anyone observing this in the base OxyPlot repo. Here's a screenshot from my sample repo here:

MissingAxes

PointAnnotation doesn't show the Text

Steps to reproduce
The PointAnnotation works under 2.0 but I it doesn't work under 2.1
For example,

public void Annotation(MarkerType shape, OxyColor color, double size, string text, DataPoint position)
{
    var annotation = new PointAnnotation
    {
        Shape = shape,
        Text = text,
        TextColor = color,
        TextHorizontalAlignment = HorizontalAlignment.Center,
        TextVerticalAlignment = VerticalAlignment.Middle,
        TextMargin = 0,
        TextPosition = position,
        FontWeight = FontWeights.Bold,
        Fill = OxyColors.Transparent,
        Stroke = SetTransparency(200, color),
        StrokeThickness = 2,
        Size = size,
        X = position.X,
        Y = position.Y
    };

    Model.Annotations.Add(annotation);
}

To Test it , call

Annotation(MarkerType.Circle, OxyColors.RoyalBlue, 8, "D", new DataPoint(60, 60));

Platform:
.Net 6.0 and WinUI

Expected behaviour
I expected to see a Circle Marker with Letter D inside. However, I only see a Circle with No Text.

If I export it as below , the pdf is correct

public static void ExportToPDF(this PlotModel model, Stream stream, float w = 1050, float h = 350)
{
    OxyPlot.SkiaSharp.PdfExporter pdfExporter = new OxyPlot.SkiaSharp.PdfExporter { Width = w, Height = h };
    stream.SetLength(0);
    pdfExporter.Export(model, stream);
    stream.Flush();
    stream.Close();
}

see the rendered PDF through Skia which suggests the core library is be behaving as expected
TSCO.L.PDF

The output from WinUI
Screenshot 2022-02-08 151819

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.