Scale #13
Replies: 2 comments
-
Development Log: I pushed Scale notably farther, resetting quite a bit of the earlier implementation to work more cleanly with a declarative style usage, while still maintaining the convenience methods for imperative usage. The top level of what's now I also created discrete scales - for grouping from category values ( To support using the scales in an incrementally more configured fashion (basic setup -> add config -> fully configured and usable), the implementations default to returning Still to do with scales that we'll want for supporting chart:
In addition, there might be notable value in adding a quantizing scale, specifically to use to break a color range into quantized segments to use as category or ordinal style indicators, and as soon as Color scales are baseline enabled, that'll beg the development of color schemes, which likely fit best within Scale as well. Three different kinds of schemes are in common use - diverging schemes (gradient or quantized with a clear center value), gradient schemes (including quantized), and categorical schemes (all contrasting values). |
Beta Was this translation helpful? Give feedback.
-
With the scale implementations in Chart, I've found a few places where things are working quite as smoothly as I'd hoped, and I have a sort of lingering, pending quandary to resolve. The first involves using Marks with independent data, but in the same chart. It seems to beg the question of if the domains for the scales involved in rendering those marks should be independent or if there should be a means to merge them. Within any specific scale, we can do that - but when you start mixing scales (discrete scales for bar charts vs. continuous scales for line or scatterplot like charts) it gets awkward. The scale implementations support updating a domain, but discrete and continuous work extremely differently - so there's likely no way to really merge those together in any meaningful way. The second is this idea of "ticks". Right now there's a protocol TickScale which is sort of a 'mixin' concept to Scale (on the Continuous Scales anyway) that allows two operations:
While the set of ticks, and their labels can be determined when the domain is completely set, the specific locations can't be fully identified until a range value is available so that we can interpolate where they should be displayed. I just simplified the Tick implementation (with swiftviz/Scale#20), but I'm wondering if the implementation isn't implemented correctly. Right now it's all built over continuous scales, but there's a need for the discrete scales (Band and Point) to provide ticks there as well. In the discrete cases, every value of the domain is a default case, and the labels should match the center of the area being provided (I think...) - so maybe it makes sense to just include "ticks" into the results of a scale more generally. In the case of "band" scales, the band itself might include the tick. I'm uncertain (from this close distance) if I'm coupling things too closely, too loosely, of if there's a better design that would make more sense. |
Beta Was this translation helpful? Give feedback.
-
Scale
While working on VisualChannel, after adding the relevant dependency, I started to add in the
property for a scale and realized the generics need to be aligned:
A scale has an InputType and OutputType - and we need InputType to match
PropertyType
from above. And OutputType should probably just be CGFloat since we'll be using it in that context.Since the property types could be one of Double, Date, Int, or String - we need scales that take all of those kinds of values as input types so that we can appropriately constrain the generics.
The two "OutputTypes" that are relevant for our use cases are "CGFloat" for drawing stuff in a
GraphicsContext
andColor
- or some color representation anyway - that can be converted or cast into to a SwiftUI color instance. Since we're doing CoreGraphics dependencies anyway, then maybeCGColor
.Added issue https://github.com/swiftviz/SwiftViz/issues/11, with the color pieces partially noted earlier as an improvement in https://github.com/swiftviz/SwiftViz/issues/8 as well.
Beta Was this translation helpful? Give feedback.
All reactions