FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

When panning with AreaSeries, the area is displayed strangely · Issue #2104 · oxyplot/oxyplot · GitHub

Repository navigation

When panning with AreaSeries, the area is displayed strangely #2104

Description

Steps to reproduce

1.Create WPF Application, And code this
MainWindow.xaml

<Window x:Class="OxyPlotAreaSeriesProbrem.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        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:local="clr-namespace:OxyPlotAreaSeriesProbrem"
        xmlns:oxy="http://oxyplot.org/wpf"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="450">
    <Grid>
        <oxy:PlotView x:Name="ThisPlot" Background="Transparent">
        </oxy:PlotView>
    </Grid>
</Window>

MainWindow.xaml.cs

using OxyPlot.Axes;
using OxyPlot.Series;
using OxyPlot;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OxyPlotAreaSeriesProbrem
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            ThisPlot.Model = new PlotModel();
            ThisPlot.Model.PlotType = PlotType.Cartesian;
            ThisPlot.Model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, MajorStep = 500.0, MinorStep = 500.0, MajorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColors.Gray, MajorGridlineThickness = 1 });
            ThisPlot.Model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, MajorStep = 500.0, MinorStep = 500.0, MajorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColors.Gray, MajorGridlineThickness = 1 });
            
            var workOutlineSeries = new AreaSeries()
            {
                StrokeThickness = 4,
                LineStyle = LineStyle.Solid,
                Color = OxyColors.Red,
                Color2 = OxyColors.Transparent,
                Fill = OxyColors.LightPink,
                Selectable = false,
            };
            var sqearOutlineSeries = new AreaSeries()
            {
                StrokeThickness = 2,
                LineStyle = LineStyle.Solid,
                Color = OxyColors.LimeGreen,
                Color2 = OxyColors.Transparent,
                Fill = OxyColors.Transparent,
                Selectable = false,
            };
            DataPoint[] work = new DataPoint[]{
                new DataPoint(2254,2740),
                new DataPoint(5028,2873),
                new DataPoint(5709,986),
                new DataPoint(2751,1477),
                new DataPoint(2254,2740),
            };

            workOutlineSeries.Points.AddRange(work);

            DataPoint[] sqear = new DataPoint[]
            {
                new DataPoint (2254,986),
                new DataPoint (2254,2873),
                new DataPoint (5709,2873),
                new DataPoint (5709,986),
                new DataPoint (2254,986),
            };

            sqearOutlineSeries.Points.AddRange(sqear);

            ThisPlot.Model.Series.Add(workOutlineSeries);
            ThisPlot.Model.Series.Add(sqearOutlineSeries);

            ThisPlot.Model.ResetAllAxes();

            ThisPlot.Model.InvalidatePlot(true);
        }
    }
}
  1. Pan until the top right point passes beyond the right side of the plot area.

Platform:
.NET version:windows-8.0
Oxyplot package version:2.2.0

Expected behaviour

The display of the area remains unchanged.

Actual behaviour

The area display is strange. Also, the green line at the bottom disappears.

Activity

  1. VisualMelon commented on Sep 24, 2024

    Contributor

    Looks like the first point is missing some of the time; can't investigate now but first thought is a bug in the monotonicity checks

  2. VisualMelon commented on Sep 24, 2024

    Contributor

    What versions of the oxyplot packages are you using?

  3. SADASHIMA commented on Sep 24, 2024

    Author

    version is 2.2.0

  4. VisualMelon commented on Sep 24, 2024

    Contributor

    Couldn't resist: it is a monotonicity problem: it's the call to this.InternalUpdateMaxMin(this.ActualPoints2); in AreaSeries which is overriding the old monotonicity value: ActualPoints2 defaults to first and last point, and that's throwing everything by making IsXMonotonic always true: behaviour goes away if you force IsXMonotonic to false. Easy if unpleasant fix in InternalUpdateMaxMin to just cache the old IsXMonotonic and && it with the new one; unfortunately the relevant methods are internal so can't be overriden by a consumer.

  5. VisualMelon commented on Sep 24, 2024

    Contributor

    All that said, this is not the intended usage of AreaSeries: AreaSeries expects both Points and Points2 to be populated, and draws an area between them: this is what causes the weird rendering; what you want is a PolygonSeries, which isn't in the library proper, but there is a PR in the works: #2033 - feel free to C&P it and any feedback on the design is welcome.

  6. SADASHIMA commented on Sep 25, 2024

    Author

    Thank you for your answer. I tried PolygonSeries a little bit and this problem did not occur in that case. If PolygonSeries is implemented, it seems that I can do what I want.
    I will close this issue with your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL