Skip to content

Commit 6c03afa

Browse files
merge
2 parents 4ccfdd2 + 0aad2e3 commit 6c03afa

File tree

4 files changed

+136
-3
lines changed

4 files changed

+136
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Blank issue
3+
about: Create a issue to help us improve kandy library
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve kandy library
4+
title: "[BUG]"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
## **Describe the bug**
11+
Please provide a description of the bug, including steps to reproduce it and the expected result.
12+
13+
## **To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Prepare the data
16+
2. Create the chart using the library
17+
3. Customize the chart
18+
4. Render or display the plot
19+
5. Interact with the plot (if applicable)
20+
21+
## **Expected behavior**
22+
Describe how the functionality should work without the bug.
23+
24+
## **Actual Behavior**
25+
Describe what is actually happening, including any error messages or stack traces.
26+
27+
## **Screenshots**
28+
if applicable
29+
30+
## **Library Version, Tool version, and Environment**
31+
(please complete the following information):
32+
- Library version:
33+
- Kotlin-Notebook version: (or kotlin-jupyter-kernel if you are using jupyter or Datalore)
34+
35+
## **Additional information**
36+
Provide any other useful information that may help in resolving the bug.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
kotlin.code.style=official
22
kotlin.jupyter.add.scanner=true
3-
version=0.4.3
3+
version=0.4.4
44
# Koltin
55
systemProp.kotlin_version=1.8.20
66
systemProp.dokka_version=1.8.10

kandy-api/src/main/kotlin/org/jetbrains/kotlinx/kandy/dsl/internal/contexts.kt

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
package org.jetbrains.kotlinx.kandy.dsl.internal
66

77
import org.jetbrains.kotlinx.dataframe.DataColumn
8+
import org.jetbrains.kotlinx.dataframe.DataFrame
89
import org.jetbrains.kotlinx.kandy.ir.Layer
910
import org.jetbrains.kotlinx.kandy.ir.Plot
1011
import org.jetbrains.kotlinx.kandy.ir.aes.AesName
1112
import org.jetbrains.kotlinx.kandy.ir.bindings.*
13+
import org.jetbrains.kotlinx.kandy.ir.data.NamedData
1214
import org.jetbrains.kotlinx.kandy.ir.feature.FeatureName
1315
import org.jetbrains.kotlinx.kandy.ir.feature.LayerFeature
1416
import org.jetbrains.kotlinx.kandy.ir.feature.PlotFeature
@@ -50,10 +52,95 @@ public interface BaseContext {
5052
*/
5153
public abstract class LayerContext(parent: LayerCollectorContext) : BindingContext {
5254
override val bindingCollector: BindingCollector = BindingCollector()
53-
override val datasetIndex: Int = parent.datasetIndex
55+
override var datasetIndex: Int = parent.datasetIndex
5456
public val features: MutableMap<FeatureName, LayerFeature> = mutableMapOf()
5557
override val plotContext: PlotContext = parent.plotContext
5658
public abstract val requiredAes: Set<AesName>
59+
60+
private var firstMapping = true
61+
private val handlerRowsCount: Int
62+
get() {
63+
val buffer = datasetHandler.buffer
64+
return if (buffer == DataFrame.Empty) {
65+
datasetHandler.initialNamedData.dataFrame.rowsCount()
66+
} else {
67+
buffer.rowsCount()
68+
}
69+
}
70+
71+
private fun overrideDataset() {
72+
plotContext.datasetHandlers.add(DatasetHandler(NamedData(DataFrame.Empty)))
73+
datasetIndex = plotContext.datasetHandlers.size - 1
74+
}
75+
76+
override fun <DomainType, RangeType> addNonPositionalMapping(
77+
aesName: AesName,
78+
columnID: String,
79+
parameters: NonPositionalMappingParameters<DomainType, RangeType>?
80+
): NonPositionalMapping<DomainType, RangeType> {
81+
firstMapping = false
82+
return super.addNonPositionalMapping(aesName, columnID, parameters)
83+
}
84+
85+
override fun <DomainType, RangeType> addNonPositionalMapping(
86+
aesName: AesName,
87+
values: DataColumn<DomainType>,
88+
parameters: NonPositionalMappingParameters<DomainType, RangeType>?
89+
): NonPositionalMapping<DomainType, RangeType> {
90+
if (firstMapping && handlerRowsCount != values.size()) {
91+
overrideDataset()
92+
}
93+
firstMapping = false
94+
return super.addNonPositionalMapping(aesName, values, parameters)
95+
}
96+
97+
override fun <DomainType, RangeType> addNonPositionalMapping(
98+
aesName: AesName,
99+
values: List<DomainType>,
100+
name: String?,
101+
parameters: NonPositionalMappingParameters<DomainType, RangeType>?
102+
): NonPositionalMapping<DomainType, RangeType> {
103+
if (firstMapping && handlerRowsCount != values.size) {
104+
overrideDataset()
105+
}
106+
firstMapping = false
107+
return super.addNonPositionalMapping(aesName, values, name, parameters)
108+
}
109+
110+
override fun <DomainType> addPositionalMapping(
111+
aesName: AesName,
112+
columnID: String,
113+
parameters: PositionalMappingParameters<DomainType>?
114+
): PositionalMapping<DomainType> {
115+
firstMapping = false
116+
return super.addPositionalMapping(aesName, columnID, parameters)
117+
}
118+
119+
override fun <DomainType> addPositionalMapping(
120+
aesName: AesName,
121+
values: DataColumn<DomainType>,
122+
parameters: PositionalMappingParameters<DomainType>?
123+
): PositionalMapping<DomainType> {
124+
if (firstMapping && handlerRowsCount != values.size()) {
125+
overrideDataset()
126+
}
127+
firstMapping = false
128+
return super.addPositionalMapping(aesName, values, parameters)
129+
}
130+
131+
override fun <DomainType> addPositionalMapping(
132+
aesName: AesName,
133+
values: List<DomainType>,
134+
name: String?,
135+
parameters: PositionalMappingParameters<DomainType>?
136+
): PositionalMapping<DomainType> {
137+
if (firstMapping && handlerRowsCount != values.size) {
138+
overrideDataset()
139+
}
140+
firstMapping = false
141+
return super.addPositionalMapping(aesName, values, name, parameters)
142+
}
143+
57144
}
58145

59146
/**
@@ -77,7 +164,7 @@ public interface LayerCollectorContext : BaseContext {
77164
} else null)
78165
layers.add(
79166
Layer(
80-
datasetIndex,
167+
context.datasetIndex,
81168
geom,
82169
context.bindingCollector.mappings,
83170
context.bindingCollector.settings,

0 commit comments

Comments
 (0)