Browse Source

feat: add name in word cloud

main
nicolas.marsal 4 years ago
parent
commit
ad7fffa448
No known key found for this signature in database
GPG Key ID: 268AB819B6453541
  1. 1
      src/App.vue
  2. 17
      src/components/common/WordCloud.vue

1
src/App.vue

@ -12,7 +12,6 @@ import WordCloud from "@/components/common/WordCloud.vue";
<template> <template>
<div class="main"> <div class="main">
<div class="left"> <div class="left">
<FirstNameAndLastName />
<div <div
style=" style="
display: flex; display: flex;

17
src/components/common/WordCloud.vue

@ -45,7 +45,7 @@ export default defineComponent({
}, },
computeWords() { computeWords() {
this.loading = true; this.loading = true;
const words = Object.keys(skills) let words: (cloud.Word & { size: number })[] = Object.keys(skills)
.map((p) => skills[p]) .map((p) => skills[p])
.map((s) => ({ text: s.name, size: s.score })); .map((s) => ({ text: s.name, size: s.score }));
@ -65,11 +65,22 @@ export default defineComponent({
const range = 120 * (1 - ((s - min) / (max - min)) * 0.7); const range = 120 * (1 - ((s - min) / (max - min)) * 0.7);
return Math.random() * range - range / 2; return Math.random() * range - range / 2;
}; };
words = [
{
size: max * 1.6,
text: "Nicolas Marsal",
rotate: -30,
padding: 6,
x: 0,
y: 0,
},
...words,
];
cloud<{ size: number } & cloud.Word>() cloud<{ size: number } & cloud.Word>()
.size([this.width!, this.height!]) .size([this.width!, this.height!])
.words(words) .words(words)
.padding(1) .padding((w) => w.padding ?? 1)
.rotate((w) => randomRotate(w.size)) .rotate((w) => w.rotate ?? randomRotate(w.size))
.spiral("archimedean") .spiral("archimedean")
.fontSize((d) => scaleFontSize(d.size)) .fontSize((d) => scaleFontSize(d.size))
.on("end", (d: cloud.Word[]) => { .on("end", (d: cloud.Word[]) => {

Loading…
Cancel
Save