Skip to content

Commit

Permalink
Fix summary stats (#848)
Browse files Browse the repository at this point in the history
* Fix error in summary stat - when trying to map some aesthetic to ..x.. or ..y.. variable.

* Fix error in summary bin stat - when trying to map some aesthetic to ..x.. or ..y.. variable.

* Small update in the Batik demo for the summary stat.
  • Loading branch information
ASmirnov-HORIS authored Aug 16, 2023
1 parent 95a525e commit 0c360a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Summary {
}

private fun crossbarGeom(): MutableMap<String, Any> {
// Failed with error (Internal error: IllegalStateException : Unsupported stat variable: '..y..') before
val spec = """
{
'kind': 'plot',
Expand All @@ -85,15 +86,23 @@ class Summary {
'y': 'sepal length (cm)'
},
'ggtitle': {
'text': 'Basic demo'
'text': 'Crossbar demo'
},
'layers': [
{
'mapping': {'fill': '..y..'},
'geom': 'crossbar',
'mapping': {'middle': '..median..'},
'stat': 'summary',
'fun': 'median',
'fun_min': 'lq',
'quantiles': [0.45, 0.5, 0.55]
'quantiles': [0.45, 0.5, 0.55],
'tooltips': {
'lines': [
'max|^ymax',
'median|^y',
'min|^ymin'
]
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SummaryBinStat(
Stats.Y_MAX to yMaxAggFunction,
)
val aesAggFunctions = statCtx.mappedStatVariables()
.filter { it != Stats.X && it != Stats.Y }
.associateWith { AggregateFunctions.byStatVar(it, lowerQuantile, middleQuantile, upperQuantile) }
val rangeX = statCtx.overallXRange() ?: return withEmptyStatValues()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class SummaryStat(
val statYMin = ArrayList<Double>()
val statYMax = ArrayList<Double>()
val statAggValues: Map<DataFrame.Variable, MutableList<Double>> = statCtx.mappedStatVariables()
.filter { it != Stats.X && it != Stats.Y }
.associateWith { mutableListOf() }
for ((x, bin) in binnedData) {
val sortedBin = bin.sorted()
Expand Down

0 comments on commit 0c360a3

Please sign in to comment.