Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/unfold/static/unfold/css/styles.css

Large diffs are not rendered by default.

54 changes: 51 additions & 3 deletions src/unfold/static/unfold/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ const DEFAULT_CHART_OPTIONS = {
pointBorderWidth: 0,
pointStyle: false,
},
pie: {
borderWidth: 0,
},
doughnut: {
borderWidth: 0,
},
},
plugins: {
legend: {
Expand All @@ -436,6 +442,13 @@ const DEFAULT_CHART_OPTIONS = {
},
scales: {
x: {
display: function (context) {
if (["pie", "doughnut", "radar"].includes(context.chart.config.type)) {
return false;
}

return true;
},
border: {
dash: [5, 5],
dashOffset: 2,
Expand All @@ -456,6 +469,13 @@ const DEFAULT_CHART_OPTIONS = {
},
},
y: {
display: function (context) {
if (["pie", "doughnut", "radar"].includes(context.chart.config.type)) {
return false;
}

return true;
},
border: {
dash: [5, 5],
dashOffset: 5,
Expand Down Expand Up @@ -512,8 +532,17 @@ const renderCharts = () => {
const borderColor = hasDarkClass ? baseColorDark : baseColorLight;

for (const chart of charts) {
chart.options.scales.x.grid.color = borderColor;
chart.options.scales.y.grid.color = borderColor;
if (chart.options.scales.x) {
chart.options.scales.x.grid.color = borderColor;
}

if (chart.options.scales.y) {
chart.options.scales.y.grid.color = borderColor;
}

if (chart.options.scales.r) {
chart.options.scales.r.grid.color = borderColor;
}
chart.update();
}
};
Expand Down Expand Up @@ -556,11 +585,30 @@ const renderCharts = () => {
processColor("backgroundColor");
}

CHART_OPTIONS = { ...DEFAULT_CHART_OPTIONS };
if (type === "radar") {
CHART_OPTIONS.scales = {
r: {
ticks: {
backdropColor: "transparent",
},
pointLabels: {
color: "#9ca3af",
font: {
size: 12,
},
},
},
};
}
Chart.defaults.font.family = "Inter";
Chart.defaults.font.size = 12;

charts.push(
new Chart(ctx, {
type: type || "bar",
data: parsedData,
options: options ? JSON.parse(options) : { ...DEFAULT_CHART_OPTIONS },
options: options ? JSON.parse(options) : { ...CHART_OPTIONS },
})
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@source inline("{md:,lg:,2xl:,}relative {md:,lg:,2xl:,}flex {md:,lg:,2xl:,}absolute {md:,lg:,2xl:,}sticky");
@source inline("{-,}{lg:,}m{t,r,b,l,x,y,}-{0..24} {-,}{lg:,}p{t,r,b,l,x,y,}-{0..24}");
@source inline("{md:,lg:,}border-{0,2} {md:,lg:,}border-{t,r,b,l}-{0,2}");
@source inline("{hover:,dark:,}bg-primary-{50,{100..900..100},950}");
@source inline("{!,}{hover:,dark:,}bg-primary-{50,{100..900..100},950}");
@source inline("{hover:,dark:,}border-base-{50,{100..900..100},950} {hover:,dark:,}border-transparent");
@source inline("{hover:,dark:,}bg-base-{50,{100..900..100},950}");
@source inline("{md:,lg:,}{min-h,h,min-w,w}-{1..8} {md:,lg:,}w-{1/2,1/3,2/3,1/4,2/4,3/4,1/5,2/5,3/5,4/5,1/6,2/6,3/6,4/6,5/6,1/7,2/7,3/7,4/7,5/7,6/7}");
Expand Down