ChartsOrg / ChartsOrg/Charts

DataApproximator.reduceWithDouglasPeuker not keeping first item in 3.3.0

Open
#4,003 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

* [x ] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## What did you do?

Called DataApproximator.reduceWithDouglasPeuker with array of CGPoints.

## What did you expect to happen?

Keep the first item in the list, data reduce some data, keep the last item in the list.
Resulting array from test below with 3.2.0 code:
[0] CGPoint (x = 0, y = 3)
[1] CGPoint (x = 1, y = 3)
[2] CGPoint (x = 5, y = 6)

## What happened instead?

Resulting array from test below with 3.3.0:
[0] CGPoint (x = 2, y = 4)
[1] CGPoint (x = 3, y = 5)
[2] CGPoint (x = 4, y = 5)

## Charts Environment

**Charts version/Branch/Commit Number:**
3.3.0 Release/Master

**Xcode version:**
10.1
**Swift version:**
Swift 4.2
**Platform(s) running Charts:**
iOS
**macOS version running Xcode:**
10.14.4

## Demo Project

func testReducedBurnRates() {
self.viewModel = IntervalMapViewModel(console: console, type: .activeMap, scheduler: scheduler)

let data: [CGPoint] = [
CGPoint(x: 0, y: 3),
CGPoint(x: 1, y: 3),
CGPoint(x: 2, y: 4),
CGPoint(x: 3, y: 5),
CGPoint(x: 4, y: 5),
CGPoint(x: 5, y: 6)]

var points = DataApproximator.reduceWithDouglasPeuker(data, tolerance: 0.5)

XCTAssertGreaterThan(points.count, 2)
XCTAssertEqual(points[0], CGPoint(x: 0, y: 3))
XCTAssertEqual(points[points.count - 1], CGPoint(x: 5, y: 6))
}

Contributor guide

Open the contributing guide

Research direction

Start by locating DataApproximator.reduceWithDouglasPeuker and compare its 3.3.0 behavior with the expected 3.2.0 result described in the issue. Use the supplied test data and tolerance of 0.5; done means the reduced array keeps the first and last CGPoint while reducing intermediate data.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.