Skip to content

Commit

Permalink
Merge pull request #143 from patrykandpatryk/development
Browse files Browse the repository at this point in the history
Prepare to release Vico 1.5.1
  • Loading branch information
Gowsky authored Oct 25, 2022
2 parents 7c0ca87 + 1df2e85 commit 8b42c50
Show file tree
Hide file tree
Showing 28 changed files with 510 additions and 124 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV
- uses: softprops/action-gh-release@v1
with:
draft: true
tag_name: ${{ env.TAG_NAME }}
token: ${{ secrets.VICO_CHART_BOT_PAT }}
body_path: ${{ github.workspace }}/vico/CHANGELOG.md
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This release includes the following changes.

## Improvements

- Column charts now support data sets in which positive and negative values are mixed together.

## Resolved issues

- Charts consumed more gestures than necessary in some instances.
- For scrollable charts, the chart scale wasn’t considered when the maximum scroll distance was being calculated, which caused scrolling-related bugs.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidViewBinding
import com.patrykandpatryk.vico.R
import com.patrykandpatryk.vico.compose.axis.axisLabelComponent
Expand All @@ -29,14 +30,14 @@ import com.patrykandpatryk.vico.compose.axis.vertical.startAxis
import com.patrykandpatryk.vico.compose.chart.Chart
import com.patrykandpatryk.vico.compose.chart.line.lineChart
import com.patrykandpatryk.vico.compose.chart.line.lineSpec
import com.patrykandpatryk.vico.compose.component.shape.textComponent
import com.patrykandpatryk.vico.compose.component.shapeComponent
import com.patrykandpatryk.vico.compose.dimensions.dimensionsOf
import com.patrykandpatryk.vico.compose.legend.verticalLegend
import com.patrykandpatryk.vico.compose.legend.verticalLegendItem
import com.patrykandpatryk.vico.core.axis.vertical.VerticalAxis
import com.patrykandpatryk.vico.core.chart.line.LineChart
import com.patrykandpatryk.vico.core.component.shape.Shapes
import com.patrykandpatryk.vico.core.component.text.textComponent
import com.patrykandpatryk.vico.core.entry.ChartEntryModelProducer
import com.patrykandpatryk.vico.core.legend.VerticalLegend
import com.patrykandpatryk.vico.databinding.LineChartWithLabelsInsideBinding
Expand Down Expand Up @@ -111,9 +112,7 @@ private fun legend(): VerticalLegend = verticalLegend(
items = entityColors.mapIndexed { index, color ->
verticalLegendItem(
icon = shapeComponent(shape = Shapes.pillShape, color = Color(color)),
label = textComponent {
textSizeSp = LEGEND_LABEL_SIZE_SP
},
label = textComponent(textSize = LEGEND_LABEL_SIZE_SP.sp),
labelText = LocalContext.current.getString(R.string.line_chart_with_labels_inside_label_legend, index),
)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2022 Patryk Goworowski and Patryk Michalik
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.patrykandpatryk.vico.sample.preview

import androidx.compose.foundation.layout.height
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.patrykandpatryk.vico.compose.axis.horizontal.bottomAxis
import com.patrykandpatryk.vico.compose.axis.vertical.startAxis
import com.patrykandpatryk.vico.compose.chart.Chart
import com.patrykandpatryk.vico.compose.chart.column.columnChart
import com.patrykandpatryk.vico.core.chart.values.AxisValuesOverrider
import com.patrykandpatryk.vico.core.component.text.textComponent
import com.patrykandpatryk.vico.core.entry.entryModelOf
import com.patrykandpatryk.vico.sample.util.marker

private val model = entryModelOf(2f, -1f, 4f, -2f, 1f, 5f, -3f)

@Preview
@Composable
public fun SingleColumnChartWithNegativeValues() {
Surface {
Chart(
modifier = Modifier.height(250.dp),
chart = columnChart(
persistentMarkers = mapOf(
2f to marker(),
3f to marker(),
),
),
model = model,
startAxis = startAxis(maxLabelCount = 8),
bottomAxis = bottomAxis(),
)
}
}

@Preview
@Composable
public fun SingleColumnChartWithNegativeValuesAndDataLabels() {
Surface {
Chart(
chart = columnChart(
dataLabel = textComponent(),
),
model = model,
startAxis = startAxis(),
bottomAxis = bottomAxis(),
)
}
}

@Preview
@Composable
public fun SingleColumnChartWithNegativeValuesAndAxisValuesOverridden() {
Surface {
Chart(
chart = columnChart(
axisValuesOverrider = AxisValuesOverrider.fixed(
minY = 1f,
maxY = 4f,
),
),
model = model,
startAxis = startAxis(maxLabelCount = 3),
bottomAxis = bottomAxis(),
)
}
}

@Preview
@Composable
public fun SingleColumnChartWithNegativeValuesAndAxisValuesOverridden2() {
Surface {
Chart(
chart = columnChart(
axisValuesOverrider = AxisValuesOverrider.fixed(
minY = -2f,
maxY = 0f,
),
),
model = model,
startAxis = startAxis(maxLabelCount = 2),
bottomAxis = bottomAxis(),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright 2022 Patryk Goworowski and Patryk Michalik
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.patrykandpatryk.vico.sample.preview

import androidx.compose.foundation.layout.height
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.patrykandpatryk.vico.compose.axis.horizontal.bottomAxis
import com.patrykandpatryk.vico.compose.axis.vertical.startAxis
import com.patrykandpatryk.vico.compose.chart.Chart
import com.patrykandpatryk.vico.compose.chart.column.columnChart
import com.patrykandpatryk.vico.compose.component.shape.lineComponent
import com.patrykandpatryk.vico.core.chart.column.ColumnChart.MergeMode.Stack
import com.patrykandpatryk.vico.core.chart.values.AxisValuesOverrider
import com.patrykandpatryk.vico.core.component.text.textComponent
import com.patrykandpatryk.vico.core.entry.entriesOf
import com.patrykandpatryk.vico.core.entry.entryModelOf
import com.patrykandpatryk.vico.sample.util.marker

private val model = entryModelOf(
entriesOf(2f, -1f, -4f, 2f, 1f, -5f, -2f, -3f),
entriesOf(3f, -2f, 2f, -1f, 2f, -3f, -4f, -1f),
entriesOf(1f, -2f, 2f, 1f, -1f, 4f, 4f, -2f),
)

private val columns = listOf(
lineComponent(color = Color(0xFF494949), thickness = 8.dp),
lineComponent(color = Color(0xFF7C7A7A), thickness = 8.dp),
lineComponent(color = Color(0xFFFF5D73), thickness = 8.dp),
)

@Preview
@Composable
public fun StackedColumnChartWithNegativeValues() {
Surface {
Chart(
modifier = Modifier.height(250.dp),
chart = columnChart(
columns = columns,
persistentMarkers = mapOf(
2f to marker(),
3f to marker(),
),
mergeMode = Stack,
),
model = model,
startAxis = startAxis(maxLabelCount = 7),
bottomAxis = bottomAxis(),
)
}
}

@Preview
@Composable
public fun StackedColumnChartWithNegativeValuesAndDataLabels() {
Surface {
Chart(
chart = columnChart(
columns = columns,
dataLabel = textComponent(),
mergeMode = Stack,
),
model = model,
startAxis = startAxis(maxLabelCount = 7),
bottomAxis = bottomAxis(),
)
}
}

@Preview
@Composable
public fun StackedColumnChartWithNegativeValuesAndAxisValuesOverridden() {
Surface {
Chart(
chart = columnChart(
columns = columns,
axisValuesOverrider = AxisValuesOverrider.fixed(
minY = 1f,
maxY = 4f,
),
mergeMode = Stack,
),
model = model,
startAxis = startAxis(maxLabelCount = 3),
bottomAxis = bottomAxis(),
)
}
}

@Preview
@Composable
public fun StackedColumnChartWithNegativeValuesAndAxisValuesOverridden2() {
Surface {
Chart(
chart = columnChart(
columns = columns,
axisValuesOverrider = AxisValuesOverrider.fixed(
minY = -2f,
maxY = 0f,
),
mergeMode = Stack,
),
model = model,
startAxis = startAxis(maxLabelCount = 2),
bottomAxis = bottomAxis(),
)
}
}
44 changes: 16 additions & 28 deletions sample/src/main/java/com/patrykandpatryk/vico/sample/ui/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
package com.patrykandpatryk.vico.sample.ui

import androidx.compose.animation.Crossfade
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material.ExperimentalMaterialApi
Expand Down Expand Up @@ -64,31 +60,23 @@ internal fun Home() {
).remember()
Scaffold(
bottomBar = {
Column {
NavigationBar(
containerColor = MaterialTheme.colorScheme.surface,
tonalElevation = 0.dp,
) {
Tab.values().forEach {
NavigationBarItem(
selected = tab == it,
onClick = { tab = it },
label = { Text(text = stringResource(id = it.labelResourceId)) },
icon = {
Icon(
painter = painterResource(id = it.iconResourceId),
contentDescription = null,
)
},
)
}
NavigationBar(
containerColor = MaterialTheme.colorScheme.surface,
tonalElevation = 0.dp,
) {
Tab.values().forEach {
NavigationBarItem(
selected = tab == it,
onClick = { tab = it },
label = { Text(text = stringResource(id = it.labelResourceId)) },
icon = {
Icon(
painter = painterResource(id = it.iconResourceId),
contentDescription = null,
)
},
)
}
Spacer(
modifier = Modifier
.background(color = MaterialTheme.colorScheme.surface)
.fillMaxWidth()
.navigationBarsPadding(),
)
}
},
) { paddingValues ->
Expand Down
6 changes: 3 additions & 3 deletions versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext {

library = [
groupId : "com.patrykandpatryk.vico",
version_name : "1.5.0",
version_name : "1.5.1",
version_code : 1,
target_sdk : 33,
min_sdk : 16,
Expand All @@ -32,8 +32,8 @@ ext {
compose : "1.2.1",
composeCompiler : "1.3.2",
coroutines : "1.6.4",
dokka : "1.7.10",
agp : "7.3.0",
dokka : "1.7.20",
agp : "7.3.1",
junit : "4.13.2",
junitExt : "1.1.2",
kotlin : "1.7.20",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ public var MarkerComponent.indicatorSize: Dp
* @param color the shadow color.
* @param applyElevationOverlay whether to apply an elevation overlay to the [ShapeComponent].
*/
public fun ShapeComponent.setShadow(
@Suppress("UNCHECKED_CAST")
public fun <T : ShapeComponent> T.setShadow(
radius: Dp,
dx: Dp = 0.dp,
dy: Dp = 0.dp,
color: Color = Color(DEF_SHADOW_COLOR),
applyElevationOverlay: Boolean = false,
): ShapeComponent = setShadow(
): T = setShadow(
radius = radius.value,
dx = dx.value,
dy = dy.value,
color = color.toArgb(),
applyElevationOverlay = applyElevationOverlay,
)
) as T
Loading

0 comments on commit 8b42c50

Please sign in to comment.