Skip to content

Commit

Permalink
fix sum indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
ronzim committed Jul 2, 2022
1 parent 1185370 commit 2cf2dc1
Showing 1 changed file with 26 additions and 35 deletions.
61 changes: 26 additions & 35 deletions src/api.charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,47 +151,38 @@ export function drawLineChart(expenses: any, getColor: (a: string) => string) {
size: 14,
color: "#afafaf"
}
// barmode: "stack"
};

// add labels
// chartData.push({
// type: "indicator",
// mode: "number+delta",
// value: 492,
// delta: { reference: 512, valueformat: ".0f" },
// ticker: { showticker: true },
// vmax: 500,
// domain: { y: [0, 1], x: [0.25, 0.75] },
// title: { text: "Users online" }
// });

const expByDate = expenses.map((e: any) => e.byDate);

const labelsData = chartData.map((cd: any, i: number) => ({
type: "indicator",
mode: "number+delta",
// mode: "number",
value: _.sum(expByDate.map((d: any) => d[(i + 1).toString()])),
delta: {
reference: _.sum(expByDate.map((d: any) => d[i.toString()])),
valueformat: ".0f",
decreasing: {
color: "#3D9970"
const labelsData = chartData
.map((cd: any, i: number) => ({
type: "indicator",
mode: "number+delta",
// mode: "number",
value: _.sum(expByDate.map((d: any) => d[(i + 1).toString()])),
delta: {
reference: _.sum(expByDate.map((d: any) => d[i.toString()])),
valueformat: ".0f",
decreasing: {
color: "#3D9970"
},
increasing: {
color: "#FF4136"
}
},
increasing: {
color: "#FF4136"
}
},
ticker: { showticker: true },
domain: {
y: [0.5, 1],
x: [(i * 1) / 4, (i + 1) / 4]
},
title: { text: (i + 1).toString() },
number: { prefix: "€", font: { size: 26 } }
}));
ticker: { showticker: true },
domain: {
y: [0.5, 1],
x: [(i * 1) / 6, (i + 1) / 6]
},
title: { text: (i + 1).toString() },
number: { prefix: "€", font: { size: 26 } }
}))
.filter((ld: any) => ld.value);

console.log(chartData);
console.log(labelsData);

Plotly.newPlot("chart", chartData.concat(labelsData), layout, {
responsive: true
Expand Down

0 comments on commit 2cf2dc1

Please sign in to comment.