Since you seem open to feedback, there is somethin...
# data2viz
j
Since you seem open to feedback, there is something else I'd like to share. I noticed I could use parts of the charts DSL in nested places that don't make much sense. For instance, I can write the following nonsense and the compiler is happy:
Copy code
chart(data = props.simulation.monthlyPayments.seriesBreakdown()) {
    title = "Monthly payments (${props.simulation.name})"

    config {
        config {
            config {
                val time = discrete({ domain.month }) { name = "Time" }
                val value = quantitative({ domain.amount }) { name = "Amount" }
                area(time, value)
            }
        }
        events {
            config {
                selection {
                    series = discrete({ domain.type })
                    zoom {
                        selectionMode = SelectionMode.Disabled
                    }
                }
                zoomMode = ZoomMode.X
            }
        }
    }
}
This could be prevented by creating an annotation to mark the charts DSL using `@DslMarker`: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-dsl-marker/
Using a proper DSL marker would have several benefits: • improve discoverability of the API by auto-complete (at the moment, everything is auto-completed, even things that we're not supposed to use at that level of nesting) • improve the readability of the code (if someone can set anything at any level, it's hard to be certain about the configuration without looking at everything)
p
You are totally right, we used @DslMarker annotations a long time ago but maybe not in the correct way cause we never achieve to limit the auto-completion to the level of nesting. Maybe the feature was still experimental at the time we used it, I'll add your message to our issue tracker, thanks a lot for your feedback.
👍 1