Skip to content

Conversation

@AppPear
Copy link
Owner

@AppPear AppPear commented Sep 14, 2022

feat: new protocol for chained functions, and added support for explicit Y ranges. X coming as well

@AppPear AppPear force-pushed the feat/new-protocol-and-range branch from 3202ac9 to b48b701 Compare September 29, 2022 17:05

var values: [String] {
data.map { $0.0 }
var values: [Double] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is very subjective but even when I started looking at the code it took me tiny bit of time to which axis these points and values are referring to. I would propose to use rather xData and yData instead of points and values.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave it points and values as not every chart has yValues (circle graphs so it wouldn't make sense there)

}

var normalisedYRange: Double {
if let _ = rangeY {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think could be rewritten as "one-liner"

rangeY == nil
        ? (normalisedPoints.max() ?? 0.0) - (normalisedPoints.min() ?? 0.0)
        : 1

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

if gridOptions.showBaseLine {
ChartGridBaseShape()
.stroke(gridOptions.color, style: gridOptions.baseStrokeStyle)
.rotationEffect(.degrees(180), anchor: .center)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not very clear why we need to do rotation by 180 degrees here. It seems it's just flipped, or not? In other words, is it necessary?

Group {
ChartGridShape(numberOfHorizontalLines: 5, numberOfVerticalLines: 0)
.stroke()
.rotationEffect(.degrees(180), anchor: .center)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also seems that these rotations are not necessary here. When I comment them the preview stays the same. But maybe I am just missing something important.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think I got it. Are you trying to get x and y axis to be the same as you would intuitively expect? As in, point (0.0) is not top left corner but you want it to be lower left?

I think padding of line .rotation3DEffect(.degrees(180), axis: (x: 0, y: 1, z: 0)) is not correct.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Group {
MarkerShape(data: [(0, 0), (0.25, 0.5), (0.5,0.8), (0.75, 0.6), (1, 1)])
.stroke()
.rotationEffect(.degrees(180), anchor: .center)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would put it into View extension as it's keep being used on many places. Maybe something like this?

extension View {
    func toStandardCoordinateSystem() -> some View {
        self
            .rotationEffect(.degrees(180), anchor: .center)
            .rotation3DEffect(.degrees(180), axis: (x: 0, y: 1, z: 0))
    }
}

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

@AppPear AppPear force-pushed the feat/new-protocol-and-range branch from 2a52e35 to f426dba Compare October 24, 2022 14:07
@AppPear AppPear merged commit ebaaf81 into new-version Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants