Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove map_id, add sym_x and sym_y #148

Merged
merged 11 commits into from
Jun 15, 2020
265 changes: 44 additions & 221 deletions docs/examples/jupyter-notebooks-dev/livemap/pie_bar_on_livemap.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ class LiveMap : PlotConfigDemoBase() {
{
"geom":"livemap",
"mapping":{
"map_id":"lonlat",
"x":"x",
"y":"y",
"color":"label"
},
"display_mode":"point",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ class Aes<T> private constructor(val name: String, val isNumeric: Boolean = true
val COLOR: Aes<Color> = Aes("color", false)
val FILL: Aes<Color> = Aes("fill", false)
val ALPHA: Aes<Double> = Aes("alpha")
val SHAPE: Aes<PointShape> =
Aes("shape", false)
val LINETYPE: Aes<LineType> =
Aes("linetype", false)
val SHAPE: Aes<PointShape> = Aes("shape", false)
val LINETYPE: Aes<LineType> = Aes("linetype", false)

val SIZE: Aes<Double> = Aes("size")
val WIDTH: Aes<Double> = Aes("width")
Expand All @@ -58,7 +56,6 @@ class Aes<T> private constructor(val name: String, val isNumeric: Boolean = true
val XEND: Aes<Double> = Aes("xend")
val YEND: Aes<Double> = Aes("yend")

val MAP_ID: Aes<Any> = Aes("map_id", false)
val FRAME: Aes<String> = Aes("frame", false)

val SPEED: Aes<Double> = Aes("speed")
Expand All @@ -76,6 +73,9 @@ class Aes<T> private constructor(val name: String, val isNumeric: Boolean = true

val ANGLE: Aes<Double> = Aes("angle")

val SYM_X: Aes<Double> = Aes("sym_x")
val SYM_Y: Aes<Double> = Aes("sym_y")


fun numeric(unfiltered: Iterable<Aes<*>>): Iterable<Aes<Double>> {
// safe to cast all 'numeric' aesthetics are 'Double'
Expand Down Expand Up @@ -135,8 +135,7 @@ class Aes<T> private constructor(val name: String, val isNumeric: Boolean = true
}

fun noGuideNeeded(aes: Aes<*>): Boolean {
return aes == MAP_ID ||
aes == FRAME ||
return aes == FRAME ||
aes == SPEED ||
aes == FLOW ||
aes == LABEL ||
Expand All @@ -148,6 +147,8 @@ class Aes<T> private constructor(val name: String, val isNumeric: Boolean = true
aes == ANGLE ||
aes == FAMILY ||
aes == FONTFACE ||
aes == SYM_X ||
aes == SYM_Y ||
isPositional(aes)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ interface DataPointAesthetics {

fun upper(): Double?

fun mapId(): Any

fun frame(): String

fun speed(): Double?
Expand All @@ -82,6 +80,10 @@ interface DataPointAesthetics {

fun angle(): Double?

fun symX(): Double?

fun symY(): Double?

fun group(): Int?

fun numeric(aes: Aes<Double>): Double?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ object GeomMeta {
Aes.COLOR,
Aes.FILL,
Aes.ALPHA,
Aes.SHAPE,
Aes.MAP_ID
Aes.SHAPE
// strokeWidth
)

Expand All @@ -40,7 +39,6 @@ object GeomMeta {
Aes.LINETYPE,
Aes.COLOR,
Aes.ALPHA,
Aes.MAP_ID,
Aes.SPEED,
Aes.FLOW
)
Expand All @@ -51,8 +49,7 @@ object GeomMeta {
Aes.LINETYPE,
Aes.COLOR,
Aes.FILL,
Aes.ALPHA,
Aes.MAP_ID
Aes.ALPHA
)

private val AREA = listOf(
Expand Down Expand Up @@ -167,8 +164,7 @@ object GeomMeta {
Aes.LINETYPE,
Aes.COLOR,
Aes.FILL,
Aes.ALPHA,
Aes.MAP_ID
Aes.ALPHA
)

GeomKind.AB_LINE -> listOf(
Expand Down Expand Up @@ -237,8 +233,7 @@ object GeomMeta {
Aes.LINETYPE,
Aes.COLOR,
Aes.FILL,
Aes.ALPHA,
Aes.MAP_ID
Aes.ALPHA
)

GeomKind.SEGMENT -> listOf(
Expand All @@ -262,20 +257,20 @@ object GeomMeta {
Aes.FONTFACE,
Aes.HJUST,
Aes.VJUST,
Aes.ANGLE,
Aes.MAP_ID
Aes.ANGLE
)

GeomKind.LIVE_MAP -> listOf( // ToDo: not static - depends on 'display mode'
Aes.MAP_ID,
Aes.ALPHA,
Aes.COLOR,
Aes.FILL,
Aes.SIZE,
Aes.SHAPE,
Aes.FRAME,
Aes.X,
Aes.Y
Aes.Y,
Aes.SYM_X,
Aes.SYM_Y
)

GeomKind.RASTER -> listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import jetbrains.datalore.plot.base.Aes.Companion.INTERCEPT
import jetbrains.datalore.plot.base.Aes.Companion.LABEL
import jetbrains.datalore.plot.base.Aes.Companion.LINETYPE
import jetbrains.datalore.plot.base.Aes.Companion.LOWER
import jetbrains.datalore.plot.base.Aes.Companion.MAP_ID
import jetbrains.datalore.plot.base.Aes.Companion.MIDDLE
import jetbrains.datalore.plot.base.Aes.Companion.SHAPE
import jetbrains.datalore.plot.base.Aes.Companion.SIZE
import jetbrains.datalore.plot.base.Aes.Companion.SLOPE
import jetbrains.datalore.plot.base.Aes.Companion.SPEED
import jetbrains.datalore.plot.base.Aes.Companion.SYM_X
import jetbrains.datalore.plot.base.Aes.Companion.SYM_Y
import jetbrains.datalore.plot.base.Aes.Companion.UPPER
import jetbrains.datalore.plot.base.Aes.Companion.VJUST
import jetbrains.datalore.plot.base.Aes.Companion.WEIGHT
Expand Down Expand Up @@ -73,7 +74,6 @@ object AesInitValue {
VALUE_MAP[LOWER] = Double.NaN
VALUE_MAP[MIDDLE] = Double.NaN
VALUE_MAP[UPPER] = Double.NaN
VALUE_MAP[MAP_ID] = "empty map_id"
VALUE_MAP[FRAME] = "empty frame"
VALUE_MAP[SPEED] = 10.0
VALUE_MAP[FLOW] = 0.1
Expand All @@ -87,6 +87,8 @@ object AesInitValue {
VALUE_MAP[HJUST] = 0.5 // 'middle'
VALUE_MAP[VJUST] = 0.5 // 'middle'
VALUE_MAP[ANGLE] = 0.0
VALUE_MAP[SYM_X] = 0.0
VALUE_MAP[SYM_Y] = 0.0
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import jetbrains.datalore.plot.base.Aes.Companion.INTERCEPT
import jetbrains.datalore.plot.base.Aes.Companion.LABEL
import jetbrains.datalore.plot.base.Aes.Companion.LINETYPE
import jetbrains.datalore.plot.base.Aes.Companion.LOWER
import jetbrains.datalore.plot.base.Aes.Companion.MAP_ID
import jetbrains.datalore.plot.base.Aes.Companion.MIDDLE
import jetbrains.datalore.plot.base.Aes.Companion.SHAPE
import jetbrains.datalore.plot.base.Aes.Companion.SIZE
import jetbrains.datalore.plot.base.Aes.Companion.SLOPE
import jetbrains.datalore.plot.base.Aes.Companion.SPEED
import jetbrains.datalore.plot.base.Aes.Companion.SYM_X
import jetbrains.datalore.plot.base.Aes.Companion.SYM_Y
import jetbrains.datalore.plot.base.Aes.Companion.UPPER
import jetbrains.datalore.plot.base.Aes.Companion.VJUST
import jetbrains.datalore.plot.base.Aes.Companion.WEIGHT
Expand Down Expand Up @@ -125,9 +126,6 @@ abstract class AesVisitor<T> {
if (aes == UPPER) {
return upper()
}
if (aes == MAP_ID) {
return mapId()
}
if (aes == FRAME) {
return frame()
}
Expand Down Expand Up @@ -168,6 +166,14 @@ abstract class AesVisitor<T> {
return angle()
}

if (aes == SYM_X) {
return symX()
}

if (aes == SYM_Y) {
return symY()
}

throw IllegalArgumentException("Unexpected aes: $aes")
}

Expand Down Expand Up @@ -213,8 +219,6 @@ abstract class AesVisitor<T> {

protected abstract fun upper(): T

protected abstract fun mapId(): T

protected abstract fun frame(): T

protected abstract fun speed(): T
Expand All @@ -240,4 +244,8 @@ abstract class AesVisitor<T> {
protected abstract fun vjust(): T

protected abstract fun angle(): T

protected abstract fun symX(): T

protected abstract fun symY(): T
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ import jetbrains.datalore.plot.base.Aes.Companion.INTERCEPT
import jetbrains.datalore.plot.base.Aes.Companion.LABEL
import jetbrains.datalore.plot.base.Aes.Companion.LINETYPE
import jetbrains.datalore.plot.base.Aes.Companion.LOWER
import jetbrains.datalore.plot.base.Aes.Companion.MAP_ID
import jetbrains.datalore.plot.base.Aes.Companion.MIDDLE
import jetbrains.datalore.plot.base.Aes.Companion.SHAPE
import jetbrains.datalore.plot.base.Aes.Companion.SIZE
import jetbrains.datalore.plot.base.Aes.Companion.SLOPE
import jetbrains.datalore.plot.base.Aes.Companion.SPEED
import jetbrains.datalore.plot.base.Aes.Companion.SYM_X
import jetbrains.datalore.plot.base.Aes.Companion.SYM_Y
import jetbrains.datalore.plot.base.Aes.Companion.UPPER
import jetbrains.datalore.plot.base.Aes.Companion.VJUST
import jetbrains.datalore.plot.base.Aes.Companion.WEIGHT
Expand Down Expand Up @@ -123,10 +124,6 @@ class AestheticsBuilder @JvmOverloads constructor(private var myDataPointCount:
return aes(WEIGHT, v)
}

fun mapId(v: (Int) -> Any?): AestheticsBuilder {
return aes(MAP_ID, v)
}

fun frame(v: (Int) -> String?): AestheticsBuilder {
return aes(FRAME, v)
}
Expand Down Expand Up @@ -184,6 +181,14 @@ class AestheticsBuilder @JvmOverloads constructor(private var myDataPointCount:
return aes(YMAX, v)
}

fun symX(v: (Int) -> Double?): AestheticsBuilder {
return aes(SYM_X, v)
}

fun symY(v: (Int) -> Double?): AestheticsBuilder {
return aes(SYM_Y, v)
}

fun <T> constantAes(aes: Aes<T>, v: T): AestheticsBuilder {
myConstantAes.add(aes)
myIndexFunctionMap[aes] = constant(v)
Expand Down Expand Up @@ -438,10 +443,6 @@ class AestheticsBuilder @JvmOverloads constructor(private var myDataPointCount:
return get(UPPER)
}

override fun mapId(): Any {
return get(MAP_ID)
}

override fun frame(): String {
return get(FRAME)
}
Expand Down Expand Up @@ -494,6 +495,14 @@ class AestheticsBuilder @JvmOverloads constructor(private var myDataPointCount:
return get(ANGLE)
}

override fun symX(): Double? {
return get(SYM_X)
}

override fun symY(): Double? {
return get(SYM_Y)
}

override fun group(): Int? {
return myAesthetics.group(myIndex!!)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ open class AestheticsDefaults {
return crossBar()
}

fun livemap(displayMode: LivemapConstants.DisplayMode, scaled: Boolean): AestheticsDefaults {
fun livemap(displayMode: LivemapConstants.DisplayMode): AestheticsDefaults {
return when (displayMode) {
LivemapConstants.DisplayMode.POLYGON -> polygon()
LivemapConstants.DisplayMode.POINT -> point()
.updateInLegend(Aes.SIZE, 5.0)
LivemapConstants.DisplayMode.BAR -> base()
Expand All @@ -164,7 +163,6 @@ open class AestheticsDefaults {
.update(Aes.SIZE, 20.0)
.update(Aes.COLOR, Color.TRANSPARENT)
.updateInLegend(Aes.SIZE, 5.0)
LivemapConstants.DisplayMode.HEATMAP -> base().update(Aes.SIZE, if (scaled) 0.01 else 10.0)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object DataFrameUtil {
}

fun variables(df: DataFrame): Map<String, DataFrame.Variable> {
return df.variables().associateBy { it.name }
return df.variables().associateBy(DataFrame.Variable::name)
}

fun appendReplace(df0: DataFrame, df1: DataFrame): DataFrame {
Expand Down Expand Up @@ -169,3 +169,5 @@ object DataFrameUtil {
return b.build()
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ object TransformVar {
val LOWER = DataFrame.Variable("transform.LOWER", TRANSFORM)
val MIDDLE = DataFrame.Variable("transform.MIDDLE", TRANSFORM)
val UPPER = DataFrame.Variable("transform.UPPER", TRANSFORM)
val MAP_ID = DataFrame.Variable("transform.MAP_ID", TRANSFORM)
val FRAME = DataFrame.Variable("transform.FRAME", TRANSFORM)
val SPEED = DataFrame.Variable("transform.SPEED", TRANSFORM)
val FLOW = DataFrame.Variable("transform.FLOW", TRANSFORM)
Expand All @@ -47,6 +46,8 @@ object TransformVar {
val HJUST = DataFrame.Variable("transform.HJUST", TRANSFORM)
val VJUST = DataFrame.Variable("transform.VJUST", TRANSFORM)
val ANGLE = DataFrame.Variable("transform.ANGLE", TRANSFORM)
val SYM_X = DataFrame.Variable("transform.SYM_X", TRANSFORM)
val SYM_Y = DataFrame.Variable("transform.SYM_Y", TRANSFORM)

private val VAR_BY_AES = TransformVarByAes()
private val VARS: Map<String, DataFrame.Variable>
Expand Down Expand Up @@ -160,11 +161,6 @@ object TransformVar {
return UPPER
}


override fun mapId(): DataFrame.Variable {
return MAP_ID
}

override fun frame(): DataFrame.Variable {
return FRAME
}
Expand Down Expand Up @@ -216,5 +212,13 @@ object TransformVar {
override fun angle(): DataFrame.Variable {
return ANGLE
}

override fun symX(): DataFrame.Variable {
return SYM_X
}

override fun symY(): DataFrame.Variable {
return SYM_Y
}
}
}
Loading