Skip to content

Commit

Permalink
Fix squashed charts on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Ru Chern Chong committed Jan 9, 2024
1 parent 027738c commit 956a2e1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 34 deletions.
15 changes: 3 additions & 12 deletions components/CarInfographic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ export const CarInfographic = ({
new Date(),
);

const grid = {
padding: {
left: 90,
right: 90,
},
};

const chartOptions = {
chart: {
id: "target-chart",
Expand All @@ -46,9 +39,7 @@ export const CarInfographic = ({
categories,
},
yaxis: {
title: {
text: "Number of Registrations",
},
title: { text: "Number of Registrations" },
},
tooltip: {
intersect: false,
Expand All @@ -57,7 +48,6 @@ export const CarInfographic = ({
format: "MMM yyyy",
},
},
grid,
};

const brushOptions = {
Expand All @@ -71,7 +61,7 @@ export const CarInfographic = ({
selection: {
enabled: true,
xaxis: {
min: subMonths(latestMonth, 6).getTime(),
min: subMonths(latestMonth, 3).getTime(),
max: latestMonth.getTime(),
},
},
Expand All @@ -83,6 +73,7 @@ export const CarInfographic = ({
max: latestMonth.getTime(),
},
yaxis: {
show: false,
tickAmount: 1,
},
legend: { show: false },
Expand Down
13 changes: 13 additions & 0 deletions components/CarTreemap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,25 @@ export const CarTreemap = ({ data, popularMakes }: CarTreemapProps) => {
},
dataLabels: {
enabled: true,
formatter: (text, opts) => `${text} - ${opts.value}`,
},
colors: CHART_COLOURS,
title: {
text: `Electric Car Make Distribution for ${selectedMonth}`,
align: "center" as "center",
},
xaxis: {
show: false,
labels: {
show: false,
},
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
},
};

const series = [
Expand Down
11 changes: 4 additions & 7 deletions components/HistoricalResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const HistoricalResult = ({ data }: HistoricalResultProps) => {
colors: CHART_COLOURS,
stroke: { curve: "smooth" as "smooth", width: 3 },
dataLabels: { enabled: false },
fill: { opacity: 0.8 },
title: { text: "Historical COE Results", align: "center" as "center" },
xaxis: {
type: "datetime" as "datetime",
Expand All @@ -98,14 +97,11 @@ export const HistoricalResult = ({ data }: HistoricalResultProps) => {
new Intl.NumberFormat("en-SG", {
style: "currency",
currency: "SGD",
maximumFractionDigits: 0,
}).format(value),
align: "left" as "left",
},
},
grid: {
padding: {
left: 90,
right: 90,
},
floating: true,
},
};

Expand All @@ -132,6 +128,7 @@ export const HistoricalResult = ({ data }: HistoricalResultProps) => {
max: latestMonth.getTime(),
},
yaxis: {
show: false,
tickAmount: 1,
},
legend: { show: false },
Expand Down
31 changes: 16 additions & 15 deletions components/MonthlyResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const MonthlyResult = ({ data }: MonthlyResultProps) => {
},
dataLabels: {
enabled: true,
enabledOnSeries: [3],
// enabled: true,
formatter: (value: number, option: any) => {
if (option.seriesIndex === 3) {
return new Intl.NumberFormat("en-SG", {
Expand All @@ -60,13 +62,13 @@ export const MonthlyResult = ({ data }: MonthlyResultProps) => {
return value;
},
},
plotOptions: {
bar: {
dataLabels: {
position: "center",
},
},
},
// plotOptions: {
// bar: {
// dataLabels: {
// position: "center",
// },
// },
// },
stroke: { curve: "smooth" as "smooth", width: [0, 0, 0, 4] },
colors: CHART_COLOURS,
title: {
Expand All @@ -80,31 +82,30 @@ export const MonthlyResult = ({ data }: MonthlyResultProps) => {
categories,
},
yaxis: [
{ seriesName: "Quotas", title: { text: "Number of Bids" } },
{
show: false,
seriesName: "Quotas",
},
{ show: false, seriesName: "Quotas" },
{ show: false, seriesName: "Quotas" },
{
opposite: true,
title: { text: "Quota Premium ($)" },
labels: {
formatter: (value: number) =>
new Intl.NumberFormat("en-SG", {
style: "currency",
currency: "SGD",
maximumFractionDigits: 0,
}).format(value),
align: "right" as "right",
},
floating: true,
},
],
tooltip: {
shared: true,
intersect: false,
},
grid: {
padding: {
left: 120,
right: 120,
},
},
};

const series = [
Expand Down

0 comments on commit 956a2e1

Please sign in to comment.