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

Add element_geom(pen, brush, paper) #836

Merged
merged 15 commits into from
Aug 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update demo.
  • Loading branch information
OLarionova-HORIS committed Aug 4, 2023
commit b7a235805eb517aaeab99b46eb7d85b2a15a1503
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,36 @@ class NamedSystemColors {
pieChart(flavor = "solarized_dark"),
pieChart(flavor = "high_contrast_light"),
pieChart(flavor = "high_contrast_dark"),
pieChart(useCustomColors = true),
pieChart(flavor = "darcula", useCustomColors = true)
pieChart(flavor ="darcula", withCustomColors = true, flavorOverCustomColors = true),
pieChart(flavor ="darcula", withCustomColors = true, flavorOverCustomColors = false)
)
}

private fun pieChart(theme: String = "grey", flavor: String? = null, useCustomColors: Boolean = false ): MutableMap<String, Any> {
val themeSettings = listOf(
"'name': '$theme'",
flavor?.let { "'flavor': '$flavor'" } ?: "",
if (useCustomColors) {
"'geom': { 'pen': 'red', 'brush': 'blue', 'paper': 'green' }"
} else ""
).filter(String::isNotEmpty).joinToString()
private fun pieChart(
theme: String = "grey",
flavor: String? = null,
withCustomColors: Boolean = false,
flavorOverCustomColors: Boolean = true
): MutableMap<String, Any> {
val flavorOpts = flavor?.let { "'flavor': '$flavor'" } ?: ""
val customColors = if (withCustomColors) "'geom': { 'pen': 'red', 'paper': 'green', 'brush': 'blue' }" else ""

val themeSettings = (listOf(
"'name': '$theme'"
) + if (flavorOverCustomColors) {
listOf(customColors, flavorOpts)
} else {
listOf(flavorOpts, customColors)
}
).filter(String::isNotEmpty).joinToString()

val spec = """
{
'data': {
'name': ['pen', 'brush', 'paper']
},
'theme': { $themeSettings },
'ggtitle': { 'text': 'theme=$theme, flavor=$flavor, custom colors=$useCustomColors' },
'ggtitle': { 'text': 'theme=$theme, flavor=$flavor, custom colors=$withCustomColors, ${if (flavorOverCustomColors) "theme() + flavor()" else "flavor() + theme()"} ' },
'kind': 'plot',
'scales': [
{
Expand Down