// Copyright © SixtyFPS GmbH // SPDX-License-Identifier: MIT import { Theme } from "../theme.slint"; import { ChartPattern } from "chart_pattern.slint"; component Bar { in property bar-height; horizontal-stretch: 1; Rectangle { border-radius: 2px; y: parent.height - self.height; height: bar-height; clip: true; Rectangle { height: root.height; y: parent.height - self.height; background: Theme.palette.bar-gradient; } } } export component BarBackground inherits Rectangle { border-radius: 2px; background: Theme.palette.bar-background-gradient; opacity: 0.25; } export component BarChart { in property <[float]> model; in property min; in property max; in property active; cache-rendering-hint: true; ChartPattern { count: model.length / 2; } layout := HorizontalLayout { spacing: 1px; for value in model : Bar { private property display-value; min-height: 120px; preferred-height: 100%; bar-height: parent.height * (display-value - root.min) / (root.max - root.min); states [ active when active : { display-value: value; in { animate display-value { duration: Theme.durations.slow; easing: ease-in-out; } } } ] } } }