1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Started fixing things

This commit is contained in:
Mawoka 2021-08-29 11:55:58 +02:00
parent 81835a3d88
commit 23f8a5cf7f
3 changed files with 784 additions and 761 deletions

View File

@ -30,8 +30,11 @@ let charts = []
let showTopN = [] let showTopN = []
let resizeCount = 0 let resizeCount = 0
Chart.defaults.global.defaultFontColor = "#E2E8F0" //Chart.defaults.global.defaultFontColor = "#E2E8F0"
Chart.defaults.global.defaultColor = "#E2E8F0" //Chart.defaults.global.defaultColor = "#E2E8F0"
charts.color = "#E2E8F0"
charts.borderColor = "#E2E8F0"
charts.backgroundColor = "#E2E8F0"
String.prototype.toHHMMSS = function () { String.prototype.toHHMMSS = function () {
const sec_num = parseInt(this, 10) const sec_num = parseInt(this, 10)
@ -58,6 +61,10 @@ String.prototype.toHHMM = function () {
return `${hours}:${minutes}` return `${hours}:${minutes}`
} }
console.log(wakapiData.projects
.slice(0, Math.min(showTopN[0], wakapiData.projects.length))
.map(p => p.key))
function draw(subselection) { function draw(subselection) {
function getTooltipOptions(key) { function getTooltipOptions(key) {
return { return {
@ -82,7 +89,8 @@ function draw(subselection) {
let projectChart = projectsCanvas && !projectsCanvas.classList.contains('hidden') && shouldUpdate(0) let projectChart = projectsCanvas && !projectsCanvas.classList.contains('hidden') && shouldUpdate(0)
? new Chart(projectsCanvas.getContext('2d'), { ? new Chart(projectsCanvas.getContext('2d'), {
type: 'horizontalBar', //type: 'horizontalBar',
type: "bar",
data: { data: {
datasets: [{ datasets: [{
data: wakapiData.projects data: wakapiData.projects
@ -107,6 +115,7 @@ function draw(subselection) {
.map(p => p.key) .map(p => p.key)
}, },
options: { options: {
indexAxis: 'y',
legend: { legend: {
display: false display: false
}, },
@ -329,13 +338,16 @@ function getPresentDataMask() {
} }
function getContainer(chart) { function getContainer(chart) {
return chart.canvas.parentNode if ( chart.canvas != undefined) {
return chart.canvas.parentNode
}
} }
function onChartResize(chart) { function onChartResize(chart) {
let container = getContainer(chart) let container = getContainer(chart)
let targetHeight = Math.min(chart.width, CHART_TARGET_SIZE) let targetHeight = Math.min(chart.width, CHART_TARGET_SIZE)
let actualHeight = chart.height - chart.chartArea.top // let actualHeight = chart.height - chart.chartArea.top
let actualHeight = chart.height - chart.top
let containerTargetHeight = container.clientHeight += (targetHeight - actualHeight) let containerTargetHeight = container.clientHeight += (targetHeight - actualHeight)
container.style.height = parseInt(containerTargetHeight) + 'px' container.style.height = parseInt(containerTargetHeight) + 'px'

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff