Skip to content

Commit

Permalink
coin2html: better view list labels, adjusting balance chart width
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobetic committed Jan 3, 2025
1 parent f619c9b commit 121d54e
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 154 deletions.
16 changes: 8 additions & 8 deletions cmd/coin2html/js/src/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ export const Views = {
Assets: {
Balances: viewBalances,
Register: viewRegister,
ChartBalances: viewBalancesChart,
ChartAggregatedRegister: viewAggregatedRegisterChart,
"Balances - Chart": viewBalancesChart,
"Aggregated Register - Chart": viewAggregatedRegisterChart,
},
Liabilities: {
Balances: viewBalances,
Register: () => viewRegister({ negated: true }),
ChartBalances: () => viewBalancesChart({ negated: true }),
ChartAggregatedRegister: () =>
"Balances - Chart": () => viewBalancesChart({ negated: true }),
"Aggregated Register - Chart": () =>
viewAggregatedRegisterChart({ negated: true }),
},
Income: {
Expand All @@ -70,8 +70,8 @@ export const Views = {
negated: true,
aggregatedTotal: true,
}),
ChartBalances: () => viewBalancesChart({ negated: true }),
ChartAggregatedRegister: () =>
"Balances - Chart": () => viewBalancesChart({ negated: true }),
"Aggregated Register - Chart": () =>
viewAggregatedRegisterChart({ negated: true }),
},
Expenses: {
Expand All @@ -80,8 +80,8 @@ export const Views = {
viewRegister({
aggregatedTotal: true,
}),
ChartBalances: viewBalancesChart,
ChartAggregatedRegister: viewAggregatedRegisterChart,
"Balances - Chart": viewBalancesChart,
"Aggregated Register - Chart": viewAggregatedRegisterChart,
},
Equity: {
Balances: viewBalances,
Expand Down
6 changes: 4 additions & 2 deletions cmd/coin2html/js/src/viewsBalancesChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export function viewBalancesChart(options?: {
)
);

const [width, height] = [1200, 800];
const view = select(containerSelector);
const width = max((view.node()! as HTMLElement).clientWidth ?? 1200, 600);
const height = max(1600 - width * 0.67, 400);
const tm = treemap<AccountBalanceAndTotal>()
.size([width, height])
.padding(4)
Expand All @@ -57,7 +59,7 @@ export function viewBalancesChart(options?: {

let uidCounter = 0;

const svg = select(containerSelector)
const svg = view
.append("svg")
.attr("id", "chart")
.attr("width", "100%")
Expand Down
306 changes: 162 additions & 144 deletions examples/yearly/viewer/index.html

Large diffs are not rendered by default.

0 comments on commit 121d54e

Please sign in to comment.