Spaces:
Running
Running
Deploy the site from pipeline commit b68555dc940d
Browse files- assets/amc.css +31 -0
- assets/amc.js +2 -0
- assets/catalog.js +56 -1
- assets/charts.js +154 -0
- assets/og/cara-a-cara.png +0 -0
- assets/og/carrera.png +0 -0
- assets/og/de-cien.png +0 -0
- assets/og/mapa.png +0 -0
- assets/og/software.png +0 -0
- assets/og/termometro.png +0 -0
- assets/picker.js +113 -0
- explorar/index.html +9 -4
- historias/cara-a-cara/index.html +195 -0
- historias/carrera/index.html +32 -19
- historias/de-cien/index.html +213 -0
- historias/gobiernos/index.html +17 -7
- historias/mapa/index.html +165 -0
- historias/software/index.html +10 -6
- historias/termometro/index.html +243 -0
- historias/tu-empresa/index.html +10 -4
- sitemap.xml +4 -0
assets/amc.css
CHANGED
|
@@ -422,3 +422,34 @@ p, li, .fig-head p, .cta .d { text-wrap: pretty; }
|
|
| 422 |
body { background: #fff; }
|
| 423 |
.fig-body, .card, .finding { box-shadow: none; }
|
| 424 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
body { background: #fff; }
|
| 423 |
.fig-body, .card, .finding { box-shadow: none; }
|
| 424 |
}
|
| 425 |
+
|
| 426 |
+
/* ------------------------------------------------------------------ pickers
|
| 427 |
+
The activity and place pickers the tools share (assets/picker.js): the
|
| 428 |
+
explorer's own controls, scoped so no other page inherits them. */
|
| 429 |
+
.picker { display: grid; gap: 12px; margin: 26px 0 0; max-width: 820px; }
|
| 430 |
+
.picker .act { position: relative; }
|
| 431 |
+
.picker input[type="search"] { width: 100%; box-sizing: border-box; font: 500 18px var(--sans); color: var(--ink); background: var(--surface);
|
| 432 |
+
border: 1px solid var(--border-strong); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
|
| 433 |
+
.picker input[type="search"]:focus { outline: 2px solid var(--c1); outline-offset: 1px; }
|
| 434 |
+
.picker .row { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
|
| 435 |
+
.picker .fld { display: grid; gap: 6px; }
|
| 436 |
+
.picker .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
|
| 437 |
+
.picker .sugg { display: grid; gap: 6px; margin: 8px 0 0; }
|
| 438 |
+
.picker .sugg button { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; text-align: left; width: 100%;
|
| 439 |
+
background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 10px 14px; font: inherit; color: inherit; cursor: pointer; }
|
| 440 |
+
.picker .sugg button:hover, .picker .sugg button:focus-visible, .picker .sugg button[aria-selected="true"] { border-color: var(--c1); box-shadow: var(--shadow); }
|
| 441 |
+
.picker .sugg .code { font: 500 12.5px var(--mono); color: var(--muted); margin-right: 8px; }
|
| 442 |
+
.picker .sugg .n { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
|
| 443 |
+
.picker .status { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
|
| 444 |
+
.picker .quick-wrap { display: grid; gap: 8px; margin: 6px 0 0; }
|
| 445 |
+
.picker .quick { display: flex; flex-wrap: wrap; gap: 8px; }
|
| 446 |
+
.picker .quick .chip { font-size: 13.5px; padding: 7px 13px; cursor: pointer; border: 1px solid var(--border); }
|
| 447 |
+
.picker .quick .chip:hover { border-color: var(--border-strong); }
|
| 448 |
+
.picker .quick .chip[aria-current="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }
|
| 449 |
+
@media (max-width: 560px) {
|
| 450 |
+
.picker .row { display: grid; grid-template-columns: minmax(0, 1fr); }
|
| 451 |
+
.picker .row .sel { width: 100%; }
|
| 452 |
+
.picker .seg-ctl { display: flex; width: 100%; box-sizing: border-box; }
|
| 453 |
+
.picker .seg-ctl button { flex: 1 1 0; padding: 9px 6px; }
|
| 454 |
+
.picker input[type="search"] { font-size: 16px; }
|
| 455 |
+
}
|
assets/amc.js
CHANGED
|
@@ -238,6 +238,8 @@ export function footer(s, o = {}) {
|
|
| 238 |
el("h4", { text: "Analíticas Mercantiles Colombianas" }),
|
| 239 |
el("p", { text: "El registro empresarial de Colombia, depurado, verificado y abierto." }),
|
| 240 |
s ? el("p", { text: `Fuente: RUES · Confecámaras · datos.gov.co. Corte del ${date(s.snapshot)}; datos del registro hasta el ${date(s.data_through)}.` }) : null,
|
|
|
|
|
|
|
| 241 |
el("p", {}, "Datos bajo licencia ", el("a", { href: "https://creativecommons.org/licenses/by-sa/4.0/deed.es", rel: "noopener", text: "CC BY-SA 4.0" }), "."),
|
| 242 |
el("a", { class: "clyx-credit", href: CLYX, rel: "noopener", "aria-label": "Un proyecto de Clyx Consulting" },
|
| 243 |
el("small", { text: "Un proyecto de" }), el("span", { class: "clyx", "aria-hidden": "true" }))),
|
|
|
|
| 238 |
el("h4", { text: "Analíticas Mercantiles Colombianas" }),
|
| 239 |
el("p", { text: "El registro empresarial de Colombia, depurado, verificado y abierto." }),
|
| 240 |
s ? el("p", { text: `Fuente: RUES · Confecámaras · datos.gov.co. Corte del ${date(s.snapshot)}; datos del registro hasta el ${date(s.data_through)}.` }) : null,
|
| 241 |
+
// DANE authorises use and transformation with this citation, word for word.
|
| 242 |
+
el("p", { text: "Cifras de población, precios, PIB y empleo, y la clasificación CIIU. Fuente: Departamento Administrativo Nacional de Estadística: www.dane.gov.co." }),
|
| 243 |
el("p", {}, "Datos bajo licencia ", el("a", { href: "https://creativecommons.org/licenses/by-sa/4.0/deed.es", rel: "noopener", text: "CC BY-SA 4.0" }), "."),
|
| 244 |
el("a", { class: "clyx-credit", href: CLYX, rel: "noopener", "aria-label": "Un proyecto de Clyx Consulting" },
|
| 245 |
el("small", { text: "Un proyecto de" }), el("span", { class: "clyx", "aria-hidden": "true" }))),
|
assets/catalog.js
CHANGED
|
@@ -16,6 +16,61 @@ function thumbSvg(box) {
|
|
| 16 |
const RAMP = ["--seq-200", "--seq-300", "--seq-400", "--seq-500", "--seq-600", "--seq-700"];
|
| 17 |
|
| 18 |
export const STORIES = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
{ slug: "gobiernos", kicker: "Gobiernos", title: "Ocho presidentes, 36 años de empresas",
|
| 20 |
dek: "Cuántas empresas se crearon en cada gobierno desde 1990, de qué tipo, en qué sectores y dónde. Las mismas medidas para todos.",
|
| 21 |
thumb: async (box) => {
|
|
@@ -161,7 +216,7 @@ export const STORIES = [
|
|
| 161 |
dek: "Qué tipo de empresas se crearon cada año desde 1990: los sectores compiten por el primer puesto.",
|
| 162 |
thumb: async (box) => {
|
| 163 |
const st = await story("carrera");
|
| 164 |
-
const R = st.q("anual"), y = d3.max(R, (r) => r.anio), rows = R.filter((r) => r.anio === y).slice(0, 6);
|
| 165 |
const s = thumbSvg(box), x = d3.scaleLinear().domain([0, rows[0].creadas]).range([0, 560]);
|
| 166 |
const C = ["--c1", "--c2", "--c3", "--c4", "--c5", "--c7"];
|
| 167 |
rows.forEach((r, i) => s.append("rect").attr("x", 40).attr("y", 30 + i * 42).attr("width", x(r.creadas)).attr("height", 26).attr("rx", 5).attr("fill", css(C[i])));
|
|
|
|
| 16 |
const RAMP = ["--seq-200", "--seq-300", "--seq-400", "--seq-500", "--seq-600", "--seq-700"];
|
| 17 |
|
| 18 |
export const STORIES = [
|
| 19 |
+
{ slug: "termometro", kicker: "Economía · Interactiva", title: "El registro como termómetro",
|
| 20 |
+
dek: "Las sociedades que se crean suben y bajan con la economía, y se conocen semanas antes que el PIB. Los comerciantes siguen su propio ritmo.",
|
| 21 |
+
thumb: async (box) => {
|
| 22 |
+
// Growth on the year before: GDP (grey) and new companies (blue), quarter by quarter.
|
| 23 |
+
const st = await story("termometro");
|
| 24 |
+
const Q = st.q("trimestral");
|
| 25 |
+
const g = (k) => Q.map((r, i) => (i >= 4 && r[k] != null && Q[i - 4][k] ? r[k] / Q[i - 4][k] - 1 : null));
|
| 26 |
+
const gs = g("sociedades"), gp = g("pib");
|
| 27 |
+
const s = thumbSvg(box);
|
| 28 |
+
const x = d3.scaleLinear().domain([4, Q.length - 1]).range([24, 616]);
|
| 29 |
+
const y = d3.scaleLinear().domain([-0.6, 0.6]).range([280, 20]).clamp(true);
|
| 30 |
+
s.append("line").attr("x1", 24).attr("x2", 616).attr("y1", y(0)).attr("y2", y(0)).attr("stroke", css("--border")).attr("stroke-width", 2);
|
| 31 |
+
const line = (v) => d3.line().defined((d) => d != null).x((_, i) => x(i)).y((d) => y(d)).curve(d3.curveMonotoneX)(v.map((d, i) => (i < 4 ? null : d)));
|
| 32 |
+
s.append("path").attr("d", line(gp)).attr("fill", "none").attr("stroke", css("--ink-2")).attr("stroke-width", 4);
|
| 33 |
+
s.append("path").attr("d", line(gs)).attr("fill", "none").attr("stroke", css("--c1")).attr("stroke-width", 4);
|
| 34 |
+
} },
|
| 35 |
+
{ slug: "mapa", kicker: "Regiones · Animada", title: "El país que se llena de empresas",
|
| 36 |
+
dek: "Cuántas empresas nacen cada año por cada 100.000 habitantes en cada región, de 1993 a hoy, en un mapa que se mueve.",
|
| 37 |
+
thumb: async (box) => {
|
| 38 |
+
// The country's companies created per 100,000 residents, year by year.
|
| 39 |
+
const st = await story("mapa");
|
| 40 |
+
const R = st.q("regiones");
|
| 41 |
+
const years = [...new Set(R.map((r) => r.anio))].sort((a, b) => a - b);
|
| 42 |
+
const per = years.map((y) => { const rr = R.filter((r) => r.anio === y); return 1e5 * rr.reduce((t, r) => t + r.creadas, 0) / rr.reduce((t, r) => t + r.poblacion, 0); });
|
| 43 |
+
sparkColumns(box, per, { color: "var(--c1)", highlight: [per.length - 1] });
|
| 44 |
+
} },
|
| 45 |
+
{ slug: "de-cien", kicker: "Herramienta · Interactiva", title: "De 100 que abren, ¿cuántas quedan?",
|
| 46 |
+
dek: "Elige una actividad, un lugar y un año. De cada 100 empresas que se crearon, mira cuántas siguen activas hoy.",
|
| 47 |
+
thumb: async (box) => {
|
| 48 |
+
// A hundred companies created ten years ago, and the ones still active.
|
| 49 |
+
const st = await story("de-cien");
|
| 50 |
+
const N = st.q("nacional");
|
| 51 |
+
const y = Math.max(...N.map((r) => r.anio)) - 10;
|
| 52 |
+
const rr = N.filter((r) => r.anio === y);
|
| 53 |
+
const k = Math.round(100 * rr.reduce((t, r) => t + r.activas, 0) / rr.reduce((t, r) => t + r.empresas, 0));
|
| 54 |
+
const s = thumbSvg(box);
|
| 55 |
+
for (let i = 0; i < 100; i++) {
|
| 56 |
+
s.append("circle").attr("cx", 175 + (i % 10) * 32).attr("cy", 6 + Math.floor(i / 10) * 30.5 + 12).attr("r", 11)
|
| 57 |
+
.attr("fill", i < k ? css("--c1") : css("--deemph"));
|
| 58 |
+
}
|
| 59 |
+
} },
|
| 60 |
+
{ slug: "cara-a-cara", kicker: "Herramienta · Interactiva", title: "Cara a cara",
|
| 61 |
+
dek: "Dos ciudades o dos actividades, frente a frente: cuántas empresas crean, cuántas siguen y cómo cambian año tras año.",
|
| 62 |
+
thumb: async (box) => {
|
| 63 |
+
// The two largest chambers, companies created each year.
|
| 64 |
+
const st = await story("cara-a-cara");
|
| 65 |
+
const E = st.q("ejemplo");
|
| 66 |
+
const s = thumbSvg(box);
|
| 67 |
+
const x = d3.scaleLinear().domain([0, E.length - 1]).range([24, 616]);
|
| 68 |
+
const y = d3.scaleLinear().domain([0, d3.max(E, (r) => Math.max(r.bogota, r.medellin))]).range([280, 20]);
|
| 69 |
+
for (const [k, c] of [["medellin", "--c2"], ["bogota", "--c1"]]) {
|
| 70 |
+
s.append("path").attr("d", d3.line().x((_, i) => x(i)).y((r) => y(r[k])).curve(d3.curveMonotoneX)(E))
|
| 71 |
+
.attr("fill", "none").attr("stroke", css(c)).attr("stroke-width", 5);
|
| 72 |
+
}
|
| 73 |
+
} },
|
| 74 |
{ slug: "gobiernos", kicker: "Gobiernos", title: "Ocho presidentes, 36 años de empresas",
|
| 75 |
dek: "Cuántas empresas se crearon en cada gobierno desde 1990, de qué tipo, en qué sectores y dónde. Las mismas medidas para todos.",
|
| 76 |
thumb: async (box) => {
|
|
|
|
| 216 |
dek: "Qué tipo de empresas se crearon cada año desde 1990: los sectores compiten por el primer puesto.",
|
| 217 |
thumb: async (box) => {
|
| 218 |
const st = await story("carrera");
|
| 219 |
+
const R = st.q("anual").filter((r) => r.seccion !== "—"), y = d3.max(R, (r) => r.anio), rows = R.filter((r) => r.anio === y).slice(0, 6);
|
| 220 |
const s = thumbSvg(box), x = d3.scaleLinear().domain([0, rows[0].creadas]).range([0, 560]);
|
| 221 |
const C = ["--c1", "--c2", "--c3", "--c4", "--c5", "--c7"];
|
| 222 |
rows.forEach((r, i) => s.append("rect").attr("x", 40).attr("y", 30 + i * 42).attr("width", x(r.creadas)).attr("height", 26).attr("rx", 5).attr("fill", css(C[i])));
|
assets/charts.js
CHANGED
|
@@ -1147,3 +1147,157 @@ export function jurisdictionMap(container, o) {
|
|
| 1147 |
}).catch((e) => { holder.replaceChildren(el("p", { class: "error", text: `No se pudo cargar el mapa (${e.message}).` })); });
|
| 1148 |
return holder;
|
| 1149 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1147 |
}).catch((e) => { holder.replaceChildren(el("p", { class: "error", text: `No se pudo cargar el mapa (${e.message}).` })); });
|
| 1148 |
return holder;
|
| 1149 |
}
|
| 1150 |
+
|
| 1151 |
+
// ------------------------------------------------------------------ time map
|
| 1152 |
+
// The jurisdictions map, period after period: one frame each, a class scale
|
| 1153 |
+
// fixed across all of them (a colour means the same in the first year as in
|
| 1154 |
+
// the last), and the bubbles' controls: play, a slider, the period in large.
|
| 1155 |
+
// o.frames: [{ label, values: { codigo_camara: number } }]; o.breaks: the class
|
| 1156 |
+
// thresholds (four, for five classes); o.format formats a legend value;
|
| 1157 |
+
// o.tip(code, i) → tooltip data for jurisdiction `code` in frame i.
|
| 1158 |
+
// Returns { set(frames, breaks) }, to swap the measure under the same controls.
|
| 1159 |
+
export function timeMap(container, o) {
|
| 1160 |
+
const play = el("button", { class: "btn primary", type: "button", text: "▶ Reproducir" });
|
| 1161 |
+
const slider = el("input", { type: "range", min: 0, max: o.frames.length - 1, value: o.start ?? o.frames.length - 1,
|
| 1162 |
+
"aria-label": o.sliderLabel || "Año", style: "flex:1;min-width:140px" });
|
| 1163 |
+
const yearLab = el("span", { style: "font:800 28px var(--display);min-width:70px;text-align:right" });
|
| 1164 |
+
const holder = el("div", { class: "chart map" });
|
| 1165 |
+
const legendBox = el("div", { class: "legend map-legend" });
|
| 1166 |
+
container.append(el("div", { class: "controls" }, play, slider, yearLab), holder, legendBox);
|
| 1167 |
+
let frames = o.frames, breaks = o.breaks, i = o.start ?? frames.length - 1, timer = null, nodes = [];
|
| 1168 |
+
const fmt = o.format || n;
|
| 1169 |
+
const ramp = () => ["--seq-100", "--seq-200", "--seq-400", "--seq-500", "--seq-700"].map((v) => color(`var(${v})`));
|
| 1170 |
+
const legend = () => {
|
| 1171 |
+
const r = ramp();
|
| 1172 |
+
legendBox.replaceChildren(...r.map((c, k) => el("span", {}, el("i", { class: "sw", style: `background:${c}` }),
|
| 1173 |
+
k === 0 ? `menos de ${fmt(breaks[0])}` : k === r.length - 1 ? `${fmt(breaks[breaks.length - 1])} o más` : `${fmt(breaks[k - 1])} a ${fmt(breaks[k])}`)),
|
| 1174 |
+
el("span", {}, el("i", { class: "sw", style: `background:${color("var(--deemph)")}` }), "sin dato"));
|
| 1175 |
+
};
|
| 1176 |
+
const paint = (animate) => {
|
| 1177 |
+
const f = frames[i];
|
| 1178 |
+
yearLab.textContent = f.label; slider.value = i; slider.setAttribute("aria-valuetext", f.label);
|
| 1179 |
+
const sc = d3.scaleThreshold().domain(breaks).range(ramp());
|
| 1180 |
+
for (const { node, code, tiny } of nodes) {
|
| 1181 |
+
const v = f.values[code];
|
| 1182 |
+
const fill = Number.isFinite(v) ? sc(v) : color("var(--deemph)");
|
| 1183 |
+
const s = animate && !reduced ? d3.select(node).transition().duration(Math.min(450, (o.step || 900) * 0.6)) : d3.select(node);
|
| 1184 |
+
s.attr("fill", fill);
|
| 1185 |
+
if (tiny) s.attr("stroke", fill);
|
| 1186 |
+
}
|
| 1187 |
+
};
|
| 1188 |
+
loadMap().then(({ jur, dep }) => {
|
| 1189 |
+
const main = { type: "FeatureCollection", features: jur.filter((f) => f.properties.codigo_camara !== ISLANDS) };
|
| 1190 |
+
const isles = { type: "FeatureCollection", features: jur.filter((f) => f.properties.codigo_camara === ISLANDS) };
|
| 1191 |
+
responsive(holder, (W) => {
|
| 1192 |
+
const proj = d3.geoMercator().fitWidth(W - 8, main);
|
| 1193 |
+
const [[, y0], [, y1]] = d3.geoPath(proj).bounds(main);
|
| 1194 |
+
const H = Math.ceil(y1 - y0) + 8;
|
| 1195 |
+
proj.fitExtent([[4, 4], [W - 4, H - 4]], main);
|
| 1196 |
+
const path = d3.geoPath(proj);
|
| 1197 |
+
const root = svg(W, H, o.label).attr("role", "group");
|
| 1198 |
+
nodes = [];
|
| 1199 |
+
const shape = (g, p, f, tiny = false) => {
|
| 1200 |
+
const code = f.properties.codigo_camara;
|
| 1201 |
+
if (tiny) g.append("path").attr("d", p(f)).attr("fill", "none").attr("stroke", color("var(--ink-2)"))
|
| 1202 |
+
.attr("stroke-opacity", 0.5).attr("stroke-width", 6.5).attr("stroke-linejoin", "round").attr("pointer-events", "none");
|
| 1203 |
+
const node = g.append("path").attr("d", p(f)).attr("class", "jur").attr("stroke", tiny ? null : color("var(--surface)"))
|
| 1204 |
+
.attr("stroke-width", tiny ? 4 : 0.6).attr("stroke-linejoin", "round").node();
|
| 1205 |
+
tipOn(node, () => o.tip(code, i));
|
| 1206 |
+
nodes.push({ node, code, tiny });
|
| 1207 |
+
};
|
| 1208 |
+
const g = root.append("g");
|
| 1209 |
+
main.features.forEach((f) => shape(g, path, f));
|
| 1210 |
+
root.append("path").attr("d", path(dep)).attr("fill", "none").attr("stroke", color("var(--ink-2)"))
|
| 1211 |
+
.attr("stroke-opacity", 0.35).attr("stroke-width", 0.6).attr("pointer-events", "none");
|
| 1212 |
+
if (isles.features.length) {
|
| 1213 |
+
const box = Math.round(Math.max(56, W * 0.13));
|
| 1214 |
+
const ip = d3.geoMercator().fitExtent([[10, 22], [box, box + 12]], isles);
|
| 1215 |
+
const ig = root.append("g");
|
| 1216 |
+
ig.append("rect").attr("x", 4).attr("y", 4).attr("width", box + 2).attr("height", box + 14).attr("rx", 6)
|
| 1217 |
+
.attr("fill", "none").attr("stroke", color("var(--border-strong)"));
|
| 1218 |
+
ig.append("text").attr("class", "tick").attr("x", 10).attr("y", 16).text("San Andrés");
|
| 1219 |
+
isles.features.forEach((f) => shape(ig, d3.geoPath(ip), f, true));
|
| 1220 |
+
}
|
| 1221 |
+
holder.replaceChildren(root.node());
|
| 1222 |
+
legend();
|
| 1223 |
+
paint(false);
|
| 1224 |
+
});
|
| 1225 |
+
}).catch((e) => { holder.replaceChildren(el("p", { class: "error", text: `No se pudo cargar el mapa (${e.message}).` })); });
|
| 1226 |
+
const stop = () => { clearInterval(timer); timer = null; play.textContent = "▶ Reproducir"; };
|
| 1227 |
+
play.addEventListener("click", () => {
|
| 1228 |
+
if (timer) return stop();
|
| 1229 |
+
if (i >= frames.length - 1) { i = 0; paint(false); }
|
| 1230 |
+
play.textContent = "❚❚ Pausa";
|
| 1231 |
+
timer = setInterval(() => { if (i >= frames.length - 1) return stop(); i++; paint(true); }, o.step || 900);
|
| 1232 |
+
});
|
| 1233 |
+
slider.addEventListener("input", () => { stop(); i = +slider.value; paint(false); });
|
| 1234 |
+
return {
|
| 1235 |
+
set(fr, br) { stop(); frames = fr; breaks = br; slider.max = fr.length - 1; i = Math.min(i, fr.length - 1); legend(); paint(false); },
|
| 1236 |
+
};
|
| 1237 |
+
}
|
| 1238 |
+
|
| 1239 |
+
// ------------------------------------------------------------------ scatter
|
| 1240 |
+
// Two measures against each other, one dot per observation. Zero lines where
|
| 1241 |
+
// the axes cross zero; o.fit draws the least-squares line through the points
|
| 1242 |
+
// marked `fit`. No dot is its own focus stop (there may be a hundred): the
|
| 1243 |
+
// pointer finds the nearest, and the figure's table carries every value.
|
| 1244 |
+
// o.points: [{ x, y, key, color?, fit? }]; o.tip(point) → tooltip data.
|
| 1245 |
+
// o.scaleToFit: the axes span the `fit` points only; any other point beyond
|
| 1246 |
+
// them sits on the edge as a hollow ring, its true value in its tooltip.
|
| 1247 |
+
export function scatter(container, o) {
|
| 1248 |
+
const holder = el("div", { class: "chart" });
|
| 1249 |
+
container.append(holder);
|
| 1250 |
+
responsive(holder, (W) => {
|
| 1251 |
+
const mobile = W < 600, H = o.height ? (mobile ? Math.round(o.height * 0.8) : o.height) : (mobile ? 300 : 380);
|
| 1252 |
+
const M = { l: mobile ? 44 : 54, r: 14, t: 22, b: 40 };
|
| 1253 |
+
const P = o.points.filter((p) => Number.isFinite(p.x) && Number.isFinite(p.y));
|
| 1254 |
+
const span = o.scaleToFit ? P.filter((p) => p.fit) : P;
|
| 1255 |
+
const pad = (e) => { const d = (e[1] - e[0]) * 0.08 || 1; return [e[0] - d, e[1] + d]; };
|
| 1256 |
+
const x = d3.scaleLinear().domain(o.xDomain || pad(d3.extent(span, (p) => p.x))).nice(mobile ? 4 : 6).range([M.l, W - M.r]);
|
| 1257 |
+
const y = d3.scaleLinear().domain(o.yDomain || pad(d3.extent(span, (p) => p.y))).nice(5).range([H - M.b, M.t]);
|
| 1258 |
+
const [x0, x1] = x.range(), [y1, y0] = y.range();
|
| 1259 |
+
const px = (p) => Math.max(x0, Math.min(x1, x(p.x))), py = (p) => Math.max(y0, Math.min(y1, y(p.y)));
|
| 1260 |
+
const off = (p) => px(p) !== x(p.x) || py(p) !== y(p.y);
|
| 1261 |
+
const root = svg(W, H, o.label);
|
| 1262 |
+
const ax = root.append("g");
|
| 1263 |
+
x.ticks(mobile ? 4 : 6).forEach((t) => {
|
| 1264 |
+
ax.append("line").attr("class", t === 0 ? "base" : "grid").attr("x1", x(t)).attr("x2", x(t)).attr("y1", M.t).attr("y2", H - M.b);
|
| 1265 |
+
ax.append("text").attr("class", "tick").attr("x", x(t)).attr("y", H - M.b + 16).attr("text-anchor", "middle").text((o.xFormat || compact)(t));
|
| 1266 |
+
});
|
| 1267 |
+
y.ticks(5).forEach((t) => {
|
| 1268 |
+
ax.append("line").attr("class", t === 0 ? "base" : "grid").attr("x1", M.l).attr("x2", W - M.r).attr("y1", y(t)).attr("y2", y(t));
|
| 1269 |
+
ax.append("text").attr("class", "tick").attr("x", M.l - 8).attr("y", y(t) + 4).attr("text-anchor", "end").text((o.yFormat || compact)(t));
|
| 1270 |
+
});
|
| 1271 |
+
if (o.xLabel) ax.append("text").attr("class", "lab").attr("x", W - M.r).attr("y", H - 4).attr("text-anchor", "end").text(o.xLabel);
|
| 1272 |
+
if (o.yLabel) ax.append("text").attr("class", "lab").attr("x", M.l).attr("y", M.t - 8).text(o.yLabel);
|
| 1273 |
+
const F = P.filter((p) => p.fit);
|
| 1274 |
+
if (o.fit && F.length > 2) {
|
| 1275 |
+
const mx = d3.mean(F, (p) => p.x), my = d3.mean(F, (p) => p.y);
|
| 1276 |
+
const b = d3.sum(F, (p) => (p.x - mx) * (p.y - my)) / d3.sum(F, (p) => (p.x - mx) ** 2);
|
| 1277 |
+
const [a0, a1] = x.domain();
|
| 1278 |
+
root.append("line").attr("x1", x(a0)).attr("x2", x(a1)).attr("y1", y(my + b * (a0 - mx))).attr("y2", y(my + b * (a1 - mx)))
|
| 1279 |
+
.attr("stroke", color("var(--ink-2)")).attr("stroke-width", 1.5).attr("stroke-dasharray", "5 4").attr("opacity", 0.8);
|
| 1280 |
+
}
|
| 1281 |
+
const g = root.append("g");
|
| 1282 |
+
for (const p of P) {
|
| 1283 |
+
const c = color(p.color || "var(--c1)");
|
| 1284 |
+
g.append("circle").attr("cx", px(p)).attr("cy", py(p)).attr("r", mobile ? 3.6 : 4.4)
|
| 1285 |
+
.attr("fill", off(p) ? color("var(--surface)") : c).attr("fill-opacity", off(p) ? 1 : 0.78)
|
| 1286 |
+
.attr("stroke", off(p) ? c : color("var(--surface)")).attr("stroke-width", off(p) ? 2 : 1);
|
| 1287 |
+
}
|
| 1288 |
+
if (o.tip) {
|
| 1289 |
+
const del = d3.Delaunay.from(P, px, py);
|
| 1290 |
+
const ring = root.append("circle").attr("r", 7).attr("fill", "none").attr("stroke", color("var(--ink)")).attr("stroke-width", 1.5).attr("opacity", 0).style("pointer-events", "none");
|
| 1291 |
+
const hit = root.append("rect").attr("class", "hit").attr("x", M.l).attr("y", M.t).attr("width", W - M.l - M.r).attr("height", H - M.b - M.t);
|
| 1292 |
+
const move = (ev) => {
|
| 1293 |
+
const [px, py] = d3.pointer(ev);
|
| 1294 |
+
const p = P[del.find(px, py)]; if (!p) return;
|
| 1295 |
+
ring.attr("cx", px(p)).attr("cy", py(p)).attr("opacity", 1);
|
| 1296 |
+
showTip(o.tip(p), ev.clientX, ev.clientY);
|
| 1297 |
+
};
|
| 1298 |
+
hit.on("pointermove", move).on("pointerdown", move).on("pointerleave", () => { ring.attr("opacity", 0); hideTip(); });
|
| 1299 |
+
}
|
| 1300 |
+
holder.replaceChildren(root.node());
|
| 1301 |
+
});
|
| 1302 |
+
return holder;
|
| 1303 |
+
}
|
assets/og/cara-a-cara.png
ADDED
|
assets/og/carrera.png
CHANGED
|
|
assets/og/de-cien.png
ADDED
|
assets/og/mapa.png
ADDED
|
assets/og/software.png
CHANGED
|
|
assets/og/termometro.png
ADDED
|
assets/picker.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AMC — the pickers the tools share: an activity, found by its name, its CIIU
|
| 2 |
+
// code or an everyday word, and a place. The explorer's own (explorar/), as a
|
| 3 |
+
// module, for the pages that compare (Cara a cara) and count (De 100).
|
| 4 |
+
//
|
| 5 |
+
// The activity is a combobox (WAI-ARIA 1.2): focus stays in the input, the
|
| 6 |
+
// arrows move through the suggestions, Enter picks, Escape closes. Besides a
|
| 7 |
+
// CIIU class it offers a whole section and every activity at once.
|
| 8 |
+
import { el, n, title } from "./amc.js";
|
| 9 |
+
|
| 10 |
+
export const norm = (t) => t.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9ñ ]/g, " ").replace(/\s+/g, " ").trim();
|
| 11 |
+
// Everyday words the official names do not use: "software" is not in 6201's
|
| 12 |
+
// name, nor "restaurante" in 5611's. Added to what a search matches, never shown.
|
| 13 |
+
export const ALIAS = {
|
| 14 |
+
"6201": "software programacion desarrollo apps aplicaciones", "6202": "software consultoria informatica sistemas",
|
| 15 |
+
"5820": "software", "5611": "restaurante restaurantes comida", "5613": "cafe cafeteria", "5619": "comidas rapidas",
|
| 16 |
+
"4711": "tienda tiendas minimercado supermercado", "4773": "drogueria farmacia", "6910": "abogados abogado juridica",
|
| 17 |
+
"6920": "contador contadores contabilidad", "8621": "medico consultorio", "8622": "odontologo odontologia",
|
| 18 |
+
"9602": "salon de belleza barberia peluqueria", "4923": "transporte de carga camiones", "4921": "taxi transporte de pasajeros",
|
| 19 |
+
"7310": "agencia de publicidad marketing", "4111": "construccion de vivienda", "6810": "inmobiliaria finca raiz",
|
| 20 |
+
"1081": "panaderia pan", "4631": "mayorista alimentos", "5511": "hotel hoteles", "7911": "agencia de viajes turismo",
|
| 21 |
+
};
|
| 22 |
+
// One-tap starts in everyday words.
|
| 23 |
+
export const STARTS = [["todas", "Todas las actividades"], ["5611", "Restaurantes"], ["4711", "Tiendas de barrio"],
|
| 24 |
+
["9602", "Peluquerías"], ["1081", "Panaderías"], ["6201", "Software"], ["F", "Construcción"], ["H", "Transporte"]];
|
| 25 |
+
|
| 26 |
+
// What the pickers offer, from the explorer's files: every class with live
|
| 27 |
+
// companies, every section, every activity at once, and the chambers.
|
| 28 |
+
export async function catalog(d) {
|
| 29 |
+
const [acts, cams, secRows] = await Promise.all([
|
| 30 |
+
d.query(`SELECT e.sector_code AS clase, arg_max(a.descripcion, a.edicion) AS nombre, sum(e.activas) AS activas
|
| 31 |
+
FROM explorer e JOIN activities a ON a.clase = e.sector_code GROUP BY 1 ORDER BY 3 DESC, 1`),
|
| 32 |
+
d.query(`SELECT codigo_camara, min(chamber) AS chamber, sum(activas) AS activas
|
| 33 |
+
FROM explorer WHERE codigo_camara IS NOT NULL GROUP BY 1 ORDER BY 2`),
|
| 34 |
+
d.query(`SELECT section, divisions, label FROM sector_sections ORDER BY section`)]);
|
| 35 |
+
for (const a of acts) { a.kind = "clase"; a.key = norm(`${a.clase} ${a.nombre} ${ALIAS[a.clase] || ""}`); }
|
| 36 |
+
const secs = secRows.map((r) => {
|
| 37 |
+
const [lo, hi = lo] = r.divisions.split("-");
|
| 38 |
+
const activas = acts.filter((x) => x.clase.slice(0, 2) >= lo && x.clase.slice(0, 2) <= hi).reduce((s, x) => s + x.activas, 0);
|
| 39 |
+
return { kind: "seccion", clase: r.section, lo, hi, nombre: `${r.label} (toda la sección)`, short: r.label, activas,
|
| 40 |
+
key: norm(`seccion ${r.section} ${r.label}`) };
|
| 41 |
+
});
|
| 42 |
+
const allLive = cams.reduce((t, c) => t + c.activas, 0);
|
| 43 |
+
const todas = { kind: "todas", clase: "todas", nombre: "Todas las actividades", short: "Todas las actividades", activas: allLive,
|
| 44 |
+
key: norm("todas las actividades empresas total") };
|
| 45 |
+
const list = [todas, ...secs, ...acts];
|
| 46 |
+
const byCode = new Map(list.map((a) => [a.clase, a]));
|
| 47 |
+
const camName = new Map(cams.map((c) => [c.codigo_camara, title(c.chamber)]));
|
| 48 |
+
return { acts: list, byCode, cams, camName };
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
// The SQL condition an activity puts on explorer's sector_code (null: all).
|
| 52 |
+
export function actCond(d, a) {
|
| 53 |
+
return a.kind === "clase" ? `sector_code = ${d.lit(a.clase)}`
|
| 54 |
+
: a.kind === "seccion" ? `sector_code IN (SELECT clase FROM activities WHERE left(clase, 2) BETWEEN '${a.lo}' AND '${a.hi}')` : null;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// A short name for a sentence: a class's own (cut at a sensible length), a
|
| 58 |
+
// section's label, or "todas las actividades".
|
| 59 |
+
export const actShort = (a) => a.kind === "clase" ? a.nombre : a.short;
|
| 60 |
+
|
| 61 |
+
export function activityPicker({ id, label = "Actividad", cat, value, onChoose, quick = true }) {
|
| 62 |
+
const { acts, byCode } = cat;
|
| 63 |
+
const input = el("input", { id: `${id}-input`, type: "search", role: "combobox", "aria-autocomplete": "list", "aria-expanded": "false",
|
| 64 |
+
"aria-controls": `${id}-list`, placeholder: "Ej.: restaurante, software, 4711", autocomplete: "off" });
|
| 65 |
+
const sugg = el("div", { class: "sugg", id: `${id}-list`, role: "listbox", "aria-label": "Actividades que coinciden" });
|
| 66 |
+
const chips = quick ? el("div", { class: "quick", role: "group", "aria-labelledby": `${id}-quick` },
|
| 67 |
+
...STARTS.filter(([c]) => byCode.has(c)).map(([c, text]) => el("button", { type: "button", class: "chip", "data-clase": c, text }))) : null;
|
| 68 |
+
let current = value, active = -1;
|
| 69 |
+
const mark = () => { if (chips) for (const b of chips.children) b.setAttribute("aria-current", String(b.dataset.clase === current)); };
|
| 70 |
+
const show = () => { const a = byCode.get(current); input.value = !a || a.kind === "todas" ? "" : a.nombre; mark(); };
|
| 71 |
+
const opts = () => [...sugg.querySelectorAll("[role=option]")];
|
| 72 |
+
const close = () => { sugg.replaceChildren(); active = -1; input.setAttribute("aria-expanded", "false"); input.removeAttribute("aria-activedescendant"); };
|
| 73 |
+
const setActive = (i) => {
|
| 74 |
+
const o = opts(); if (!o.length) return;
|
| 75 |
+
active = (i + o.length) % o.length;
|
| 76 |
+
o.forEach((x, k) => x.setAttribute("aria-selected", String(k === active)));
|
| 77 |
+
input.setAttribute("aria-activedescendant", o[active].id);
|
| 78 |
+
o[active].scrollIntoView({ block: "nearest" });
|
| 79 |
+
};
|
| 80 |
+
const suggest = () => {
|
| 81 |
+
const q = norm(input.value);
|
| 82 |
+
close();
|
| 83 |
+
if (q.length < 2) return;
|
| 84 |
+
const words = q.split(" ");
|
| 85 |
+
const hits = acts.filter((a) => /^\d+$/.test(q) ? a.kind === "clase" && a.clase.startsWith(q) : words.every((w) => a.key.includes(w))).slice(0, 8);
|
| 86 |
+
if (!hits.length) { sugg.append(el("p", { class: "status", role: "status", text: "Ninguna actividad tiene esas palabras. Prueba con otra, o con el código CIIU." })); return; }
|
| 87 |
+
hits.forEach((a, i) => sugg.append(el("button", { type: "button", role: "option", id: `${id}-opt-${i}`, tabindex: "-1", "aria-selected": "false", "data-clase": a.clase },
|
| 88 |
+
el("span", {}, el("span", { class: "code", text: a.kind === "todas" ? "*" : a.clase }), a.nombre), el("span", { class: "n", text: `${n(a.activas)} activas` }))));
|
| 89 |
+
input.setAttribute("aria-expanded", "true");
|
| 90 |
+
};
|
| 91 |
+
const choose = (c) => { current = c; close(); show(); onChoose(c); };
|
| 92 |
+
input.addEventListener("input", suggest);
|
| 93 |
+
input.addEventListener("keydown", (e) => {
|
| 94 |
+
if (e.key === "ArrowDown") { e.preventDefault(); if (!opts().length) suggest(); setActive(active + 1); }
|
| 95 |
+
else if (e.key === "ArrowUp") { e.preventDefault(); setActive(active - 1); }
|
| 96 |
+
else if (e.key === "Enter") { e.preventDefault(); (opts()[active] || opts()[0])?.click(); }
|
| 97 |
+
else if (e.key === "Escape") { close(); show(); }
|
| 98 |
+
});
|
| 99 |
+
input.addEventListener("blur", () => setTimeout(() => { if (!sugg.contains(document.activeElement)) { close(); } }, 150));
|
| 100 |
+
for (const box of [sugg, chips].filter(Boolean)) box.addEventListener("click", (e) => { const b = e.target.closest("button[data-clase]"); if (b) choose(b.dataset.clase); });
|
| 101 |
+
show();
|
| 102 |
+
const node = el("div", { class: "fld act" }, el("label", { class: "lbl", for: `${id}-input`, text: label }), input, sugg,
|
| 103 |
+
...(chips ? [el("div", { class: "quick-wrap" }, el("span", { class: "lbl", id: `${id}-quick`, text: "O empieza por una de estas" }), chips)] : []));
|
| 104 |
+
return { node, set(c) { current = c; show(); } };
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
export function placeSelect({ id, label = "Lugar", cat, value = "", onChange }) {
|
| 108 |
+
const sel = el("select", { class: "sel", id }, el("option", { value: "", text: "Todo el país" }),
|
| 109 |
+
...cat.cams.map((c) => el("option", { value: c.codigo_camara, text: cat.camName.get(c.codigo_camara) })));
|
| 110 |
+
sel.value = value;
|
| 111 |
+
sel.addEventListener("change", () => onChange(sel.value));
|
| 112 |
+
return { node: el("div", { class: "fld" }, el("label", { class: "lbl", for: id, text: label }), sel), sel };
|
| 113 |
+
}
|
explorar/index.html
CHANGED
|
@@ -279,10 +279,15 @@ GROUP BY 1 ORDER BY 4 DESC`;
|
|
| 279 |
? fact(A.n1(1e5 * regions.reduce((t, r) => t + r.activas, 0) / regions.reduce((t, r) => t + r.poblacion, 0)), [`${who} activas por cada 100.000 habitantes del país, con la población que el DANE proyecta para ${Y}.`])
|
| 280 |
: fact(share(live / allLive), ["de todas las empresas activas del país, ", { b: n(allLive) }, ", se dedican a esto."]));
|
| 281 |
|
| 282 |
-
// Created each year, and how many of each year still renew: the last 30
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
const f1 = figure({ title: "Cuántas se crean cada año, y cuántas siguen",
|
| 285 |
-
sub: `La columna entera es lo que se creó ese año; la parte de abajo, las que siguen activas en ${Y}. ${Y} va hasta el ${A.date(s.data_through)}.`,
|
| 286 |
sql: sqlYears, source: "RUES · Confecámaras. Cálculos de AMC." });
|
| 287 |
f1.body.append(A.legend([{ label: `Siguen activas en ${Y}`, color: "var(--accent)" }, { label: "Ya no renuevan", color: "var(--c1)" }]));
|
| 288 |
columns(f1.body, span.map((r) => ({ label: r.anio % 5 === 0 ? String(r.anio) : "", value: r.creadas, part: r.siguen_activas,
|
|
@@ -290,7 +295,7 @@ GROUP BY 1 ORDER BY 4 DESC`;
|
|
| 290 |
{ label: "De cada 100", value: n(100 * r.siguen_activas / r.creadas) }] } })),
|
| 291 |
{ label: `Empresas creadas por año en ${a.nombre}, ${place}`, labelEvery: () => 1 });
|
| 292 |
f1.fig.append(tableView(`Empresas creadas y activas por año: ${a.nombre}, ${place}`, ["Año", "Creadas", "Siguen activas", "De cada 100"],
|
| 293 |
-
years.
|
| 294 |
|
| 295 |
// Month by month, the last 24: what opened last month, without SQL.
|
| 296 |
const byMonth = new Map(months.map((r) => [r.mes.slice(0, 7), r.creadas]));
|
|
|
|
| 279 |
? fact(A.n1(1e5 * regions.reduce((t, r) => t + r.activas, 0) / regions.reduce((t, r) => t + r.poblacion, 0)), [`${who} activas por cada 100.000 habitantes del país, con la población que el DANE proyecta para ${Y}.`])
|
| 280 |
: fact(share(live / allLive), ["de todas las empresas activas del país, ", { b: n(allLive) }, ", se dedican a esto."]));
|
| 281 |
|
| 282 |
+
// Created each year, and how many of each year still renew: the last 30,
|
| 283 |
+
// or, for one activity or section, from 2013. Earlier cohorts counted by
|
| 284 |
+
// activity leave out most of the companies that closed, whose activity was
|
| 285 |
+
// never converted to CIIU rev. 4 (99.8 % carry it from 2013, 71 % in
|
| 286 |
+
// 2005), and would show fewer created and more remaining than there were.
|
| 287 |
+
const from = a.kind === "todas" ? Y - 29 : Math.max(Y - 29, 2013);
|
| 288 |
+
const span = years.filter((r) => r.anio >= from && r.anio <= Y);
|
| 289 |
const f1 = figure({ title: "Cuántas se crean cada año, y cuántas siguen",
|
| 290 |
+
sub: `La columna entera es lo que se creó ese año; la parte de abajo, las que siguen activas en ${Y}. ${Y} va hasta el ${A.date(s.data_through)}.${a.kind === "todas" ? "" : " Por actividad, desde 2013: antes, la mayoría de las empresas que cerraron no tiene su actividad en la clasificación actual (CIIU rev. 4)."}`,
|
| 291 |
sql: sqlYears, source: "RUES · Confecámaras. Cálculos de AMC." });
|
| 292 |
f1.body.append(A.legend([{ label: `Siguen activas en ${Y}`, color: "var(--accent)" }, { label: "Ya no renuevan", color: "var(--c1)" }]));
|
| 293 |
columns(f1.body, span.map((r) => ({ label: r.anio % 5 === 0 ? String(r.anio) : "", value: r.creadas, part: r.siguen_activas,
|
|
|
|
| 295 |
{ label: "De cada 100", value: n(100 * r.siguen_activas / r.creadas) }] } })),
|
| 296 |
{ label: `Empresas creadas por año en ${a.nombre}, ${place}`, labelEvery: () => 1 });
|
| 297 |
f1.fig.append(tableView(`Empresas creadas y activas por año: ${a.nombre}, ${place}`, ["Año", "Creadas", "Siguen activas", "De cada 100"],
|
| 298 |
+
years.filter((r) => r.anio >= from).reverse().map((r) => [String(r.anio), n(r.creadas), n(r.siguen_activas), n(100 * r.siguen_activas / r.creadas)])));
|
| 299 |
|
| 300 |
// Month by month, the last 24: what opened last month, without SQL.
|
| 301 |
const byMonth = new Map(months.map((r) => [r.mes.slice(0, 7), r.creadas]));
|
historias/cara-a-cara/index.html
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="es" data-root="../../">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Cara a cara · AMC</title>
|
| 7 |
+
<meta name="description" content="Dos ciudades o dos actividades de Colombia, frente a frente: cuántas empresas crean, cuántas siguen activas y cómo cambian año tras año.">
|
| 8 |
+
<meta property="og:title" content="Cara a cara: dos ciudades o dos actividades, frente a frente">
|
| 9 |
+
<meta property="og:description" content="Cuántas empresas crean, cuántas siguen activas y cómo cambian año tras año, lado a lado.">
|
| 10 |
+
<meta property="og:type" content="article">
|
| 11 |
+
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
|
| 12 |
+
<meta property="og:image" content="https://amc.clyxconsulting.com/assets/og/cara-a-cara.png">
|
| 13 |
+
<meta property="og:image:width" content="1200">
|
| 14 |
+
<meta property="og:image:height" content="630">
|
| 15 |
+
<meta property="og:site_name" content="Analíticas Mercantiles Colombianas">
|
| 16 |
+
<meta name="twitter:card" content="summary_large_image">
|
| 17 |
+
<meta name="twitter:image" content="https://amc.clyxconsulting.com/assets/og/cara-a-cara.png">
|
| 18 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 19 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 20 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 21 |
+
<link rel="stylesheet" href="../../assets/amc.css">
|
| 22 |
+
<link rel="stylesheet" href="../../assets/nav.css">
|
| 23 |
+
<style>
|
| 24 |
+
.sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin: 26px 0 0; }
|
| 25 |
+
@media (max-width: 860px) { .sides { grid-template-columns: minmax(0, 1fr); } }
|
| 26 |
+
.side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
|
| 27 |
+
border-top: 5px solid var(--side); }
|
| 28 |
+
.side .picker { margin: 10px 0 0; }
|
| 29 |
+
.side h2 { margin: 0; font: 800 15px var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
|
| 30 |
+
display: flex; align-items: center; gap: 8px; }
|
| 31 |
+
.side h2::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--side); flex: none; }
|
| 32 |
+
.tipo-row { margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
|
| 33 |
+
.tipo-row .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
|
| 34 |
+
.result { margin: 30px 0 0; }
|
| 35 |
+
.vs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
|
| 36 |
+
@media (max-width: 860px) { .vs { grid-template-columns: minmax(0, 1fr); } }
|
| 37 |
+
.vs .fact { border-top: 5px solid var(--side); }
|
| 38 |
+
.vs .fact h3 { margin: 0 0 6px; font: 700 16px/1.3 var(--display); color: var(--ink); }
|
| 39 |
+
.vs .fact .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 10px 0 0; }
|
| 40 |
+
.vs .fact .row3 .big { font-size: clamp(24px, 3vw, 32px); }
|
| 41 |
+
.vs .fact .row3 p { font-size: 13.5px; }
|
| 42 |
+
.lead { font-size: 18px; line-height: 1.5; margin: 20px 0 0; max-width: 760px; color: var(--ink-2); }
|
| 43 |
+
.lead b { color: var(--ink); }
|
| 44 |
+
</style>
|
| 45 |
+
<link rel="canonical" href="https://amc.clyxconsulting.com/historias/cara-a-cara/">
|
| 46 |
+
<meta property="og:url" content="https://amc.clyxconsulting.com/historias/cara-a-cara/">
|
| 47 |
+
<meta property="og:locale" content="es_CO">
|
| 48 |
+
<meta property="og:image:type" content="image/png">
|
| 49 |
+
<meta property="og:image:alt" content="Cara a cara: dos ciudades o dos actividades, frente a frente">
|
| 50 |
+
</head>
|
| 51 |
+
<body>
|
| 52 |
+
<main class="wrap" id="app"><p class="loading">Preparando la herramienta: la primera vez descarga los datos y el motor de consulta, unos segundos.</p></main>
|
| 53 |
+
<noscript><p class="wrap">Esta página necesita JavaScript.</p></noscript>
|
| 54 |
+
<script type="module">
|
| 55 |
+
import * as A from "../../assets/amc.js";
|
| 56 |
+
import { moreStories } from "../../assets/catalog.js";
|
| 57 |
+
import { lineChart } from "../../assets/charts.js";
|
| 58 |
+
import { catalog, activityPicker, placeSelect, actCond, actShort } from "../../assets/picker.js";
|
| 59 |
+
const { el, n, rich, figure, readThis, tableView, legend, money } = A;
|
| 60 |
+
|
| 61 |
+
A.chrome("historias/cara-a-cara");
|
| 62 |
+
const app = document.getElementById("app");
|
| 63 |
+
const TIPOS = [["todas", "Todas"], ["juridicas", "Sociedades y entidades"], ["naturales", "Comerciantes"]];
|
| 64 |
+
const COLOR = { a: "var(--c1)", b: "var(--c2)" };
|
| 65 |
+
// By activity, only cohorts from 2013 (see De 100 and ops/stories.py ACT_FROM):
|
| 66 |
+
// earlier, the companies that closed mostly lack a CIIU rev. 4 activity.
|
| 67 |
+
const ACT_FROM = 2013;
|
| 68 |
+
|
| 69 |
+
try {
|
| 70 |
+
const ready = import("../../assets/duck.js").then(async (d) => { await d.preload(["explorer", "explorer_firms", "activities", "sector_sections"]); return d; });
|
| 71 |
+
const s = await A.summary();
|
| 72 |
+
const Y = s.year, LAST = Y - 1;
|
| 73 |
+
const d = await ready;
|
| 74 |
+
const cat = await catalog(d);
|
| 75 |
+
const h = new URLSearchParams(location.hash.slice(1));
|
| 76 |
+
const side = (k, clase, camara) => ({ clase: cat.byCode.has(h.get(`${k}c`)) ? h.get(`${k}c`) : clase,
|
| 77 |
+
camara: h.has(`${k}p`) ? (cat.camName.has(h.get(`${k}p`)) ? h.get(`${k}p`) : "") : camara });
|
| 78 |
+
const st = { a: side("a", "todas", "04"), b: side("b", "todas", "21"),
|
| 79 |
+
tipo: TIPOS.some(([k]) => k === h.get("tipo")) ? h.get("tipo") : "todas" };
|
| 80 |
+
const name = (sd) => { const a = cat.byCode.get(sd.clase); const p = sd.camara ? cat.camName.get(sd.camara) : "todo el país";
|
| 81 |
+
return a.kind === "todas" ? A.cap(p) : `${actShort(a)} · ${A.cap(p)}`; };
|
| 82 |
+
|
| 83 |
+
const panel = (k, title) => {
|
| 84 |
+
const ap = activityPicker({ id: `${k}-act`, cat, value: st[k].clase, quick: false, onChoose: (c) => { st[k].clase = c; render(); } });
|
| 85 |
+
const pp = placeSelect({ id: `${k}-lugar`, label: "Lugar", cat, value: st[k].camara, onChange: (v) => { st[k].camara = v; render(); } });
|
| 86 |
+
return el("section", { class: "side", style: `--side:${COLOR[k]}`, "aria-label": title },
|
| 87 |
+
el("h2", { text: title }), el("div", { class: "picker" }, ap.node, el("div", { class: "row" }, pp.node)));
|
| 88 |
+
};
|
| 89 |
+
const seg = el("div", { class: "seg-ctl", role: "group", "aria-labelledby": "tipo-lbl" },
|
| 90 |
+
...TIPOS.map(([k, t]) => el("button", { type: "button", "data-k": k, "aria-pressed": String(k === st.tipo), text: t })));
|
| 91 |
+
seg.addEventListener("click", (e) => {
|
| 92 |
+
const b = e.target.closest("button[data-k]"); if (!b) return;
|
| 93 |
+
st.tipo = b.dataset.k;
|
| 94 |
+
for (const x of seg.children) x.setAttribute("aria-pressed", String(x === b));
|
| 95 |
+
render();
|
| 96 |
+
});
|
| 97 |
+
const out = el("section", { class: "result", "aria-live": "polite" });
|
| 98 |
+
|
| 99 |
+
app.replaceChildren(
|
| 100 |
+
el("header", { class: "story-head", style: "padding-bottom:0" },
|
| 101 |
+
el("p", { class: "kicker", text: "Herramienta · Interactiva" }),
|
| 102 |
+
el("h1", { text: "Cara a cara" }),
|
| 103 |
+
el("p", { class: "dek", text: "Dos lugares, dos actividades o las dos cosas, frente a frente: cuántas empresas crean, cuántas siguen activas y cómo cambian año tras año." }),
|
| 104 |
+
el("div", { class: "sides" }, panel("a", "Lado A"), panel("b", "Lado B")),
|
| 105 |
+
el("div", { class: "tipo-row" }, el("span", { class: "lbl", id: "tipo-lbl", text: "Tipo de empresa, para los dos lados" }), seg)),
|
| 106 |
+
out,
|
| 107 |
+
readThis(["El lugar es la ", { b: "cámara de comercio" }, " de la matrícula principal de cada empresa: su jurisdicción, no necesariamente donde opera. La actividad es la principal que declaró, con la clasificación CIIU del DANE."],
|
| 108 |
+
[{ b: "Activa" }, ` quiere decir que renovó su matrícula en ${Y}. Las empresas creadas hace más tiempo han tenido más años para cerrar.`],
|
| 109 |
+
["Los ingresos son los de las empresas que reportan estados financieros a la Superintendencia de Sociedades, en su último año reportado: no los de todas. Los bancos, las aseguradoras y las que cotizan en bolsa no están."]),
|
| 110 |
+
moreStories("cara-a-cara"));
|
| 111 |
+
A.footer(s);
|
| 112 |
+
A.reveal(app);
|
| 113 |
+
|
| 114 |
+
const tipoCond = () => (st.tipo !== "todas" ? `is_juridical = ${st.tipo === "juridicas"}` : null);
|
| 115 |
+
const where = (...c) => c.filter(Boolean).join(" AND ") || "TRUE";
|
| 116 |
+
const condOf = (sd) => where(actCond(d, cat.byCode.get(sd.clase)), tipoCond(), sd.camara && `codigo_camara = ${d.lit(sd.camara)}`);
|
| 117 |
+
const firmCond = (sd) => where(actCond(d, cat.byCode.get(sd.clase)), sd.camara && `codigo_camara = ${d.lit(sd.camara)}`);
|
| 118 |
+
const fromOf = () => (st.a.clase === "todas" && st.b.clase === "todas" ? 1990 : ACT_FROM);
|
| 119 |
+
async function data(sd) {
|
| 120 |
+
const c = condOf(sd);
|
| 121 |
+
const [years, [tot], [f]] = await Promise.all([
|
| 122 |
+
d.query(`SELECT formation_year AS anio, sum(empresas) AS empresas, sum(activas) AS activas FROM explorer
|
| 123 |
+
WHERE ${c} AND formation_year BETWEEN ${fromOf()} AND ${LAST} GROUP BY 1 ORDER BY 1`),
|
| 124 |
+
d.query(`SELECT sum(activas) AS activas FROM explorer WHERE ${c}`),
|
| 125 |
+
st.tipo === "naturales" ? Promise.resolve([null])
|
| 126 |
+
: d.query(`SELECT count(*) AS firmas, sum(ingresos) AS ingresos FROM explorer_firms
|
| 127 |
+
WHERE ${firmCond(sd)} AND anio_fiscal >= (SELECT max(anio_fiscal) - 1 FROM explorer_firms)`)]);
|
| 128 |
+
const by = new Map(years.map((r) => [r.anio, r]));
|
| 129 |
+
return { sd, years, by, activas: tot?.activas || 0, firms: f };
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
let run = 0;
|
| 133 |
+
async function render(animate = true) {
|
| 134 |
+
const mine = ++run;
|
| 135 |
+
history.replaceState(null, "", `#${new URLSearchParams({ ac: st.a.clase, ap: st.a.camara, bc: st.b.clase, bp: st.b.camara, tipo: st.tipo })}`);
|
| 136 |
+
const [DA, DB] = await Promise.all([data(st.a), data(st.b)]);
|
| 137 |
+
if (mine !== run) return;
|
| 138 |
+
const yrs = [], from = fromOf();
|
| 139 |
+
for (let y = from; y <= LAST; y++) yrs.push(y);
|
| 140 |
+
const fromNote = from > 1990 ? ` Desde ${from}: por actividad, antes de ese año la mayoría de las empresas que cerraron no tiene su actividad en la clasificación actual.` : "";
|
| 141 |
+
const at = (y) => new Date(Date.UTC(y, 0, 1));
|
| 142 |
+
const created = (D, y) => D.by.get(y)?.empresas || 0;
|
| 143 |
+
const share = (D, y) => { const r = D.by.get(y); return r && r.empresas ? r.activas / r.empresas : null; };
|
| 144 |
+
const ten = LAST - 10;
|
| 145 |
+
const card = (D, k) => el("div", { class: "fact", style: `--side:${COLOR[k]}` },
|
| 146 |
+
el("h3", { text: name(D.sd) }),
|
| 147 |
+
el("div", { class: "row3" },
|
| 148 |
+
el("div", {}, el("p", { class: "big", text: n(D.activas) }), el("p", { text: `empresas activas en ${Y}` })),
|
| 149 |
+
el("div", {}, el("p", { class: "big", text: n(created(D, LAST)) }), el("p", { text: `creadas en ${LAST}` })),
|
| 150 |
+
el("div", {}, el("p", { class: "big", text: share(D, ten) == null ? "—" : `${Math.round(100 * share(D, ten))} de 100` }), el("p", { text: `de las creadas en ${ten} siguen activas` }))),
|
| 151 |
+
D.firms && D.firms.firmas ? rich("p", { style: "margin-top:12px;font-size:13.5px" }, [`${n(D.firms.firmas)} reportan estados financieros, con ingresos por `, { b: `${money(D.firms.ingresos)} de pesos` }, " en su último año."]) : "");
|
| 152 |
+
|
| 153 |
+
const ca = created(DA, LAST), cb = created(DB, LAST);
|
| 154 |
+
const lead = ca && cb ? rich("p", { class: "lead" }, [`En ${LAST}, `, { b: ca >= cb ? name(DA.sd) : name(DB.sd) }, ` creó ${A.n1(Math.max(ca, cb) / Math.min(ca, cb)).replace(/,0$/, "")} veces más empresas que `, ca >= cb ? name(DB.sd) : name(DA.sd),
|
| 155 |
+
`: ${n(Math.max(ca, cb))} frente a ${n(Math.min(ca, cb))}.`]) : "";
|
| 156 |
+
|
| 157 |
+
// The race: companies created each year, side by side.
|
| 158 |
+
const f1 = figure({ title: "Empresas creadas cada año", sub: `De ${from} a ${LAST}. Dale «ver la carrera» para dibujarla otra vez.${fromNote}`,
|
| 159 |
+
sql: `SELECT formation_year AS anio, sum(empresas) AS empresas\nFROM explorer\nWHERE ${condOf(st.a)}\n AND formation_year BETWEEN ${from} AND ${LAST}\nGROUP BY 1 ORDER BY 1`,
|
| 160 |
+
source: "RUES · Confecámaras. Cálculos de AMC." });
|
| 161 |
+
const replay = el("button", { type: "button", class: "btn", text: "▶ Ver la carrera" });
|
| 162 |
+
const box1 = el("div");
|
| 163 |
+
f1.body.append(el("div", { class: "controls" }, replay, legend([{ label: name(DA.sd), color: COLOR.a }, { label: name(DB.sd), color: COLOR.b }])), box1);
|
| 164 |
+
const draw1 = (anim) => {
|
| 165 |
+
box1.replaceChildren();
|
| 166 |
+
lineChart(box1, { label: `Empresas creadas cada año: ${name(DA.sd)} frente a ${name(DB.sd)}`, height: 300, animate: anim, yMin: 0, yFormat: (v) => A.compact(v),
|
| 167 |
+
series: [{ color: COLOR.a, width: 2.5, values: yrs.map((y) => ({ x: at(y), y: created(DA, y) })) },
|
| 168 |
+
{ color: COLOR.b, width: 2.5, values: yrs.map((y) => ({ x: at(y), y: created(DB, y) })) }],
|
| 169 |
+
tip: (x, i) => ({ title: String(yrs[i]), rows: [{ label: name(DA.sd), value: n(created(DA, yrs[i])), color: A.css("--c1") }, { label: name(DB.sd), value: n(created(DB, yrs[i])), color: A.css("--c2") }] }) });
|
| 170 |
+
};
|
| 171 |
+
replay.addEventListener("click", () => draw1(true));
|
| 172 |
+
draw1(animate);
|
| 173 |
+
f1.fig.append(tableView("Empresas creadas cada año", ["Año", name(DA.sd), name(DB.sd)], yrs.map((y) => [String(y), n(created(DA, y)), n(created(DB, y))]).reverse()));
|
| 174 |
+
|
| 175 |
+
// Which cohorts kept more.
|
| 176 |
+
const f2 = figure({ title: "De cada 100 creadas, cuántas siguen activas", sub: `Según el año en que se crearon: las más antiguas han tenido más tiempo para cerrar.${fromNote}`,
|
| 177 |
+
sql: `SELECT formation_year AS anio, sum(activas) * 100.0 / sum(empresas) AS siguen_de_cada_100\nFROM explorer\nWHERE ${condOf(st.a)}\n AND formation_year BETWEEN ${from} AND ${LAST}\nGROUP BY 1 ORDER BY 1`,
|
| 178 |
+
source: "RUES · Confecámaras. Cálculos de AMC." });
|
| 179 |
+
f2.body.append(legend([{ label: name(DA.sd), color: COLOR.a }, { label: name(DB.sd), color: COLOR.b }]));
|
| 180 |
+
lineChart(f2.body, { label: `De cada 100 creadas, cuántas siguen activas: ${name(DA.sd)} frente a ${name(DB.sd)}`, height: 260, animate: false, yMin: 0, yMax: 100, yFormat: (v) => String(v),
|
| 181 |
+
series: [{ color: COLOR.a, values: yrs.map((y) => ({ x: at(y), y: share(DA, y) == null ? null : 100 * share(DA, y) })) },
|
| 182 |
+
{ color: COLOR.b, values: yrs.map((y) => ({ x: at(y), y: share(DB, y) == null ? null : 100 * share(DB, y) })) }],
|
| 183 |
+
tip: (x, i) => ({ title: `Creadas en ${yrs[i]}`, rows: [
|
| 184 |
+
{ label: name(DA.sd), value: share(DA, yrs[i]) == null ? "—" : `${Math.round(100 * share(DA, yrs[i]))} de 100`, color: A.css("--c1") },
|
| 185 |
+
{ label: name(DB.sd), value: share(DB, yrs[i]) == null ? "—" : `${Math.round(100 * share(DB, yrs[i]))} de 100`, color: A.css("--c2") }] }) });
|
| 186 |
+
|
| 187 |
+
out.replaceChildren(el("div", { class: "vs" }, card(DA, "a"), card(DB, "b")), lead, f1.fig, f2.fig);
|
| 188 |
+
A.reveal(out);
|
| 189 |
+
}
|
| 190 |
+
render(true);
|
| 191 |
+
window.__amcReady = true;
|
| 192 |
+
} catch (e) { A.fail(app, e, "la herramienta"); }
|
| 193 |
+
</script>
|
| 194 |
+
</body>
|
| 195 |
+
</html>
|
historias/carrera/index.html
CHANGED
|
@@ -40,21 +40,31 @@ const app = document.getElementById("app");
|
|
| 40 |
|
| 41 |
try {
|
| 42 |
const [s, st] = await Promise.all([A.summary(), A.story("carrera")]);
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
const LABEL = Object.fromEntries(R.map((r) => [r.seccion, r.sector]));
|
| 46 |
const totals = Object.fromEntries(years.map((y) => [y, R.filter((r) => r.anio === y).reduce((a, r) => a + r.creadas, 0)]));
|
|
|
|
|
|
|
| 47 |
const share = (sec, y) => { const r = R.find((x) => x.seccion === sec && x.anio === y); return r ? r.creadas / totals[y] : 0; };
|
| 48 |
// Colour follows the sector in every frame: the seven that ever lead get a
|
| 49 |
// slot each, in fixed order; every other sector is the same neutral.
|
| 50 |
const leaders = [...new Set(years.flatMap((y) => R.filter((r) => r.anio === y).slice(0, 4).map((r) => r.seccion)))].slice(0, 7);
|
| 51 |
const SLOTS = ["var(--c1)", "var(--c2)", "var(--c3)", "var(--c4)", "var(--c5)", "var(--c6)", "var(--c7)"];
|
| 52 |
-
const colorOf = (sec) => (leaders.includes(sec) ? SLOTS[leaders.indexOf(sec)] : "var(--other)");
|
| 53 |
-
const short = (sec) => A.shortActivity(LABEL[sec], 34);
|
| 54 |
-
const y0 = years[0], yL = years[years.length - 1];
|
|
|
|
|
|
|
| 55 |
// Between the shares as printed (one decimal), so the page's own arithmetic adds up.
|
| 56 |
const r1 = (x) => Math.round(x * 1000) / 1000;
|
| 57 |
-
const change = Object.keys(LABEL).map((sec) => ({ sec, d: r1(share(sec, yL)) - r1(share(sec,
|
| 58 |
const up = change[0], down = change[change.length - 1];
|
| 59 |
|
| 60 |
const head = el("header", { class: "story-head" },
|
|
@@ -63,32 +73,35 @@ try {
|
|
| 63 |
el("p", { class: "dek", text: `Qué tipo de empresas se crearon cada año desde ${y0}: los sectores compiten año tras año por el primer puesto. Dale «reproducir».` }),
|
| 64 |
el("div", { class: "meta" }, el("span", { class: "chip", text: `Corte del ${A.date(s.snapshot)}` }), A.shareButton()));
|
| 65 |
|
| 66 |
-
const f1 = figure({ title: "Empresas creadas cada año, por sector",
|
|
|
|
| 67 |
barRace(f1.body, { label: "Carrera de los sectores por empresas creadas cada año", step: 900, top: 10,
|
| 68 |
-
frames: years.map((y) => ({ label: String(y), rows:
|
| 69 |
-
f1.fig.append(tableView("Empresas creadas por sector y año", ["Año", ...Object.keys(LABEL).sort()],
|
| 70 |
-
years.map((y) => [String(y), ...Object.keys(LABEL).sort().map((sec) => n((R.find((x) => x.seccion === sec && x.anio === y) || {}).creadas || 0))])));
|
| 71 |
|
| 72 |
-
const
|
| 73 |
-
const
|
|
|
|
| 74 |
smallMultiples(f2.body, main.map((sec) => ({ title: short(sec), color: colorOf(sec), badge: `${A.pct1(share(sec, yL))} en ${yL}`,
|
| 75 |
-
values:
|
| 76 |
{ unit: "Del total del año", format: (v) => `${A.n1(v)}%`, min: 220 });
|
| 77 |
|
| 78 |
app.replaceChildren(head,
|
| 79 |
el("div", { class: "findings" },
|
| 80 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: pct(share("G", yL)) }),
|
| 81 |
-
rich("p", {}, [`de las empresas creadas en ${yL} son de `, { b: "comercio" }, `: el sector que gana la carrera todos los años desde ${y0}.`])),
|
| 82 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `+${A.n1(up.d * 100)} pts` }),
|
| 83 |
-
rich("p", {}, ["ganó ", { b: LABEL[up.sec].toLowerCase() }, ` entre
|
| 84 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `−${A.n1(Math.abs(down.d) * 100)} pts` }),
|
| 85 |
rich("p", {}, ["perdió ", { b: LABEL[down.sec].toLowerCase() }, " en el mismo periodo: el que más cayó."]))),
|
| 86 |
-
prose({ h2:
|
| 87 |
-
|
|
|
|
| 88 |
f1.fig,
|
| 89 |
-
prose(["Vistos uno por uno, los sectores tienen trayectorias
|
| 90 |
f2.fig,
|
| 91 |
-
readThis(["El sector es el ", { b: "actual" },
|
| 92 |
"Los colores siguen a cada sector en todos los años: los siete que alguna vez estuvieron entre los cuatro primeros tienen el suyo; los demás comparten el gris."),
|
| 93 |
moreStories("carrera"));
|
| 94 |
A.footer(s);
|
|
|
|
| 40 |
|
| 41 |
try {
|
| 42 |
const [s, st] = await Promise.all([A.summary(), A.story("carrera")]);
|
| 43 |
+
// '—': the companies of a year with no sector in today's classification
|
| 44 |
+
// (CIIU rev. 4). Before 2013 they are up to half of a year, mostly companies
|
| 45 |
+
// that closed before the registry adopted it, so the sectors known for
|
| 46 |
+
// those years are mostly the survivors'. They race as a grey bar; every
|
| 47 |
+
// share and comparison is on 2013 and after, when (nearly) all have one.
|
| 48 |
+
const UN = "—", FULL = 2013;
|
| 49 |
+
const ALL = st.q("anual"), R = ALL.filter((r) => r.seccion !== UN);
|
| 50 |
+
const years = [...new Set(ALL.map((r) => r.anio))].sort((a, b) => a - b);
|
| 51 |
const LABEL = Object.fromEntries(R.map((r) => [r.seccion, r.sector]));
|
| 52 |
const totals = Object.fromEntries(years.map((y) => [y, R.filter((r) => r.anio === y).reduce((a, r) => a + r.creadas, 0)]));
|
| 53 |
+
const unk = (y) => (ALL.find((r) => r.anio === y && r.seccion === UN) || {}).creadas || 0;
|
| 54 |
+
const unkShare = (y) => unk(y) / (totals[y] + unk(y));
|
| 55 |
const share = (sec, y) => { const r = R.find((x) => x.seccion === sec && x.anio === y); return r ? r.creadas / totals[y] : 0; };
|
| 56 |
// Colour follows the sector in every frame: the seven that ever lead get a
|
| 57 |
// slot each, in fixed order; every other sector is the same neutral.
|
| 58 |
const leaders = [...new Set(years.flatMap((y) => R.filter((r) => r.anio === y).slice(0, 4).map((r) => r.seccion)))].slice(0, 7);
|
| 59 |
const SLOTS = ["var(--c1)", "var(--c2)", "var(--c3)", "var(--c4)", "var(--c5)", "var(--c6)", "var(--c7)"];
|
| 60 |
+
const colorOf = (sec) => (sec === UN ? "var(--deemph)" : leaders.includes(sec) ? SLOTS[leaders.indexOf(sec)] : "var(--other)");
|
| 61 |
+
const short = (sec) => (sec === UN ? "Sin sector actual" : A.shortActivity(LABEL[sec], 34));
|
| 62 |
+
const y0 = years[0], yL = years[years.length - 1], BASE = Math.max(y0, FULL);
|
| 63 |
+
const firstYears = years.filter((y) => y < FULL);
|
| 64 |
+
const worst = firstYears.reduce((a, y) => (unkShare(y) > unkShare(a) ? y : a), firstYears[0] ?? y0);
|
| 65 |
// Between the shares as printed (one decimal), so the page's own arithmetic adds up.
|
| 66 |
const r1 = (x) => Math.round(x * 1000) / 1000;
|
| 67 |
+
const change = Object.keys(LABEL).map((sec) => ({ sec, d: r1(share(sec, yL)) - r1(share(sec, BASE)) })).sort((a, b) => b.d - a.d);
|
| 68 |
const up = change[0], down = change[change.length - 1];
|
| 69 |
|
| 70 |
const head = el("header", { class: "story-head" },
|
|
|
|
| 73 |
el("p", { class: "dek", text: `Qué tipo de empresas se crearon cada año desde ${y0}: los sectores compiten año tras año por el primer puesto. Dale «reproducir».` }),
|
| 74 |
el("div", { class: "meta" }, el("span", { class: "chip", text: `Corte del ${A.date(s.snapshot)}` }), A.shareButton()));
|
| 75 |
|
| 76 |
+
const f1 = figure({ title: "Empresas creadas cada año, por sector",
|
| 77 |
+
sub: `Los diez sectores con más empresas creadas cada año. En gris, las empresas sin sector en la clasificación actual: hasta ${FULL}, muchas, porque son sobre todo las que cerraron antes de que el registro la adoptara. Reproduce la animación o mueve el control para ir a un año.`, sql: st.sql("anual") });
|
| 78 |
barRace(f1.body, { label: "Carrera de los sectores por empresas creadas cada año", step: 900, top: 10,
|
| 79 |
+
frames: years.map((y) => ({ label: String(y), rows: ALL.filter((r) => r.anio === y).map((r) => ({ key: r.seccion, label: short(r.seccion), title: r.seccion === UN ? r.sector : `${r.seccion} · ${r.sector}`, value: r.creadas, color: colorOf(r.seccion) })) })) });
|
| 80 |
+
f1.fig.append(tableView("Empresas creadas por sector y año", ["Año", ...Object.keys(LABEL).sort(), "Sin sector actual"],
|
| 81 |
+
years.map((y) => [String(y), ...Object.keys(LABEL).sort().map((sec) => n((R.find((x) => x.seccion === sec && x.anio === y) || {}).creadas || 0)), n(unk(y))])));
|
| 82 |
|
| 83 |
+
const shareYears = years.filter((y) => y >= BASE);
|
| 84 |
+
const f2 = figure({ title: "El peso de cada sector, año a año", sub: `Porcentaje de las empresas creadas cada año que pertenece a cada sector, desde ${BASE}: antes, el sector de buena parte de ellas no se conoce. Cada panel tiene su propia escala.`, sql: st.sql("anual") });
|
| 85 |
+
const main = Object.keys(LABEL).filter((sec) => shareYears.some((y) => share(sec, y) >= 0.03)).sort((a, b) => share(b, yL) - share(a, yL));
|
| 86 |
smallMultiples(f2.body, main.map((sec) => ({ title: short(sec), color: colorOf(sec), badge: `${A.pct1(share(sec, yL))} en ${yL}`,
|
| 87 |
+
values: shareYears.map((y) => ({ x: y, y: share(sec, y) * 100, extra: [{ label: "Empresas creadas", value: n((R.find((x) => x.seccion === sec && x.anio === y) || {}).creadas || 0) }] })) })),
|
| 88 |
{ unit: "Del total del año", format: (v) => `${A.n1(v)}%`, min: 220 });
|
| 89 |
|
| 90 |
app.replaceChildren(head,
|
| 91 |
el("div", { class: "findings" },
|
| 92 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: pct(share("G", yL)) }),
|
| 93 |
+
rich("p", {}, [`de las empresas creadas en ${yL} con sector conocido son de `, { b: "comercio" }, `: el sector que gana la carrera todos los años desde ${y0}.`])),
|
| 94 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `+${A.n1(up.d * 100)} pts` }),
|
| 95 |
+
rich("p", {}, ["ganó ", { b: LABEL[up.sec].toLowerCase() }, ` entre ${BASE} y ${yL}: el sector que más creció en peso.`])),
|
| 96 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `−${A.n1(Math.abs(down.d) * 100)} pts` }),
|
| 97 |
rich("p", {}, ["perdió ", { b: LABEL[down.sec].toLowerCase() }, " en el mismo periodo: el que más cayó."]))),
|
| 98 |
+
prose({ h2: `${yL - y0 + 1} años de carrera` },
|
| 99 |
+
[`El comercio gana siempre, y por mucho: cada año desde ${BASE}, ${shareYears.every((y) => share("G", y) >= 1 / 3) ? "más de una de cada tres" : "cerca de una de cada tres"} empresas nuevas con sector conocido se dedica a comprar y vender. La carrera interesante es la del resto: quién sube, quién baja y cuándo.`],
|
| 100 |
+
["La barra gris es una advertencia, no un sector. Antes de ", { b: String(FULL) }, ` una parte de las empresas creadas cada año no tiene sector en la clasificación actual: el ${pct(unkShare(worst))} de las de ${worst}. Son sobre todo las que cerraron antes de que el registro adoptara la CIIU rev. 4, así que en esos años la carrera muestra sobre todo a las que sobrevivieron. Por eso los porcentajes por sector se comparan desde ${BASE}.`]),
|
| 101 |
f1.fig,
|
| 102 |
+
prose(["Vistos uno por uno, los sectores tienen trayectorias distintas. El de ", { b: LABEL[up.sec].toLowerCase() }, ` pasó del ${A.pct1(share(up.sec, BASE))} de las empresas nuevas en ${BASE} al ${A.pct1(share(up.sec, yL))} en ${yL}; el de `, { b: LABEL[down.sec].toLowerCase() }, `, del ${A.pct1(share(down.sec, BASE))} al ${A.pct1(share(down.sec, yL))}.`]),
|
| 103 |
f2.fig,
|
| 104 |
+
readThis(["El sector es el ", { b: "actual" }, ` de cada empresa (CIIU Rev. 4), contado en su año de creación. Las que no tienen uno en esa clasificación forman la barra gris; desde ${FULL} son menos del 1 % de cada año.`],
|
| 105 |
"Los colores siguen a cada sector en todos los años: los siete que alguna vez estuvieron entre los cuatro primeros tienen el suyo; los demás comparten el gris."),
|
| 106 |
moreStories("carrera"));
|
| 107 |
A.footer(s);
|
historias/de-cien/index.html
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="es" data-root="../../">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>De 100 que abren, ¿cuántas quedan? · AMC</title>
|
| 7 |
+
<meta name="description" content="Elige una actividad, un lugar y un año: de cada 100 empresas que se crearon en Colombia, cuántas siguen activas hoy. Con el registro mercantil completo.">
|
| 8 |
+
<meta property="og:title" content="De 100 que abren, ¿cuántas quedan?">
|
| 9 |
+
<meta property="og:description" content="Elige una actividad, un lugar y un año: de cada 100 empresas que se crearon, cuántas siguen activas hoy.">
|
| 10 |
+
<meta property="og:type" content="article">
|
| 11 |
+
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
|
| 12 |
+
<meta property="og:image" content="https://amc.clyxconsulting.com/assets/og/de-cien.png">
|
| 13 |
+
<meta property="og:image:width" content="1200">
|
| 14 |
+
<meta property="og:image:height" content="630">
|
| 15 |
+
<meta property="og:site_name" content="Analíticas Mercantiles Colombianas">
|
| 16 |
+
<meta name="twitter:card" content="summary_large_image">
|
| 17 |
+
<meta name="twitter:image" content="https://amc.clyxconsulting.com/assets/og/de-cien.png">
|
| 18 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 19 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 20 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 21 |
+
<link rel="stylesheet" href="../../assets/amc.css">
|
| 22 |
+
<link rel="stylesheet" href="../../assets/nav.css">
|
| 23 |
+
<style>
|
| 24 |
+
.result { margin: 30px 0 0; scroll-margin-top: 80px; }
|
| 25 |
+
.verdict { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 28px; align-items: center;
|
| 26 |
+
background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
|
| 27 |
+
@media (max-width: 760px) { .verdict { grid-template-columns: minmax(0, 1fr); } }
|
| 28 |
+
.dots svg { width: 100%; height: auto; display: block; }
|
| 29 |
+
.verdict .big { font: 800 clamp(48px, 7vw, 76px)/1 var(--display); letter-spacing: -.04em; margin: 0; color: var(--ink); }
|
| 30 |
+
.verdict .big span { font-size: .42em; letter-spacing: -.01em; color: var(--ink-2); font-weight: 700; }
|
| 31 |
+
.verdict .say { font-size: 18px; line-height: 1.5; margin: 10px 0 0; color: var(--ink-2); }
|
| 32 |
+
.verdict .say b { color: var(--ink); }
|
| 33 |
+
.verdict .warn { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
|
| 34 |
+
.verdict .acts { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 0; }
|
| 35 |
+
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin: 16px 0 0; }
|
| 36 |
+
@media (max-width: 760px) { .compare { grid-template-columns: minmax(0, 1fr); } }
|
| 37 |
+
.compare .fact .big { font-size: clamp(30px, 3.6vw, 40px); }
|
| 38 |
+
.yearfld { min-width: min(320px, 100%); }
|
| 39 |
+
.yearfld .yr { display: flex; align-items: center; gap: 12px; }
|
| 40 |
+
.yearfld input[type="range"] { flex: 1; accent-color: var(--c1); }
|
| 41 |
+
.yearfld output { font: 800 24px var(--display); min-width: 58px; text-align: right; }
|
| 42 |
+
</style>
|
| 43 |
+
<link rel="canonical" href="https://amc.clyxconsulting.com/historias/de-cien/">
|
| 44 |
+
<meta property="og:url" content="https://amc.clyxconsulting.com/historias/de-cien/">
|
| 45 |
+
<meta property="og:locale" content="es_CO">
|
| 46 |
+
<meta property="og:image:type" content="image/png">
|
| 47 |
+
<meta property="og:image:alt" content="De 100 que abren, ¿cuántas quedan?">
|
| 48 |
+
</head>
|
| 49 |
+
<body>
|
| 50 |
+
<main class="wrap" id="app"><p class="loading">Preparando la herramienta: la primera vez descarga los datos y el motor de consulta, unos segundos.</p></main>
|
| 51 |
+
<noscript><p class="wrap">Esta página necesita JavaScript.</p></noscript>
|
| 52 |
+
<script type="module">
|
| 53 |
+
import * as A from "../../assets/amc.js";
|
| 54 |
+
import { moreStories } from "../../assets/catalog.js";
|
| 55 |
+
import { columns, d3 } from "../../assets/charts.js";
|
| 56 |
+
import { catalog, activityPicker, placeSelect, actCond, actShort } from "../../assets/picker.js";
|
| 57 |
+
const { el, n, pct, rich, figure, readThis, tableView } = A;
|
| 58 |
+
|
| 59 |
+
A.chrome("historias/de-cien");
|
| 60 |
+
const app = document.getElementById("app");
|
| 61 |
+
const TIPOS = [["todas", "Todas"], ["juridicas", "Sociedades y entidades"], ["naturales", "Comerciantes"]];
|
| 62 |
+
const MIN = 30; // fewer companies than this, and one of them moves the answer
|
| 63 |
+
// By activity, only cohorts from 2013: earlier, most companies that closed
|
| 64 |
+
// never had their activity converted to CIIU rev. 4, so counting the ones that
|
| 65 |
+
// carry it overstates who remains (99.8 % carry it from 2013; 71 % in 2005).
|
| 66 |
+
const ACT_FROM = 2013;
|
| 67 |
+
|
| 68 |
+
// The same 100 dots fall the same way for the same question: a shuffle seeded
|
| 69 |
+
// by the question, so the picture does not flicker between identical answers.
|
| 70 |
+
function order(seed) {
|
| 71 |
+
let h = 2166136261;
|
| 72 |
+
for (const ch of seed) { h ^= ch.charCodeAt(0); h = Math.imul(h, 16777619); }
|
| 73 |
+
const idx = [...Array(100).keys()];
|
| 74 |
+
for (let i = 99; i > 0; i--) { h = Math.imul(h ^ (h >>> 15), 2246822507) >>> 0; const j = h % (i + 1); [idx[i], idx[j]] = [idx[j], idx[i]]; }
|
| 75 |
+
return idx;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
try {
|
| 79 |
+
const ready = import("../../assets/duck.js").then(async (d) => { await d.preload(["explorer", "activities", "sector_sections"]); return d; });
|
| 80 |
+
const s = await A.summary();
|
| 81 |
+
const Y = s.year, LAST = Y - 1;
|
| 82 |
+
const d = await ready;
|
| 83 |
+
const cat = await catalog(d);
|
| 84 |
+
const h = new URLSearchParams(location.hash.slice(1));
|
| 85 |
+
const st = {
|
| 86 |
+
clase: cat.byCode.has(h.get("clase")) ? h.get("clase") : "5611",
|
| 87 |
+
camara: cat.camName.has(h.get("camara")) ? h.get("camara") : "",
|
| 88 |
+
anio: Math.min(LAST, Math.max(1990, +h.get("anio") || LAST - 10)),
|
| 89 |
+
tipo: TIPOS.some(([k]) => k === h.get("tipo")) ? h.get("tipo") : "todas",
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
const picker = activityPicker({ id: "act", cat, value: st.clase, onChoose: (c) => { st.clase = c; year.min = fromOf(); st.anio = Math.max(fromOf(), st.anio); render(); } });
|
| 93 |
+
const place = placeSelect({ id: "lugar", label: "Lugar", cat, value: st.camara, onChange: (v) => { st.camara = v; render(); } });
|
| 94 |
+
const fromOf = () => (cat.byCode.get(st.clase).kind === "todas" ? 1990 : ACT_FROM);
|
| 95 |
+
st.anio = Math.max(fromOf(), st.anio);
|
| 96 |
+
const year = el("input", { type: "range", id: "anio", min: fromOf(), max: LAST, step: 1, value: st.anio });
|
| 97 |
+
const yearOut = el("output", { for: "anio", text: String(st.anio) });
|
| 98 |
+
year.addEventListener("input", () => { yearOut.textContent = year.value; });
|
| 99 |
+
year.addEventListener("change", () => { st.anio = +year.value; render(); });
|
| 100 |
+
const seg = el("div", { class: "seg-ctl", role: "group", "aria-labelledby": "tipo-lbl" },
|
| 101 |
+
...TIPOS.map(([k, t]) => el("button", { type: "button", "data-k": k, "aria-pressed": String(k === st.tipo), text: t })));
|
| 102 |
+
seg.addEventListener("click", (e) => {
|
| 103 |
+
const b = e.target.closest("button[data-k]"); if (!b) return;
|
| 104 |
+
st.tipo = b.dataset.k;
|
| 105 |
+
for (const x of seg.children) x.setAttribute("aria-pressed", String(x === b));
|
| 106 |
+
render();
|
| 107 |
+
});
|
| 108 |
+
const out = el("section", { class: "result", "aria-live": "polite" });
|
| 109 |
+
|
| 110 |
+
app.replaceChildren(
|
| 111 |
+
el("header", { class: "story-head", style: "padding-bottom:0" },
|
| 112 |
+
el("p", { class: "kicker", text: "Herramienta · Supervivencia · Interactiva" }),
|
| 113 |
+
el("h1", { text: "De 100 que abren, ¿cuántas quedan?" }),
|
| 114 |
+
el("p", { class: "dek", text: "Elige una actividad, un lugar y el año en que se crearon. De cada 100 empresas, mira cuántas siguen activas hoy." }),
|
| 115 |
+
el("div", { class: "picker" }, picker.node,
|
| 116 |
+
el("div", { class: "row" }, place.node,
|
| 117 |
+
el("div", { class: "fld yearfld" }, el("label", { class: "lbl", for: "anio", text: "Año de creación" }), el("div", { class: "yr" }, year, yearOut)),
|
| 118 |
+
el("div", { class: "fld" }, el("span", { class: "lbl", id: "tipo-lbl", text: "Tipo de empresa" }), seg)))),
|
| 119 |
+
out,
|
| 120 |
+
readThis([{ b: "Activa" }, ` quiere decir que renovó su matrícula mercantil en ${Y}: la que no renovó puede haber cerrado o solo haber dejado de renovar. El registro guarda el último año renovado, no la fecha de cierre, así que esto no es una curva de supervivencia (decisión D21).`],
|
| 121 |
+
["Las empresas creadas hace más tiempo han tenido más años para cerrar: compara un año con otro sabiendo eso. El gráfico de abajo muestra todos los años a la vez."],
|
| 122 |
+
["Por actividad, los años empiezan en ", { b: "2013" }, ": antes, la mayoría de las empresas que cerraron no tiene su actividad en la clasificación actual (CIIU rev. 4), y contarlas solo a ellas exageraría las que siguen. Con todas las actividades, desde 1990."],
|
| 123 |
+
["La actividad es la ", { b: "principal" }, " que la empresa declaró, con la clasificación CIIU del DANE, y el lugar es la ", { b: "cámara de comercio" }, " de su matrícula principal, no necesariamente donde opera."]),
|
| 124 |
+
moreStories("de-cien"));
|
| 125 |
+
A.footer(s);
|
| 126 |
+
A.reveal(app);
|
| 127 |
+
|
| 128 |
+
let run = 0;
|
| 129 |
+
async function series(cond, from = fromOf()) {
|
| 130 |
+
return d.query(`SELECT formation_year AS anio, sum(empresas) AS empresas, sum(activas) AS activas
|
| 131 |
+
FROM explorer WHERE ${cond} AND formation_year BETWEEN ${from} AND ${LAST} GROUP BY 1 ORDER BY 1`);
|
| 132 |
+
}
|
| 133 |
+
async function render() {
|
| 134 |
+
const mine = ++run;
|
| 135 |
+
history.replaceState(null, "", `#${new URLSearchParams({ clase: st.clase, ...(st.camara && { camara: st.camara }), anio: st.anio, tipo: st.tipo })}`);
|
| 136 |
+
year.value = st.anio; yearOut.textContent = String(st.anio);
|
| 137 |
+
const a = cat.byCode.get(st.clase);
|
| 138 |
+
const tipo = st.tipo !== "todas" ? `is_juridical = ${st.tipo === "juridicas"}` : null;
|
| 139 |
+
const where = (...c) => c.filter(Boolean).join(" AND ") || "TRUE";
|
| 140 |
+
const here = where(actCond(d, a), tipo, st.camara && `codigo_camara = ${d.lit(st.camara)}`);
|
| 141 |
+
const [S, Snat, Splace] = await Promise.all([series(here), series(where(actCond(d, a), tipo)),
|
| 142 |
+
st.camara ? series(where(tipo, `codigo_camara = ${d.lit(st.camara)}`)) : Promise.resolve(null)]);
|
| 143 |
+
if (mine !== run) return;
|
| 144 |
+
const pick = (rows) => rows.find((r) => r.anio === st.anio) || { empresas: 0, activas: 0 };
|
| 145 |
+
const r = pick(S), share = r.empresas ? r.activas / r.empresas : null;
|
| 146 |
+
const k = share == null ? 0 : Math.round(100 * share);
|
| 147 |
+
const lugar = st.camara ? cat.camName.get(st.camara) : "Colombia";
|
| 148 |
+
const quien = a.kind === "todas" ? "empresas" : `empresas de ${actShort(a).toLowerCase()}`;
|
| 149 |
+
const tipoTxt = st.tipo === "juridicas" ? " (sociedades y entidades)" : st.tipo === "naturales" ? " (comerciantes personas naturales)" : "";
|
| 150 |
+
|
| 151 |
+
// The hundred dots: all start alive; those that did not renew fade and fall.
|
| 152 |
+
const W = 320, cell = 32, rad = 12.5;
|
| 153 |
+
const svg = d3.create("svg").attr("viewBox", `0 0 ${W} ${W + 8}`).attr("role", "img")
|
| 154 |
+
.attr("aria-label", share == null ? "Sin empresas para esta combinación" : `${k} de cada 100 siguen activas`);
|
| 155 |
+
const seq = order(`${st.clase}|${st.camara}|${st.anio}|${st.tipo}`);
|
| 156 |
+
const alive = new Set(seq.slice(0, k));
|
| 157 |
+
const dots = [...Array(100).keys()].map((i) => svg.append("circle").attr("cx", 16 + (i % 10) * cell).attr("cy", 16 + Math.floor(i / 10) * cell)
|
| 158 |
+
.attr("r", rad).attr("fill", A.css("--c1")).datum(i));
|
| 159 |
+
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
| 160 |
+
const fall = () => {
|
| 161 |
+
dots.forEach((c) => {
|
| 162 |
+
const i = c.datum();
|
| 163 |
+
if (alive.has(i)) return;
|
| 164 |
+
const t = reduced ? c : c.transition().delay(250 + seq.indexOf(i) * 9).duration(500);
|
| 165 |
+
t.attr("fill", A.css("--deemph")).attr("cy", 16 + Math.floor(i / 10) * cell + (reduced ? 0 : 5));
|
| 166 |
+
});
|
| 167 |
+
};
|
| 168 |
+
const replay = el("button", { type: "button", class: "btn", text: "Ver de nuevo" });
|
| 169 |
+
replay.addEventListener("click", () => { dots.forEach((c) => { const i = c.datum(); c.interrupt().attr("fill", A.css("--c1")).attr("cy", 16 + Math.floor(i / 10) * cell); }); fall(); });
|
| 170 |
+
|
| 171 |
+
const say = share == null
|
| 172 |
+
? rich("p", { class: "say" }, [`No hay ${quien}${tipoTxt} creadas en ${lugar} en ${st.anio}. Prueba otro año u otro lugar.`])
|
| 173 |
+
: rich("p", { class: "say" }, [`De las `, { b: n(r.empresas) }, ` ${quien}${tipoTxt} que se crearon en `, { b: lugar }, ` en ${st.anio}, hoy siguen activas `, { b: n(r.activas) }, `: ${k} de cada 100.`]);
|
| 174 |
+
const cmp = [];
|
| 175 |
+
const fact = (big, text) => el("div", { class: "fact" }, el("p", { class: "big", text: big }), rich("p", {}, text));
|
| 176 |
+
const rn = pick(Snat);
|
| 177 |
+
if (st.camara && rn.empresas) cmp.push(fact(`${Math.round(100 * rn.activas / rn.empresas)} de 100`, [`en todo el país, para las ${quien}${tipoTxt} creadas en ${st.anio}.`]));
|
| 178 |
+
if (Splace) { const rp = pick(Splace); if (rp.empresas) cmp.push(fact(`${Math.round(100 * rp.activas / rp.empresas)} de 100`, [`en ${lugar}, para todas las actividades creadas en ${st.anio}${tipoTxt}.`])); }
|
| 179 |
+
if (!st.camara && a.kind !== "todas") {
|
| 180 |
+
const all = await series(where(tipo)); if (mine !== run) return;
|
| 181 |
+
const ra = pick(all); if (ra.empresas) cmp.push(fact(`${Math.round(100 * ra.activas / ra.empresas)} de 100`, [`en todo el país, para todas las actividades creadas en ${st.anio}${tipoTxt}.`]));
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// Every year at once: which cohorts kept more.
|
| 185 |
+
const f = figure({ title: `De cada 100, cuántas siguen activas, según el año en que se crearon`,
|
| 186 |
+
sub: `${A.cap(quien)}${tipoTxt} en ${lugar}. Las más antiguas han tenido más tiempo para cerrar. Resaltado, ${st.anio}.`,
|
| 187 |
+
sql: `SELECT formation_year AS anio, sum(empresas) AS empresas, sum(activas) AS activas\nFROM explorer\nWHERE ${here}\n AND formation_year BETWEEN ${fromOf()} AND ${LAST}\nGROUP BY 1 ORDER BY 1`,
|
| 188 |
+
source: "RUES · Confecámaras. Cálculos de AMC." });
|
| 189 |
+
const shown = S.filter((x) => x.empresas > 0);
|
| 190 |
+
columns(f.body, shown.map((x) => {
|
| 191 |
+
const v = 100 * x.activas / x.empresas, me = x.anio === st.anio;
|
| 192 |
+
return { label: String(x.anio), value: v, color: me ? "var(--c2)" : "var(--c1)", callout: me ? String(Math.round(v)) : null,
|
| 193 |
+
tip: { title: `Creadas en ${x.anio}`, rows: [{ label: "Siguen activas", value: `${Math.round(v)} de 100` }, { label: "Creadas", value: n(x.empresas) }, { label: "Activas hoy", value: n(x.activas) }] } };
|
| 194 |
+
}), { label: "De cada 100 empresas, cuántas siguen activas, por año de creación", max: 100, yFormat: (t) => String(t), unit: "De cada 100",
|
| 195 |
+
labelEvery: (W) => (W < 600 ? 10 : 5) });
|
| 196 |
+
f.fig.append(tableView("De cada 100, cuántas siguen activas, por año de creación", ["Año", "Creadas", "Activas hoy", "De cada 100"],
|
| 197 |
+
shown.map((x) => [String(x.anio), n(x.empresas), n(x.activas), String(Math.round(100 * x.activas / x.empresas))]).reverse()));
|
| 198 |
+
|
| 199 |
+
const warn = r.empresas && r.empresas < MIN ? el("p", { class: "warn", text: `Son solo ${n(r.empresas)} empresas: con tan pocas, una sola mueve mucho el resultado.` }) : null;
|
| 200 |
+
out.replaceChildren(
|
| 201 |
+
el("div", { class: "verdict" }, el("div", { class: "dots" }, svg.node()),
|
| 202 |
+
el("div", {}, el("p", { class: "big" }, share == null ? "—" : String(k), el("span", { text: " de 100" })), say, warn, el("div", { class: "acts" }, replay))),
|
| 203 |
+
cmp.length ? el("div", { class: "compare" }, ...cmp) : "",
|
| 204 |
+
f.fig);
|
| 205 |
+
A.reveal(out);
|
| 206 |
+
if (share != null) fall();
|
| 207 |
+
}
|
| 208 |
+
render();
|
| 209 |
+
window.__amcReady = true;
|
| 210 |
+
} catch (e) { A.fail(app, e, "la herramienta"); }
|
| 211 |
+
</script>
|
| 212 |
+
</body>
|
| 213 |
+
</html>
|
historias/gobiernos/index.html
CHANGED
|
@@ -175,19 +175,28 @@ try {
|
|
| 175 |
p.en_curso ? "demasiado pronto" : p.completo ? "completa" : `parcial (hasta ${s.year - 4})`])));
|
| 176 |
|
| 177 |
// ------------------------------------------------------------- 5. sectors
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
const S = st.q("sectores");
|
| 179 |
const totals = Object.fromEntries(P.map((p) => [p.periodo, S.filter((r) => r.periodo === p.periodo).reduce((a, r) => a + r.creadas, 0)]));
|
| 180 |
-
const
|
|
|
|
| 181 |
const share = (sec, per) => { const r = S.find((x) => x.seccion === sec && x.periodo === per); return r ? r.creadas / totals[per] : null; };
|
| 182 |
-
const main = secs.filter((sec) =>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
const f5 = figure({ title: "Qué tipo de empresas: el sector de las creadas en cada gobierno",
|
| 184 |
-
sub:
|
| 185 |
sql: st.sql("sectores") });
|
| 186 |
matrix(f5.body, { label: "Sector de las empresas creadas por gobierno",
|
| 187 |
-
rows: main, cols:
|
| 188 |
value: (r, c) => share(r.key, c.key), rowRelative: true, format: (v) => `${Math.round(v * 100)}`, unit: "Del total del periodo", note: () => "Cifras en porcentaje del periodo." });
|
| 189 |
-
f5.fig.append(tableView("Sector de las empresas creadas por gobierno (%)", ["Sector", ...
|
| 190 |
-
secs.map((sec) => [sec.label, ...
|
| 191 |
|
| 192 |
// ------------------------------------------------------------- 6. chambers
|
| 193 |
const C = st.q("camaras");
|
|
@@ -227,7 +236,8 @@ try {
|
|
| 227 |
["Esto ", { b: "no es una tasa de supervivencia" }, ". El registro no guarda la historia de renovaciones de cada empresa, solo la última, así que no se puede trazar una curva de supervivencia honesta (decisión D21 de la metodología)."],
|
| 228 |
["Las empresas sin año de renovación conocido —más frecuentes en los años noventa— se excluyen en lugar de contarse como cerradas. El periodo 2022–2026 es parcial: solo las empresas creadas hasta ", { b: String(s.year - 4) }, " han tenido ya tres años completos para renovar; las renovaciones tardías de este año siguen llegando hasta diciembre."]),
|
| 229 |
prose({ h2: "Qué empresas y dónde" },
|
| 230 |
-
|
|
|
|
| 231 |
f5.fig,
|
| 232 |
prose("Bogotá encabeza todos los periodos; detrás, el orden de las demás cámaras sí se mueve. Cada línea es una cámara de comercio, ordenada por las empresas creadas en su jurisdicción."),
|
| 233 |
f6.fig,
|
|
|
|
| 175 |
p.en_curso ? "demasiado pronto" : p.completo ? "completa" : `parcial (hasta ${s.year - 4})`])));
|
| 176 |
|
| 177 |
// ------------------------------------------------------------- 5. sectors
|
| 178 |
+
// Sectors only for the periods that began once every company carried its
|
| 179 |
+
// CIIU rev. 4 sector (ops/stories.py, ACT_FROM): earlier, the sectors known
|
| 180 |
+
// are mostly those of the companies that survived, and a comparison across
|
| 181 |
+
// them would compare survivors with everyone (found 2026-10-20).
|
| 182 |
const S = st.q("sectores");
|
| 183 |
const totals = Object.fromEntries(P.map((p) => [p.periodo, S.filter((r) => r.periodo === p.periodo).reduce((a, r) => a + r.creadas, 0)]));
|
| 184 |
+
const PS = P.filter((p) => totals[p.periodo] > 0);
|
| 185 |
+
const secs = [...new Map(S.map((r) => [r.seccion, r.sector])).entries()].map(([code, label]) => ({ key: code, label: `${code} · ${A.shortActivity(label, 44)}`, short: `${code} · ${label.split(/[;,]/)[0]}`, word: label.split(/[;,]/)[0].toLowerCase() }));
|
| 186 |
const share = (sec, per) => { const r = S.find((x) => x.seccion === sec && x.periodo === per); return r ? r.creadas / totals[per] : null; };
|
| 187 |
+
const main = secs.filter((sec) => PS.some((p) => (share(sec.key, p.periodo) || 0) >= 0.02));
|
| 188 |
+
const doneS = PS.filter((p) => !p.en_curso), pA = doneS[0], pB = doneS[doneS.length - 1];
|
| 189 |
+
const moves = main.map((sec) => ({ sec, d: (share(sec.key, pB.periodo) || 0) - (share(sec.key, pA.periodo) || 0) })).sort((a, b) => b.d - a.d);
|
| 190 |
+
const gRange = PS.map((p) => share("G", p.periodo)).filter((v) => v != null);
|
| 191 |
+
const pts = (d) => `${d > 0 ? "+" : d < 0 ? "−" : ""}${A.n1(Math.abs(d) * 100)} pts`;
|
| 192 |
const f5 = figure({ title: "Qué tipo de empresas: el sector de las creadas en cada gobierno",
|
| 193 |
+
sub: `Porcentaje de las empresas creadas en cada periodo en cada sector, desde ${PS[0].periodo}: antes, buena parte de las empresas creadas no tiene sector en la clasificación actual, y las que sí lo tienen son sobre todo las que siguen activas. El color compara cada sector consigo mismo: más oscuro, el periodo en que más pesó. Se muestran los sectores que superan el 2% en algún periodo.`,
|
| 194 |
sql: st.sql("sectores") });
|
| 195 |
matrix(f5.body, { label: "Sector de las empresas creadas por gobierno",
|
| 196 |
+
rows: main, cols: PS.map((p) => ({ key: p.periodo, label: p.periodo.replace(" ", "\n"), short: p.periodo.split(" ").map((w) => w.slice(0, 3)).join("\n"), title: who(p) })),
|
| 197 |
value: (r, c) => share(r.key, c.key), rowRelative: true, format: (v) => `${Math.round(v * 100)}`, unit: "Del total del periodo", note: () => "Cifras en porcentaje del periodo." });
|
| 198 |
+
f5.fig.append(tableView("Sector de las empresas creadas por gobierno (%)", ["Sector", ...PS.map((p) => p.periodo)],
|
| 199 |
+
secs.map((sec) => [sec.label, ...PS.map((p) => { const v = share(sec.key, p.periodo); return v == null ? "—" : pct(v); })])));
|
| 200 |
|
| 201 |
// ------------------------------------------------------------- 6. chambers
|
| 202 |
const C = st.q("camaras");
|
|
|
|
| 236 |
["Esto ", { b: "no es una tasa de supervivencia" }, ". El registro no guarda la historia de renovaciones de cada empresa, solo la última, así que no se puede trazar una curva de supervivencia honesta (decisión D21 de la metodología)."],
|
| 237 |
["Las empresas sin año de renovación conocido —más frecuentes en los años noventa— se excluyen en lugar de contarse como cerradas. El periodo 2022–2026 es parcial: solo las empresas creadas hasta ", { b: String(s.year - 4) }, " han tenido ya tres años completos para renovar; las renovaciones tardías de este año siguen llegando hasta diciembre."]),
|
| 238 |
prose({ h2: "Qué empresas y dónde" },
|
| 239 |
+
[`Desde ${PS[0].periodo}, el comercio domina todos los periodos: entre el ${pct(Math.min(...gRange))} y el ${pct(Math.max(...gRange))} de las empresas creadas. Entre ${pA.periodo} y ${pB.periodo}, el sector que más ganó peso fue `, { b: moves[0].sec.word }, ` (${pts(moves[0].d)}) y el que más perdió, `, { b: moves[moves.length - 1].sec.word }, ` (${pts(moves[moves.length - 1].d)}).`],
|
| 240 |
+
[`Los gobiernos anteriores a ${PS[0].periodo} no entran en esta comparación: entre las empresas que crearon, buena parte no tiene sector en la clasificación actual (la CIIU rev. 4, que el registro adoptó en 2013), y las que lo tienen son sobre todo las que sobrevivieron.`]),
|
| 241 |
f5.fig,
|
| 242 |
prose("Bogotá encabeza todos los periodos; detrás, el orden de las demás cámaras sí se mueve. Cada línea es una cámara de comercio, ordenada por las empresas creadas en su jurisdicción."),
|
| 243 |
f6.fig,
|
historias/mapa/index.html
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="es" data-root="../../">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>El país que se llena de empresas · AMC</title>
|
| 7 |
+
<meta name="description" content="Cuántas empresas nacen cada año por cada 100.000 habitantes en cada región de Colombia, de 1993 a hoy, en un mapa que se mueve. Con población del DANE.">
|
| 8 |
+
<meta property="og:title" content="El país que se llena de empresas">
|
| 9 |
+
<meta property="og:description" content="Cuántas empresas nacen cada año por cada 100.000 habitantes en cada región de Colombia, de 1993 a hoy, en un mapa que se mueve.">
|
| 10 |
+
<meta property="og:type" content="article">
|
| 11 |
+
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
|
| 12 |
+
<meta property="og:image" content="https://amc.clyxconsulting.com/assets/og/mapa.png">
|
| 13 |
+
<meta property="og:image:width" content="1200">
|
| 14 |
+
<meta property="og:image:height" content="630">
|
| 15 |
+
<meta property="og:site_name" content="Analíticas Mercantiles Colombianas">
|
| 16 |
+
<meta name="twitter:card" content="summary_large_image">
|
| 17 |
+
<meta name="twitter:image" content="https://amc.clyxconsulting.com/assets/og/mapa.png">
|
| 18 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 19 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 20 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 21 |
+
<link rel="stylesheet" href="../../assets/amc.css">
|
| 22 |
+
<link rel="stylesheet" href="../../assets/nav.css">
|
| 23 |
+
<style>
|
| 24 |
+
.controls input[type="range"] { accent-color: var(--c1); }
|
| 25 |
+
</style>
|
| 26 |
+
<link rel="canonical" href="https://amc.clyxconsulting.com/historias/mapa/">
|
| 27 |
+
<meta property="og:url" content="https://amc.clyxconsulting.com/historias/mapa/">
|
| 28 |
+
<meta property="og:locale" content="es_CO">
|
| 29 |
+
<meta property="og:image:type" content="image/png">
|
| 30 |
+
<meta property="og:image:alt" content="El país que se llena de empresas">
|
| 31 |
+
</head>
|
| 32 |
+
<body>
|
| 33 |
+
<main class="wrap" id="app"><p class="loading">Cargando la historia…</p></main>
|
| 34 |
+
<noscript><p class="wrap">Esta página necesita JavaScript para dibujar sus gráficos.</p></noscript>
|
| 35 |
+
<script type="module">
|
| 36 |
+
import * as A from "../../assets/amc.js";
|
| 37 |
+
import { moreStories } from "../../assets/catalog.js";
|
| 38 |
+
import { timeMap, lineChart, barList } from "../../assets/charts.js";
|
| 39 |
+
const { el, n, rich, figure, prose, readThis, tableView, legend } = A;
|
| 40 |
+
|
| 41 |
+
A.chrome("historias/mapa");
|
| 42 |
+
const app = document.getElementById("app");
|
| 43 |
+
const MEASURES = {
|
| 44 |
+
todas: { label: "Todas", long: "empresas", get: (r) => r.creadas },
|
| 45 |
+
juridicas: { label: "Sociedades y entidades", long: "sociedades y entidades", get: (r) => r.juridicas },
|
| 46 |
+
naturales: { label: "Comerciantes", long: "comerciantes personas naturales", get: (r) => r.creadas - r.juridicas },
|
| 47 |
+
};
|
| 48 |
+
const per = (v, pop) => (1e5 * v) / pop;
|
| 49 |
+
const x1 = (v) => `×${A.n1(v).replace(/,0$/, "")}`;
|
| 50 |
+
// Class breaks pooled over every region and year, at two significant digits:
|
| 51 |
+
// one key for the whole film, so a colour means the same in 1993 and today.
|
| 52 |
+
function breaksOf(values) {
|
| 53 |
+
const v = [...values].sort((a, b) => a - b);
|
| 54 |
+
const q = (p) => v[Math.min(v.length - 1, Math.floor(p * v.length))];
|
| 55 |
+
const nice = (x) => { const m = 10 ** (Math.floor(Math.log10(x)) - 1); return Math.round(x / m) * m; };
|
| 56 |
+
return [0.2, 0.4, 0.6, 0.8].map((p) => nice(q(p)));
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
try {
|
| 60 |
+
const [s, st] = await Promise.all([A.summary(), A.story("mapa")]);
|
| 61 |
+
const R = st.q("regiones"), C = st.q("camaras");
|
| 62 |
+
const years = [...new Set(R.map((r) => r.anio))].sort((a, b) => a - b);
|
| 63 |
+
const first = years[0], last = years[years.length - 1];
|
| 64 |
+
const byRY = new Map(R.map((r) => [`${r.region}|${r.anio}`, r]));
|
| 65 |
+
const byCY = new Map(C.map((c) => [`${c.codigo_camara}|${c.anio}`, c]));
|
| 66 |
+
const regionOf = new Map(C.map((c) => [c.codigo_camara, c.region]));
|
| 67 |
+
const camaraOf = new Map(C.map((c) => [c.codigo_camara, A.title(c.camara)]));
|
| 68 |
+
const regions = [...new Set(R.map((r) => r.region))].sort((a, b) => a.localeCompare(b, "es"));
|
| 69 |
+
const nation = years.map((y) => {
|
| 70 |
+
const rows = R.filter((r) => r.anio === y);
|
| 71 |
+
const pop = rows.reduce((t, r) => t + r.poblacion, 0);
|
| 72 |
+
return { anio: y, pop, ...Object.fromEntries(Object.entries(MEASURES).map(([k, m]) => [k, rows.reduce((t, r) => t + m.get(r), 0)])) };
|
| 73 |
+
});
|
| 74 |
+
const natRate = (k, y) => { const r = nation.find((x) => x.anio === y); return per(r[k], r.pop); };
|
| 75 |
+
const lastRows = regions.map((g) => byRY.get(`${g}|${last}`)).filter(Boolean)
|
| 76 |
+
.map((r) => ({ region: r.region, rate: per(r.creadas, r.poblacion), r })).sort((a, b) => b.rate - a.rate);
|
| 77 |
+
const top = lastRows[0], bottom = lastRows[lastRows.length - 1];
|
| 78 |
+
|
| 79 |
+
const head = el("header", { class: "story-head" },
|
| 80 |
+
el("p", { class: "kicker", text: "Historia · Regiones · Animada" }),
|
| 81 |
+
el("h1", { text: "El país que se llena de empresas" }),
|
| 82 |
+
el("p", { class: "dek", text: `Cuántas empresas nacen cada año por cada 100.000 habitantes, región por región, de ${first} a ${last}. Dale «reproducir» y mira cómo se llena el mapa.` }),
|
| 83 |
+
el("div", { class: "meta" }, el("span", { class: "chip", text: `Corte del ${A.date(s.snapshot)}` }), el("span", { class: "chip", text: "Población: DANE" }), A.shareButton()));
|
| 84 |
+
|
| 85 |
+
const findings = el("div", { class: "findings" },
|
| 86 |
+
el("div", { class: "finding reveal" }, el("p", { class: "n", text: x1(natRate("todas", last) / natRate("todas", first)) }),
|
| 87 |
+
rich("p", {}, [`más empresas por habitante nacen hoy que en ${first}: `, { b: `${n(natRate("todas", first))} por cada 100.000 habitantes` }, ` entonces, ${n(natRate("todas", last))} en ${last}.`])),
|
| 88 |
+
el("div", { class: "finding reveal" }, el("p", { class: "n", text: n(top.rate) }),
|
| 89 |
+
rich("p", {}, [`empresas por cada 100.000 habitantes nacieron en ${last} en `, { b: top.region }, `, la región que más crea; en ${bottom.region}, ${n(bottom.rate)}: ${A.n1(top.rate / bottom.rate)} veces menos.`])),
|
| 90 |
+
el("div", { class: "finding reveal" }, el("p", { class: "n", text: x1(natRate("juridicas", last) / natRate("juridicas", first)) }),
|
| 91 |
+
rich("p", {}, ["se multiplicó desde ", String(first), " la creación de ", { b: "sociedades y entidades" }, ` por habitante; la de comerciantes personas naturales, ${x1(natRate("naturales", last) / natRate("naturales", first))}.`])));
|
| 92 |
+
|
| 93 |
+
// 1. The map, year by year.
|
| 94 |
+
const f1 = figure({ title: "Empresas nacidas por cada 100.000 habitantes, cada año",
|
| 95 |
+
sub: "Cada color es una región: las cámaras de comercio de un mismo departamento comparten el suyo. La escala es la misma para todos los años. Pasa el cursor por el mapa para ver la región y la cámara.",
|
| 96 |
+
sql: st.sql("regiones"), source: "RUES · Confecámaras; población: DANE. Cálculos de AMC." });
|
| 97 |
+
let measure = "todas";
|
| 98 |
+
const framesOf = (m) => years.map((y) => ({ label: String(y),
|
| 99 |
+
values: Object.fromEntries([...regionOf].map(([code, reg]) => { const r = byRY.get(`${reg}|${y}`); return [code, r ? per(MEASURES[m].get(r), r.poblacion) : NaN]; })) }));
|
| 100 |
+
const brk = (m) => breaksOf(R.map((r) => per(MEASURES[m].get(r), r.poblacion)));
|
| 101 |
+
const segm = el("div", { class: "seg-ctl", role: "group", "aria-label": "Qué empresas" },
|
| 102 |
+
...Object.entries(MEASURES).map(([k, m]) => el("button", { type: "button", "data-k": k, "aria-pressed": String(k === measure), text: m.label })));
|
| 103 |
+
f1.body.append(el("div", { class: "controls" }, segm));
|
| 104 |
+
const map = timeMap(f1.body, { label: "Mapa de las empresas nacidas por cada 100.000 habitantes, por región y año", frames: framesOf(measure), breaks: brk(measure), step: 800,
|
| 105 |
+
format: (v) => n(v),
|
| 106 |
+
tip: (code, i) => {
|
| 107 |
+
const y = years[i], reg = regionOf.get(code), r = byRY.get(`${reg}|${y}`), c = byCY.get(`${code}|${y}`), m = MEASURES[measure];
|
| 108 |
+
if (!r) return { title: camaraOf.get(code) || "Cámara de comercio", rows: [] };
|
| 109 |
+
return { title: `${reg} · ${y}`, rows: [
|
| 110 |
+
{ label: `${A.cap(m.long)} por cada 100.000 habitantes`, value: n(per(m.get(r), r.poblacion)) },
|
| 111 |
+
{ label: `${A.cap(m.long)} creadas en la región`, value: n(m.get(r)) },
|
| 112 |
+
{ label: "Habitantes", value: n(r.poblacion) },
|
| 113 |
+
{ label: `En la cámara de ${camaraOf.get(code)}`, value: c ? n(m.get(c)) : "—" }] };
|
| 114 |
+
} });
|
| 115 |
+
segm.addEventListener("click", (e) => {
|
| 116 |
+
const b = e.target.closest("button[data-k]"); if (!b) return;
|
| 117 |
+
measure = b.dataset.k;
|
| 118 |
+
for (const x of segm.children) x.setAttribute("aria-pressed", String(x === b));
|
| 119 |
+
map.set(framesOf(measure), brk(measure));
|
| 120 |
+
});
|
| 121 |
+
f1.fig.append(tableView("Empresas creadas por cada 100.000 habitantes, por región y año", ["Región", "Año", "Creadas", "Sociedades y entidades", "Comerciantes", "Habitantes", "Por 100.000 habitantes"],
|
| 122 |
+
R.map((r) => [r.region, String(r.anio), n(r.creadas), n(r.juridicas), n(r.creadas - r.juridicas), n(r.poblacion), n(per(r.creadas, r.poblacion))])));
|
| 123 |
+
|
| 124 |
+
// 2. The country as a whole.
|
| 125 |
+
const f2 = figure({ title: "Todo el país, año por año",
|
| 126 |
+
sub: "Empresas nacidas por cada 100.000 habitantes: sociedades y entidades, y comerciantes personas naturales.", sql: st.sql("regiones"),
|
| 127 |
+
source: "RUES · Confecámaras; población: DANE. Cálculos de AMC." });
|
| 128 |
+
f2.body.append(legend([{ label: "Comerciantes", color: "var(--c2)" }, { label: "Sociedades y entidades", color: "var(--c1)" }]));
|
| 129 |
+
const at = (y) => new Date(Date.UTC(y, 0, 1));
|
| 130 |
+
lineChart(f2.body, { label: "Empresas nacidas por cada 100.000 habitantes en todo el país", height: 280, animate: false, yMin: 0, yFormat: (v) => n(v),
|
| 131 |
+
series: [{ color: "var(--c2)", values: nation.map((r) => ({ x: at(r.anio), y: per(r.naturales, r.pop) })) },
|
| 132 |
+
{ color: "var(--c1)", values: nation.map((r) => ({ x: at(r.anio), y: per(r.juridicas, r.pop) })) }],
|
| 133 |
+
tip: (x, i) => ({ title: String(nation[i].anio), rows: [
|
| 134 |
+
{ label: "Comerciantes por 100.000 hab.", value: n(per(nation[i].naturales, nation[i].pop)), color: A.css("--c2") },
|
| 135 |
+
{ label: "Sociedades y entidades por 100.000 hab.", value: n(per(nation[i].juridicas, nation[i].pop)), color: A.css("--c1") }] }) });
|
| 136 |
+
f2.fig.append(tableView("Empresas nacidas por cada 100.000 habitantes en todo el país", ["Año", "Todas", "Sociedades y entidades", "Comerciantes", "Habitantes"],
|
| 137 |
+
nation.map((r) => [String(r.anio), n(per(r.todas, r.pop)), n(per(r.juridicas, r.pop)), n(per(r.naturales, r.pop)), n(r.pop)])));
|
| 138 |
+
|
| 139 |
+
// 3. The regions in the last year.
|
| 140 |
+
const f3 = figure({ title: `Las regiones en ${last}`, sub: `Empresas nacidas en ${last} por cada 100.000 habitantes.`, sql: st.sql("regiones"),
|
| 141 |
+
source: "RUES · Confecámaras; población: DANE. Cálculos de AMC." });
|
| 142 |
+
barList(f3.body, lastRows.map((x) => ({ label: x.region, value: x.rate, valueText: n(x.rate), strong: x === top,
|
| 143 |
+
tip: { title: x.region, rows: [{ label: "Por 100.000 habitantes", value: n(x.rate) }, { label: "Empresas creadas", value: n(x.r.creadas) }, { label: "Habitantes", value: n(x.r.poblacion) }] } })),
|
| 144 |
+
{ labelWidth: 230, reserve: 60 });
|
| 145 |
+
|
| 146 |
+
app.replaceChildren(head, findings,
|
| 147 |
+
prose({ h2: "Un mapa que se llena" },
|
| 148 |
+
["Contar las empresas que nacen en cada región favorece a las grandes: Bogotá crea más que nadie. Dividir por la población cambia la pregunta: ", { b: "¿dónde nacen más empresas por persona?" }],
|
| 149 |
+
[`En ${first} nacían ${n(natRate("todas", first))} empresas por cada 100.000 habitantes; en ${last}, ${n(natRate("todas", last))}. Dale «reproducir»: el mapa se oscurece a medida que el país crea más empresas por habitante. Con los botones, el mapa cambia entre todas las empresas, las sociedades y entidades, y los comerciantes.`]),
|
| 150 |
+
f1.fig,
|
| 151 |
+
prose(["El crecimiento no es parejo. Las ", { b: "sociedades y entidades" }, ` nacen hoy ${x1(natRate("juridicas", last) / natRate("juridicas", first))} más por habitante que en ${first}; los comerciantes personas naturales, ${x1(natRate("naturales", last) / natRate("naturales", first))}.`]),
|
| 152 |
+
f2.fig,
|
| 153 |
+
prose([`En ${last}, la región que más empresas crea para su población es ${top.region}, con ${n(top.rate)} por cada 100.000 habitantes. La que menos, ${bottom.region}, con ${n(bottom.rate)}.`]),
|
| 154 |
+
f3.fig,
|
| 155 |
+
readThis(["Las regiones juntan departamentos y cámaras de comercio según sus jurisdicciones (Decreto 1074 de 2015): ", { b: "Bogotá y Cundinamarca" }, " van juntas, porque la Cámara de Bogotá cubre buena parte de Cundinamarca, y también ", { b: "Meta, Vichada, Guainía y Vaupés" }, ". Una cámara creada después de 1990 sigue dentro de su región, así que la serie no salta cuando abre."],
|
| 156 |
+
["Se cuentan las empresas ", { b: "creadas" }, " cada año, también las que después cerraron: el mapa muestra cuántas nacen, no cuántas siguen. Una empresa cuenta en la región de la cámara de su matrícula principal, en el año de su primera matrícula."],
|
| 157 |
+
[`La población es la del DANE: retroproyecciones y proyecciones departamentales con base en el censo de 2018, desde ${first}. El año en curso no aparece: aún no termina.`]),
|
| 158 |
+
moreStories("mapa"));
|
| 159 |
+
A.footer(s);
|
| 160 |
+
A.reveal();
|
| 161 |
+
window.__amcReady = true;
|
| 162 |
+
} catch (e) { A.fail(app, e); }
|
| 163 |
+
</script>
|
| 164 |
+
</body>
|
| 165 |
+
</html>
|
historias/software/index.html
CHANGED
|
@@ -44,7 +44,10 @@ try {
|
|
| 44 |
const Y = st.q("anual"), ACT = st.q("activas"), CL = st.q("clases");
|
| 45 |
const years = [...new Set(Y.map((r) => r.anio))].sort((a, b) => a - b);
|
| 46 |
const nat = years.map((y) => ({ y, v: Y.filter((r) => r.anio === y).reduce((a, r) => a + r.creadas, 0) }));
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
const vY = (y) => (nat.find((r) => r.y === y) || {}).v;
|
| 49 |
// The pandemic year against the one before it, and that one against its own predecessor.
|
| 50 |
const g20 = vY(2020) && vY(2019) ? vY(2020) / vY(2019) - 1 : null, g19 = vY(2019) && vY(2018) ? vY(2019) / vY(2018) - 1 : null;
|
|
@@ -62,9 +65,9 @@ try {
|
|
| 62 |
|
| 63 |
const findings = el("div", { class: "findings" },
|
| 64 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `${A.n1(vL / v10)}×` }),
|
| 65 |
-
rich("p", {}, [`empresas de software y servicios de información se crearon en ${yL} frente a
|
| 66 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: pct(bog.activas_tic / totalLive) }),
|
| 67 |
-
rich("p", {}, ["de las empresas activas del sector están en ", { b: "Bogotá" }, `. En
|
| 68 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: short(dense[0].camara) }),
|
| 69 |
rich("p", {}, ["es la cámara donde el sector pesa más entre sus empresas activas: el ", { b: A.pct1(dense[0].d) }, ", frente al ", { b: A.pct1(totalLive / ACT.reduce((a, r) => a + r.activas_total, 0)) }, " del país."])));
|
| 70 |
|
|
@@ -94,15 +97,16 @@ try {
|
|
| 94 |
f4.fig.append(tableView("Empresas activas del sector por actividad", ["Actividad", "Activas"], CL.map((r) => [r.descripcion, n(r.activas)])));
|
| 95 |
|
| 96 |
app.replaceChildren(head, findings,
|
| 97 |
-
prose({ h2: "Un sector que se multiplicó" },
|
| 98 |
-
[`En
|
| 99 |
f1.fig,
|
| 100 |
prose(["Bogotá concentra la mayor parte del sector, pero no está sola. Medellín, Cali, Barranquilla y Bucaramanga tienen comunidades propias, y en cada una la curva tiene su forma."]),
|
| 101 |
f2.fig,
|
| 102 |
prose(["Medido como peso dentro de cada economía local, el mapa cambia: en ", { b: short(dense[0].camara) }, `, el sector es el ${A.pct1(dense[0].d)} de las empresas activas.`]),
|
| 103 |
f3.fig, f4.fig,
|
| 104 |
readThis(["Se cuentan las empresas cuya actividad ", { b: "principal y actual" }, " está en las divisiones 62 y 63 de la CIIU Rev. 4 A.C.: desarrollo de software, consultoría informática, gestión de equipos, procesamiento de datos, alojamiento web y portales. Una empresa de otro sector que desarrolla software como actividad secundaria no aparece."],
|
| 105 |
-
["La cámara es la de la matrícula principal de la empresa, no necesariamente la ciudad donde trabaja su equipo."]
|
|
|
|
| 106 |
moreStories("software"));
|
| 107 |
A.footer(s);
|
| 108 |
A.reveal();
|
|
|
|
| 44 |
const Y = st.q("anual"), ACT = st.q("activas"), CL = st.q("clases");
|
| 45 |
const years = [...new Set(Y.map((r) => r.anio))].sort((a, b) => a - b);
|
| 46 |
const nat = years.map((y) => ({ y, v: Y.filter((r) => r.anio === y).reduce((a, r) => a + r.creadas, 0) }));
|
| 47 |
+
// From 2013 (ops/stories.py ACT_FROM): a software company that closed
|
| 48 |
+
// earlier mostly never had its activity converted to CIIU rev. 4, so earlier
|
| 49 |
+
// years would leave out the ones that closed and overstate the growth.
|
| 50 |
+
const y0 = years[0], yL = years[years.length - 1], vL = nat.find((r) => r.y === yL).v, v10 = nat[0].v;
|
| 51 |
const vY = (y) => (nat.find((r) => r.y === y) || {}).v;
|
| 52 |
// The pandemic year against the one before it, and that one against its own predecessor.
|
| 53 |
const g20 = vY(2020) && vY(2019) ? vY(2020) / vY(2019) - 1 : null, g19 = vY(2019) && vY(2018) ? vY(2019) / vY(2018) - 1 : null;
|
|
|
|
| 65 |
|
| 66 |
const findings = el("div", { class: "findings" },
|
| 67 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `${A.n1(vL / v10)}×` }),
|
| 68 |
+
rich("p", {}, [`empresas de software y servicios de información se crearon en ${yL} frente a ${y0}: `, { b: n(vL) }, " contra ", { b: n(v10) }, "."])),
|
| 69 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: pct(bog.activas_tic / totalLive) }),
|
| 70 |
+
rich("p", {}, ["de las empresas activas del sector están en ", { b: "Bogotá" }, `. En ${y0} la capital creaba el ${pct(bogShare(y0))} de las nuevas; en ${yL}, el ${pct(bogShare(yL))}.`])),
|
| 71 |
el("div", { class: "finding reveal" }, el("p", { class: "n", text: short(dense[0].camara) }),
|
| 72 |
rich("p", {}, ["es la cámara donde el sector pesa más entre sus empresas activas: el ", { b: A.pct1(dense[0].d) }, ", frente al ", { b: A.pct1(totalLive / ACT.reduce((a, r) => a + r.activas_total, 0)) }, " del país."])));
|
| 73 |
|
|
|
|
| 97 |
f4.fig.append(tableView("Empresas activas del sector por actividad", ["Actividad", "Activas"], CL.map((r) => [r.descripcion, n(r.activas)])));
|
| 98 |
|
| 99 |
app.replaceChildren(head, findings,
|
| 100 |
+
prose({ h2: vL >= 2 * v10 ? "Un sector que se multiplicó" : "Un sector que crece" },
|
| 101 |
+
[`En ${y0} se crearon en Colombia ${n(v10)} empresas de software y servicios de información. En ${yL}, ${n(vL)}. El crecimiento no fue parejo, pero sí sostenido${g20 != null && g19 != null ? `: en 2020, el año de la pandemia, se crearon un ${pct(Math.abs(g20))} ${g20 >= 0 ? "más" : "menos"} que en 2019${g20 > 0 && g20 < g19 ? `, aunque el año anterior el sector había crecido más, un ${pct(g19)}` : ""}` : ""}.`]),
|
| 102 |
f1.fig,
|
| 103 |
prose(["Bogotá concentra la mayor parte del sector, pero no está sola. Medellín, Cali, Barranquilla y Bucaramanga tienen comunidades propias, y en cada una la curva tiene su forma."]),
|
| 104 |
f2.fig,
|
| 105 |
prose(["Medido como peso dentro de cada economía local, el mapa cambia: en ", { b: short(dense[0].camara) }, `, el sector es el ${A.pct1(dense[0].d)} de las empresas activas.`]),
|
| 106 |
f3.fig, f4.fig,
|
| 107 |
readThis(["Se cuentan las empresas cuya actividad ", { b: "principal y actual" }, " está en las divisiones 62 y 63 de la CIIU Rev. 4 A.C.: desarrollo de software, consultoría informática, gestión de equipos, procesamiento de datos, alojamiento web y portales. Una empresa de otro sector que desarrolla software como actividad secundaria no aparece."],
|
| 108 |
+
["La cámara es la de la matrícula principal de la empresa, no necesariamente la ciudad donde trabaja su equipo."],
|
| 109 |
+
[`Los años empiezan en ${y0}: antes, la mayoría de las empresas del sector que cerraron no tiene su actividad en la clasificación actual (CIIU rev. 4), y contar solo las que la tienen inflaría el crecimiento.`]),
|
| 110 |
moreStories("software"));
|
| 111 |
A.footer(s);
|
| 112 |
A.reveal();
|
historias/termometro/index.html
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="es" data-root="../../">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>El registro como termómetro · AMC</title>
|
| 7 |
+
<meta name="description" content="Las sociedades que se crean cada trimestre suben y bajan con la economía, y se conocen semanas antes que el PIB. Los comerciantes siguen su propio ritmo. Con datos del DANE.">
|
| 8 |
+
<meta property="og:title" content="El registro como termómetro de la economía">
|
| 9 |
+
<meta property="og:description" content="Las sociedades que se crean cada trimestre suben y bajan con la economía, y se conocen semanas antes que el PIB. Los comerciantes siguen su propio ritmo.">
|
| 10 |
+
<meta property="og:type" content="article">
|
| 11 |
+
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
|
| 12 |
+
<meta property="og:image" content="https://amc.clyxconsulting.com/assets/og/termometro.png">
|
| 13 |
+
<meta property="og:image:width" content="1200">
|
| 14 |
+
<meta property="og:image:height" content="630">
|
| 15 |
+
<meta property="og:site_name" content="Analíticas Mercantiles Colombianas">
|
| 16 |
+
<meta name="twitter:card" content="summary_large_image">
|
| 17 |
+
<meta name="twitter:image" content="https://amc.clyxconsulting.com/assets/og/termometro.png">
|
| 18 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 19 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 20 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 21 |
+
<link rel="stylesheet" href="../../assets/amc.css">
|
| 22 |
+
<link rel="stylesheet" href="../../assets/nav.css">
|
| 23 |
+
<style>
|
| 24 |
+
.panel-t { margin: 10px 0 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
|
| 25 |
+
.readout { margin: 0 0 6px; font-size: 15px; color: var(--ink-2); }
|
| 26 |
+
.readout b { color: var(--ink); }
|
| 27 |
+
.controls input[type="range"] { accent-color: var(--c1); }
|
| 28 |
+
</style>
|
| 29 |
+
<link rel="canonical" href="https://amc.clyxconsulting.com/historias/termometro/">
|
| 30 |
+
<meta property="og:url" content="https://amc.clyxconsulting.com/historias/termometro/">
|
| 31 |
+
<meta property="og:locale" content="es_CO">
|
| 32 |
+
<meta property="og:image:type" content="image/png">
|
| 33 |
+
<meta property="og:image:alt" content="El registro como termómetro de la economía">
|
| 34 |
+
</head>
|
| 35 |
+
<body>
|
| 36 |
+
<main class="wrap" id="app"><p class="loading">Cargando la historia…</p></main>
|
| 37 |
+
<noscript><p class="wrap">Esta página necesita JavaScript para dibujar sus gráficos.</p></noscript>
|
| 38 |
+
<script type="module">
|
| 39 |
+
import * as A from "../../assets/amc.js";
|
| 40 |
+
import { moreStories } from "../../assets/catalog.js";
|
| 41 |
+
import { lineChart, scatter, divergingBars } from "../../assets/charts.js";
|
| 42 |
+
const { el, rich, figure, prose, readThis, tableView, legend } = A;
|
| 43 |
+
|
| 44 |
+
A.chrome("historias/termometro");
|
| 45 |
+
const app = document.getElementById("app");
|
| 46 |
+
const SOURCE = "RUES · Confecámaras y DANE (PIB trimestral, Gran Encuesta Integrada de Hogares). Cálculos de AMC.";
|
| 47 |
+
// DANE's twelve groupings, in everyday words; the full names are in the table.
|
| 48 |
+
const SHORT = { "A": "Agro y pesca", "B": "Minería", "C": "Industria", "D+E": "Energía, gas y agua", "F": "Construcción",
|
| 49 |
+
"G+H+I": "Comercio, transporte y turismo", "J": "Información y comunicaciones", "K": "Finanzas y seguros", "L": "Inmobiliario",
|
| 50 |
+
"M+N": "Servicios profesionales", "O+P+Q": "Gobierno, educación y salud", "R+S+T": "Arte y otros servicios" };
|
| 51 |
+
const KIND = { sociedades: "Sociedades nuevas", naturales: "Comerciantes nuevos" };
|
| 52 |
+
const r2 = (r) => (Number.isFinite(r) ? r.toLocaleString("es-CO", { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : "—");
|
| 53 |
+
const sgn = (x) => (x == null ? "—" : `${x > 0 ? "+" : x < 0 ? "−" : ""}${A.pct1(Math.abs(x))}`);
|
| 54 |
+
const isPand = (iso) => iso >= "2020-01-01" && iso < "2022-01-01";
|
| 55 |
+
const qn = (iso) => (+iso.slice(5, 7) - 1) / 3;
|
| 56 |
+
const qlabel = (iso) => `${["primer", "segundo", "tercer", "cuarto"][qn(iso)]} trimestre de ${iso.slice(0, 4)}`;
|
| 57 |
+
const qshort = (iso) => `T${qn(iso) + 1} ${iso.slice(0, 4)}`;
|
| 58 |
+
const at = (iso, plusQuarters = 0) => { const d = A.parseDate(iso); d.setUTCMonth(d.getUTCMonth() + 3 * plusQuarters); return d; };
|
| 59 |
+
// Growth on the same period a year before: 4 rows back by quarter, 12 by month.
|
| 60 |
+
const yoy = (rows, key, lag) => rows.map((r, i) => (i >= lag && r[key] != null && rows[i - lag][key] ? r[key] / rows[i - lag][key] - 1 : null));
|
| 61 |
+
function corr(a, b) {
|
| 62 |
+
const k = a.length; if (k < 3) return NaN;
|
| 63 |
+
const ma = a.reduce((s, x) => s + x, 0) / k, mb = b.reduce((s, x) => s + x, 0) / k;
|
| 64 |
+
let sab = 0, sa = 0, sb = 0;
|
| 65 |
+
for (let i = 0; i < k; i++) { sab += (a[i] - ma) * (b[i] - mb); sa += (a[i] - ma) ** 2; sb += (b[i] - mb) ** 2; }
|
| 66 |
+
return sab / Math.sqrt(sa * sb);
|
| 67 |
+
}
|
| 68 |
+
function seg(options, value, label, onChange) {
|
| 69 |
+
const node = el("div", { class: "seg-ctl", role: "group", "aria-label": label },
|
| 70 |
+
...options.map(([k, t]) => el("button", { type: "button", "data-k": k, "aria-pressed": String(k === value), text: t })));
|
| 71 |
+
node.addEventListener("click", (e) => {
|
| 72 |
+
const b = e.target.closest("button[data-k]"); if (!b) return;
|
| 73 |
+
for (const x of node.children) x.setAttribute("aria-pressed", String(x === b));
|
| 74 |
+
onChange(b.dataset.k);
|
| 75 |
+
});
|
| 76 |
+
return node;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
try {
|
| 80 |
+
const [s, st] = await Promise.all([A.summary(), A.story("termometro")]);
|
| 81 |
+
const Q = st.q("trimestral"), SEC = st.q("sectores"), U = st.q("desempleo");
|
| 82 |
+
const DESC = new Map(st.q("grupos").map((g) => [g.grupo, g.descripcion]));
|
| 83 |
+
const G = { sociedades: yoy(Q, "sociedades", 4), naturales: yoy(Q, "naturales", 4) };
|
| 84 |
+
const P = yoy(Q, "pib", 4);
|
| 85 |
+
// Registrations of quarter i against GDP of quarter i + k: k > 0, the
|
| 86 |
+
// registry k quarters before; k < 0, after. 2020 and 2021 out unless asked.
|
| 87 |
+
const pairs = (g, k, excl) => {
|
| 88 |
+
const a = [], b = [];
|
| 89 |
+
Q.forEach((q, i) => {
|
| 90 |
+
const j = i + k;
|
| 91 |
+
if (j < 0 || j >= Q.length || g[i] == null || P[j] == null) return;
|
| 92 |
+
if (excl && (isPand(q.trimestre) || isPand(Q[j].trimestre))) return;
|
| 93 |
+
a.push(g[i]); b.push(P[j]);
|
| 94 |
+
});
|
| 95 |
+
return [a, b];
|
| 96 |
+
};
|
| 97 |
+
const rAt = (g, k, excl = true) => corr(...pairs(g, k, excl));
|
| 98 |
+
const sameDir = (g) => { const [a, b] = pairs(g, 0, true); return { share: a.filter((x, i) => (x > 0) === (b[i] > 0)).length / a.length, n: a.length }; };
|
| 99 |
+
const dS = sameDir(G.sociedades), dN = sameDir(G.naturales);
|
| 100 |
+
const lastReg = Q.findLastIndex((_, i) => G.sociedades[i] != null);
|
| 101 |
+
const lastGdp = Q.findLastIndex((_, i) => P[i] != null);
|
| 102 |
+
const ahead = lastReg > lastGdp;
|
| 103 |
+
const tenths = (x) => Math.round(x * 10);
|
| 104 |
+
|
| 105 |
+
const head = el("header", { class: "story-head" },
|
| 106 |
+
el("p", { class: "kicker", text: "Historia · Economía · Interactiva" }),
|
| 107 |
+
el("h1", { text: "El registro como termómetro" }),
|
| 108 |
+
el("p", { class: "dek", text: "Las sociedades que se crean cada trimestre suben y bajan con la economía, y se conocen semanas antes que el PIB. Los comerciantes siguen su propio ritmo." }),
|
| 109 |
+
el("div", { class: "meta" }, el("span", { class: "chip", text: `Corte del ${A.date(s.snapshot)}` }), el("span", { class: "chip", text: "PIB y desempleo: DANE" }), A.shareButton()));
|
| 110 |
+
|
| 111 |
+
const findings = el("div", { class: "findings" },
|
| 112 |
+
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `${tenths(dS.share)} de cada 10` }),
|
| 113 |
+
rich("p", {}, ["trimestres, las ", { b: "sociedades nuevas y el PIB" }, ` se movieron en la misma dirección frente al año anterior: ${dS.n} trimestres desde 2006, sin contar 2020 y 2021.`])),
|
| 114 |
+
el("div", { class: "finding reveal" }, el("p", { class: "n", text: sgn(G.sociedades[lastReg]) }),
|
| 115 |
+
rich("p", {}, [`cambió la creación de sociedades en el ${qlabel(Q[lastReg].trimestre)}, frente al mismo trimestre de un año antes.`,
|
| 116 |
+
...(ahead ? [" El PIB de ese trimestre ", { b: "aún no está publicado" }, ": el registro lo cuenta primero."] : [])])),
|
| 117 |
+
el("div", { class: "finding reveal" }, el("p", { class: "n", text: `${tenths(dN.share)} de cada 10` }),
|
| 118 |
+
rich("p", {}, ["trimestres, los ", { b: "comerciantes nuevos" }, ` y el PIB se movieron en la misma dirección: ${dN.share < 0.6 ? "casi lo mismo que lanzar una moneda" : "algo más que al azar"}.`])));
|
| 119 |
+
|
| 120 |
+
// 1. The two series, one above the other, and the registry moved in time.
|
| 121 |
+
const f1 = figure({ title: "Las matrículas nuevas y el PIB, trimestre a trimestre",
|
| 122 |
+
sub: "Cambio de cada trimestre frente al mismo trimestre del año anterior. Arriba, el producto interno bruto; abajo, las matrículas nuevas. El control corre el registro hacia adelante o hacia atrás en el tiempo: la correlación dice cuánto se parecen las dos curvas.",
|
| 123 |
+
sql: st.sql("trimestral"), source: SOURCE });
|
| 124 |
+
let kind1 = "sociedades";
|
| 125 |
+
const lagIn = el("input", { type: "range", id: "lag", min: -2, max: 3, step: 1, value: 0, style: "flex:1;min-width:140px;max-width:260px" });
|
| 126 |
+
const lagLab = el("span", { style: "min-width:150px;font-weight:600" });
|
| 127 |
+
const readout = el("p", { class: "readout", "aria-live": "polite" });
|
| 128 |
+
const panels = el("div");
|
| 129 |
+
f1.body.append(el("div", { class: "controls" },
|
| 130 |
+
seg(Object.entries(KIND).map(([k, t]) => [k, t.split(" ")[0]]), kind1, "Qué matrículas", (k) => { kind1 = k; draw1(); }),
|
| 131 |
+
el("label", { for: "lag", text: "Correr el registro" }), lagIn, lagLab), readout, panels);
|
| 132 |
+
const bands = [{ from: at("2020-01-01"), to: at("2022-01-01"), label: "Pandemia", short: "Covid" }];
|
| 133 |
+
function draw1() {
|
| 134 |
+
const k = +lagIn.value, g = G[kind1];
|
| 135 |
+
lagLab.textContent = k === 0 ? "mismo trimestre" : k > 0 ? `${k} trimestre${k > 1 ? "s" : ""} antes que el PIB` : `${-k} trimestre${k < -1 ? "s" : ""} después del PIB`;
|
| 136 |
+
lagIn.setAttribute("aria-valuetext", lagLab.textContent);
|
| 137 |
+
const best = [-2, -1, 0, 1, 2, 3].map((x) => [x, rAt(g, x)]).reduce((a, b) => (b[1] > a[1] ? b : a));
|
| 138 |
+
readout.replaceChildren(...rich("p", {}, ["Correlación con el PIB: ", { b: r2(rAt(g, k)) }, ` sin 2020 y 2021 (${r2(rAt(g, k, false))} con todos los años). `,
|
| 139 |
+
best[0] === 0 ? "Es más alta en el mismo trimestre." : `Es más alta con el registro ${Math.abs(best[0])} trimestre${Math.abs(best[0]) > 1 ? "s" : ""} ${best[0] > 0 ? "antes" : "después"}.`]).childNodes);
|
| 140 |
+
const first = at(Q[4].trimestre), last = at(Q[Q.length - 1].trimestre, Math.max(0, k));
|
| 141 |
+
const p1 = el("div"), p2 = el("div");
|
| 142 |
+
panels.replaceChildren(el("p", { class: "panel-t", text: "PIB" }), p1, el("p", { class: "panel-t", text: `${KIND[kind1]}${k ? ` (corridas ${Math.abs(k)} trimestre${Math.abs(k) > 1 ? "s" : ""} ${k > 0 ? "adelante" : "atrás"})` : ""}` }), p2);
|
| 143 |
+
const gdp = Q.map((q, i) => ({ x: at(q.trimestre), y: P[i] == null ? null : 100 * P[i] }));
|
| 144 |
+
const reg = Q.map((q, i) => ({ x: at(q.trimestre, k), y: g[i] == null ? null : 100 * g[i] }));
|
| 145 |
+
lineChart(p1, { label: "Cambio anual del PIB, por trimestre", height: 190, animate: false, xDomain: [first, last], bands,
|
| 146 |
+
yFormat: (v) => `${v}%`, series: [{ color: "var(--ink-2)", values: gdp }],
|
| 147 |
+
tip: (x, i) => ({ title: qshort(Q[i].trimestre), rows: [{ label: "PIB frente al año anterior", value: sgn(P[i]) }] }) });
|
| 148 |
+
lineChart(p2, { label: `Cambio anual de las matrículas nuevas: ${KIND[kind1].toLowerCase()}`, height: 210, animate: false, xDomain: [first, last], bands,
|
| 149 |
+
yFormat: (v) => `${v}%`, series: [{ color: "var(--c1)", values: reg }],
|
| 150 |
+
tip: (x, i) => ({ title: `${qshort(Q[i].trimestre)}${k ? ` (dibujado en ${qshort(Q[Math.min(Q.length - 1, Math.max(0, i + k))].trimestre)})` : ""}`,
|
| 151 |
+
rows: [{ label: `${KIND[kind1]} frente al año anterior`, value: sgn(g[i]) }, { label: "Matrículas", value: A.n(Q[i][kind1]) }] }) });
|
| 152 |
+
}
|
| 153 |
+
lagIn.addEventListener("input", draw1);
|
| 154 |
+
draw1();
|
| 155 |
+
f1.fig.append(tableView("Matrículas nuevas y PIB por trimestre", ["Trimestre", "Sociedades", "Cambio anual", "Comerciantes", "Cambio anual", "PIB (miles de millones de pesos de 2015)", "Cambio anual"],
|
| 156 |
+
Q.map((q, i) => [qshort(q.trimestre), A.n(q.sociedades), sgn(G.sociedades[i]), A.n(q.naturales), sgn(G.naturales[i]), q.pib == null ? "aún no publicado" : A.n(q.pib), sgn(P[i])]).reverse()));
|
| 157 |
+
|
| 158 |
+
// 2. Each quarter a dot.
|
| 159 |
+
const f2 = figure({ title: "Cada trimestre, un punto",
|
| 160 |
+
sub: "Horizontal: cuánto cambió el PIB frente al año anterior. Vertical: cuánto cambiaron las matrículas nuevas. Si se movieran juntos, los puntos formarían una línea que sube. La línea punteada es la tendencia sin 2020 y 2021; los trimestres de la pandemia que se salen de la escala aparecen como aros en el borde.",
|
| 161 |
+
sql: st.sql("trimestral"), source: SOURCE });
|
| 162 |
+
let kind2 = "sociedades";
|
| 163 |
+
const box2 = el("div"), r2box = el("p", { class: "readout", "aria-live": "polite" });
|
| 164 |
+
f2.body.append(el("div", { class: "controls" }, seg(Object.entries(KIND).map(([k, t]) => [k, t.split(" ")[0]]), kind2, "Qué matrículas", (k) => { kind2 = k; draw2(); })),
|
| 165 |
+
legend([{ label: "Trimestres de 2006 a 2019 y desde 2022", color: "var(--c1)" }, { label: "2020 y 2021", color: "var(--c2)" }]), r2box, box2);
|
| 166 |
+
function draw2() {
|
| 167 |
+
const g = G[kind2];
|
| 168 |
+
r2box.replaceChildren(...rich("p", {}, [`${KIND[kind2]}: correlación con el PIB de `, { b: r2(rAt(g, 0)) }, " sin 2020 y 2021."]).childNodes);
|
| 169 |
+
box2.replaceChildren();
|
| 170 |
+
scatter(box2, { label: `Cambio anual del PIB frente al de las matrículas nuevas: ${KIND[kind2].toLowerCase()}`, fit: true, scaleToFit: true,
|
| 171 |
+
points: Q.map((q, i) => ({ x: P[i] == null ? null : 100 * P[i], y: g[i] == null ? null : 100 * g[i], key: q.trimestre,
|
| 172 |
+
color: isPand(q.trimestre) ? "var(--c2)" : "var(--c1)", fit: !isPand(q.trimestre) })),
|
| 173 |
+
xFormat: (v) => `${v}%`, yFormat: (v) => `${v}%`, xLabel: "Cambio anual del PIB →", yLabel: `↑ ${KIND[kind2]}: cambio anual`,
|
| 174 |
+
tip: (p) => ({ title: qshort(p.key), rows: [{ label: "PIB", value: sgn(p.x / 100) }, { label: KIND[kind2], value: sgn(p.y / 100) }] }) });
|
| 175 |
+
}
|
| 176 |
+
draw2();
|
| 177 |
+
|
| 178 |
+
// 3. Sector by sector: each grouping's new companies against its own GDP.
|
| 179 |
+
const groups = [...new Set(SEC.map((r) => r.grupo))];
|
| 180 |
+
const secRows = groups.map((gr) => {
|
| 181 |
+
const R = SEC.filter((r) => r.grupo === gr);
|
| 182 |
+
const a = yoy(R, "sociedades", 4), b = yoy(R, "pib", 4), xs = [], ys = [];
|
| 183 |
+
R.forEach((r, i) => { if (a[i] == null || b[i] == null || isPand(r.trimestre)) return; xs.push(a[i]); ys.push(b[i]); });
|
| 184 |
+
return { grupo: gr, desc: DESC.get(gr) || gr, r: corr(xs, ys), n: xs.length, total: R.reduce((t, r) => t + r.sociedades, 0) };
|
| 185 |
+
}).filter((x) => Number.isFinite(x.r)).sort((x, y) => y.r - x.r);
|
| 186 |
+
// "a, b y c": joined by hand, since the values carry decimal commas.
|
| 187 |
+
const list = (rows) => { const t = rows.map((x) => `${(SHORT[x.grupo] || x.grupo).toLowerCase()} (${r2(x.r)})`); return t.length > 1 ? `${t.slice(0, -1).join("; ")} y ${t[t.length - 1]}` : t.join(""); };
|
| 188 |
+
const f3 = figure({ title: "Sector por sector",
|
| 189 |
+
sub: "Correlación entre las sociedades nuevas de cada sector y el PIB de ese mismo sector, trimestre a trimestre, frente al año anterior, desde 2014 y sin 2020 ni 2021. Cerca de 1: se mueven juntos; cerca de 0: cada uno por su lado.",
|
| 190 |
+
sql: st.sql("sectores"), source: SOURCE });
|
| 191 |
+
divergingBars(f3.body, secRows.map((x) => ({ label: SHORT[x.grupo] || x.grupo, value: x.r,
|
| 192 |
+
tip: { title: SHORT[x.grupo] || x.grupo, rows: [{ label: "Correlación", value: r2(x.r) }, { label: "Trimestres", value: A.n(x.n) }, { label: "Sociedades creadas desde 2005", value: A.n(x.total) }], note: x.desc } })),
|
| 193 |
+
{ label: "Correlación entre sociedades nuevas y PIB, por sector", format: r2, tickFormat: (t) => r2(t) });
|
| 194 |
+
f3.fig.append(tableView("Correlación por sector", ["Sector (agrupación del DANE)", "Correlación", "Trimestres", "Sociedades creadas desde 2005"],
|
| 195 |
+
secRows.map((x) => [x.desc, r2(x.r), A.n(x.n), A.n(x.total)])));
|
| 196 |
+
|
| 197 |
+
// 4. Unemployment and sole traders, monthly: the test of an idea.
|
| 198 |
+
const roll = (k) => U.map((u, i) => (i >= 2 ? U[i][k] + U[i - 1][k] + U[i - 2][k] : null));
|
| 199 |
+
const nat3 = roll("naturales");
|
| 200 |
+
const natG = nat3.map((v, i) => (i >= 14 && v != null && nat3[i - 12] ? v / nat3[i - 12] - 1 : null));
|
| 201 |
+
const tdD = U.map((u, i) => (i >= 12 ? u.tasa_desocupacion - U[i - 12].tasa_desocupacion : null));
|
| 202 |
+
const upairs = (k, excl) => { const a = [], b = []; U.forEach((u, i) => { const j = i - k; if (j < 0 || natG[i] == null || tdD[j] == null) return; if (excl && (isPand(u.mes) || isPand(U[j].mes))) return; a.push(natG[i]); b.push(tdD[j]); }); return [a, b]; };
|
| 203 |
+
const uR = [0, 3, 6].map((k) => [k, corr(...upairs(k, true))]);
|
| 204 |
+
const f4 = figure({ title: "¿Y el desempleo?",
|
| 205 |
+
sub: "Arriba, la tasa de desempleo nacional, desestacionalizada. Abajo, cuánto cambiaron los comerciantes nuevos frente al año anterior (sumando cada tres meses, para quitar ruido). Si quedarse sin empleo empujara a registrar un negocio, la línea de abajo subiría cuando sube la de arriba.",
|
| 206 |
+
sql: st.sql("desempleo"), source: SOURCE });
|
| 207 |
+
const u1 = el("div"), u2 = el("div");
|
| 208 |
+
f4.body.append(el("p", { class: "panel-t", text: "Tasa de desempleo" }), u1, el("p", { class: "panel-t", text: "Comerciantes nuevos, cambio anual" }), u2);
|
| 209 |
+
const ux = U.map((u) => A.parseDate(u.mes)), uDomain = [ux[14], ux[ux.length - 1]];
|
| 210 |
+
const ubands = [{ from: A.parseDate("2020-01-01"), to: A.parseDate("2022-01-01"), label: "Pandemia", short: "Covid" }];
|
| 211 |
+
lineChart(u1, { label: "Tasa de desempleo, mensual", height: 180, animate: false, xDomain: uDomain, bands: ubands, yMin: 0, yFormat: (v) => `${v}%`,
|
| 212 |
+
series: [{ color: "var(--c2)", values: U.map((u, i) => ({ x: ux[i], y: u.tasa_desocupacion })) }],
|
| 213 |
+
tip: (x, i) => ({ title: A.monthYear(U[i].mes), rows: [{ label: "Desempleo", value: `${A.n1(U[i].tasa_desocupacion)} %` }] }) });
|
| 214 |
+
lineChart(u2, { label: "Cambio anual de los comerciantes nuevos, mensual", height: 200, animate: false, xDomain: uDomain, bands: ubands, yFormat: (v) => `${v}%`,
|
| 215 |
+
series: [{ color: "var(--c1)", values: U.map((u, i) => ({ x: ux[i], y: natG[i] == null ? null : 100 * natG[i] })) }],
|
| 216 |
+
tip: (x, i) => ({ title: A.monthYear(U[i].mes), rows: [{ label: "Comerciantes nuevos, frente al año anterior", value: sgn(natG[i]) }, { label: "Desempleo", value: `${A.n1(U[i].tasa_desocupacion)} %` }] }) });
|
| 217 |
+
|
| 218 |
+
app.replaceChildren(head, findings,
|
| 219 |
+
prose({ h2: "Un dato que llega antes" },
|
| 220 |
+
["El DANE publica el producto interno bruto de cada trimestre unas seis semanas después de que termina. El registro mercantil sabe cuántas sociedades se crearon en ese trimestre a los pocos días. Si las dos cosas se mueven juntas, el registro es un ", { b: "termómetro temprano" }, " de la economía."],
|
| 221 |
+
[`Se mueven juntas. Desde 2006, sin contar los dos años de la pandemia, la creación de sociedades y el PIB fueron en la misma dirección en ${tenths(dS.share)} de cada 10 trimestres, y su correlación es de ${r2(rAt(G.sociedades, 0))}. No es un adelanto: la coincidencia es mayor en el mismo trimestre que uno antes o uno después. La ventaja es que el registro se conoce primero.`]),
|
| 222 |
+
f1.fig,
|
| 223 |
+
prose(["Con los ", { b: "comerciantes" }, " (personas naturales que se matriculan para un negocio propio) no pasa: sus matrículas suben y bajan casi sin relación con el PIB. Sus motivos son otros, y estos datos no alcanzan a decir cuáles."]),
|
| 224 |
+
f2.fig,
|
| 225 |
+
prose(["Por sectores, la relación cambia mucho. Es más estrecha en ", { b: list(secRows.slice(0, 3)) },
|
| 226 |
+
`, y casi no existe en ${list(secRows.slice(-3).reverse())}.`]),
|
| 227 |
+
f3.fig,
|
| 228 |
+
prose({ h2: "La idea que no se cumple" },
|
| 229 |
+
["Es común pensar que cuando el desempleo sube, la gente monta su propio negocio por necesidad. Si fuera así en el registro, los comerciantes nuevos crecerían cuando crece el desempleo."],
|
| 230 |
+
[`No se ve. Fuera de la pandemia, cuando las dos cosas cayeron a la vez por la misma causa, la correlación entre el cambio del desempleo y el de los comerciantes nuevos es de ${r2(uR[0][1])} el mismo mes, ${r2(uR[1][1])} tres meses después y ${r2(uR[2][1])} seis meses después: prácticamente cero. Puede que ocurra en el comercio informal, que no pasa por el registro.`]),
|
| 231 |
+
f4.fig,
|
| 232 |
+
readThis(["Se cuentan ", { b: "matrículas nuevas" }, ", no empresas: una sociedad o un comerciante que se matricula. Se dejan fuera los días en que una cámara registra miles a la vez, que son trámites y no negocios nuevos. Los trimestres son completos: el que está en curso no aparece."],
|
| 233 |
+
["El PIB es el del ", { b: "DANE" }, ": series encadenadas de volumen con año de referencia 2015, por trimestre y por las doce agrupaciones de sectores de sus cuentas nacionales. El desempleo es el total nacional desestacionalizado de la Gran Encuesta Integrada de Hogares. El DANE revisa las cifras recientes."],
|
| 234 |
+
["Una correlación mide si dos series suben y bajan juntas, de −1 a 1. ", { b: "No dice que una cause la otra" }, ". 2020 y 2021 se apartan porque la pandemia movió todo a la vez."],
|
| 235 |
+
["Por sectores, la comparación empieza en 2013: antes, buena parte de las sociedades no tiene su sector en la clasificación actual (CIIU rev. 4), y el aumento de esa cobertura se leería como crecimiento."]),
|
| 236 |
+
moreStories("termometro"));
|
| 237 |
+
A.footer(s);
|
| 238 |
+
A.reveal();
|
| 239 |
+
window.__amcReady = true;
|
| 240 |
+
} catch (e) { A.fail(app, e); }
|
| 241 |
+
</script>
|
| 242 |
+
</body>
|
| 243 |
+
</html>
|
historias/tu-empresa/index.html
CHANGED
|
@@ -248,9 +248,11 @@ try {
|
|
| 248 |
{ b: tail }, sv.local && sv.national != null ? ` En todo el país, ${pct(sv.national)}.` : ""]),
|
| 249 |
el("div", { class: "meter" }, el("i", { style: `width:${sv.share * 100}%` }))));
|
| 250 |
} else if (y && r.cohorte_camara) {
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
| 254 |
}
|
| 255 |
// 3. A local cluster? The activity's share of the chamber's live companies
|
| 256 |
// against its share of the country's (both counted over all live companies,
|
|
@@ -276,8 +278,12 @@ try {
|
|
| 276 |
A.reveal(profile);
|
| 277 |
}
|
| 278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
function survival(rows, r, y) {
|
| 280 |
-
if (!rows || !y) return null;
|
| 281 |
const same = rows.filter((x) => x.is_juridical && Number(x.formation_year) === y);
|
| 282 |
const sum = (a, k) => a.reduce((t, x) => t + x[k], 0);
|
| 283 |
const here = same.filter((x) => x.codigo_camara === r.codigo_camara);
|
|
|
|
| 248 |
{ b: tail }, sv.local && sv.national != null ? ` En todo el país, ${pct(sv.national)}.` : ""]),
|
| 249 |
el("div", { class: "meter" }, el("i", { style: `width:${sv.share * 100}%` }))));
|
| 250 |
} else if (y && r.cohorte_camara) {
|
| 251 |
+
const share = (r.cohorte_camara_vivas || 0) / r.cohorte_camara;
|
| 252 |
+
items.push(el("div", { class: "c reveal" }, el("p", { class: "big", text: pct(share) }),
|
| 253 |
+
rich("p", {}, [`de las `, { b: n(r.cohorte_camara) }, ` empresas de todas las actividades creadas en ${camara} en ${y} siguen activas. `,
|
| 254 |
+
{ b: r.is_live ? "Esta es una de ellas." : `Esta no ha renovado en ${s.year}.` }]),
|
| 255 |
+
el("div", { class: "meter" }, el("i", { style: `width:${share * 100}%` }))));
|
| 256 |
}
|
| 257 |
// 3. A local cluster? The activity's share of the chamber's live companies
|
| 258 |
// against its share of the country's (both counted over all live companies,
|
|
|
|
| 278 |
A.reveal(profile);
|
| 279 |
}
|
| 280 |
|
| 281 |
+
// Only from 2013: an earlier cohort, counted by activity, leaves out most of
|
| 282 |
+
// the companies that closed (their activity was never converted to CIIU
|
| 283 |
+
// rev. 4) and overstates who remains. Earlier companies get the cohort of
|
| 284 |
+
// all activities in their chamber, which is complete (name_directory).
|
| 285 |
function survival(rows, r, y) {
|
| 286 |
+
if (!rows || !y || y < 2013) return null;
|
| 287 |
const same = rows.filter((x) => x.is_juridical && Number(x.formation_year) === y);
|
| 288 |
const sum = (a, k) => a.reduce((t, x) => t + x[k], 0);
|
| 289 |
const here = same.filter((x) => x.codigo_camara === r.codigo_camara);
|
sitemap.xml
CHANGED
|
@@ -6,15 +6,18 @@
|
|
| 6 |
<url><loc>https://amc.clyxconsulting.com/consulta/</loc></url>
|
| 7 |
<url><loc>https://amc.clyxconsulting.com/explorar/</loc></url>
|
| 8 |
<url><loc>https://amc.clyxconsulting.com/historias/abril-2020/</loc></url>
|
|
|
|
| 9 |
<url><loc>https://amc.clyxconsulting.com/historias/carrera/</loc></url>
|
| 10 |
<url><loc>https://amc.clyxconsulting.com/historias/concentracion/</loc></url>
|
| 11 |
<url><loc>https://amc.clyxconsulting.com/historias/conexiones/</loc></url>
|
|
|
|
| 12 |
<url><loc>https://amc.clyxconsulting.com/historias/depuraciones/</loc></url>
|
| 13 |
<url><loc>https://amc.clyxconsulting.com/historias/duracion/</loc></url>
|
| 14 |
<url><loc>https://amc.clyxconsulting.com/historias/gacelas/</loc></url>
|
| 15 |
<url><loc>https://amc.clyxconsulting.com/historias/gobiernos/</loc></url>
|
| 16 |
<url><loc>https://amc.clyxconsulting.com/historias/</loc></url>
|
| 17 |
<url><loc>https://amc.clyxconsulting.com/historias/latido/</loc></url>
|
|
|
|
| 18 |
<url><loc>https://amc.clyxconsulting.com/historias/margenes/</loc></url>
|
| 19 |
<url><loc>https://amc.clyxconsulting.com/historias/marzo/</loc></url>
|
| 20 |
<url><loc>https://amc.clyxconsulting.com/historias/migracion/</loc></url>
|
|
@@ -27,6 +30,7 @@
|
|
| 27 |
<url><loc>https://amc.clyxconsulting.com/historias/regiones/</loc></url>
|
| 28 |
<url><loc>https://amc.clyxconsulting.com/historias/sas/</loc></url>
|
| 29 |
<url><loc>https://amc.clyxconsulting.com/historias/software/</loc></url>
|
|
|
|
| 30 |
<url><loc>https://amc.clyxconsulting.com/historias/tu-empresa/</loc></url>
|
| 31 |
<url><loc>https://amc.clyxconsulting.com/</loc></url>
|
| 32 |
<url><loc>https://amc.clyxconsulting.com/metodologia/comparacion/</loc></url>
|
|
|
|
| 6 |
<url><loc>https://amc.clyxconsulting.com/consulta/</loc></url>
|
| 7 |
<url><loc>https://amc.clyxconsulting.com/explorar/</loc></url>
|
| 8 |
<url><loc>https://amc.clyxconsulting.com/historias/abril-2020/</loc></url>
|
| 9 |
+
<url><loc>https://amc.clyxconsulting.com/historias/cara-a-cara/</loc></url>
|
| 10 |
<url><loc>https://amc.clyxconsulting.com/historias/carrera/</loc></url>
|
| 11 |
<url><loc>https://amc.clyxconsulting.com/historias/concentracion/</loc></url>
|
| 12 |
<url><loc>https://amc.clyxconsulting.com/historias/conexiones/</loc></url>
|
| 13 |
+
<url><loc>https://amc.clyxconsulting.com/historias/de-cien/</loc></url>
|
| 14 |
<url><loc>https://amc.clyxconsulting.com/historias/depuraciones/</loc></url>
|
| 15 |
<url><loc>https://amc.clyxconsulting.com/historias/duracion/</loc></url>
|
| 16 |
<url><loc>https://amc.clyxconsulting.com/historias/gacelas/</loc></url>
|
| 17 |
<url><loc>https://amc.clyxconsulting.com/historias/gobiernos/</loc></url>
|
| 18 |
<url><loc>https://amc.clyxconsulting.com/historias/</loc></url>
|
| 19 |
<url><loc>https://amc.clyxconsulting.com/historias/latido/</loc></url>
|
| 20 |
+
<url><loc>https://amc.clyxconsulting.com/historias/mapa/</loc></url>
|
| 21 |
<url><loc>https://amc.clyxconsulting.com/historias/margenes/</loc></url>
|
| 22 |
<url><loc>https://amc.clyxconsulting.com/historias/marzo/</loc></url>
|
| 23 |
<url><loc>https://amc.clyxconsulting.com/historias/migracion/</loc></url>
|
|
|
|
| 30 |
<url><loc>https://amc.clyxconsulting.com/historias/regiones/</loc></url>
|
| 31 |
<url><loc>https://amc.clyxconsulting.com/historias/sas/</loc></url>
|
| 32 |
<url><loc>https://amc.clyxconsulting.com/historias/software/</loc></url>
|
| 33 |
+
<url><loc>https://amc.clyxconsulting.com/historias/termometro/</loc></url>
|
| 34 |
<url><loc>https://amc.clyxconsulting.com/historias/tu-empresa/</loc></url>
|
| 35 |
<url><loc>https://amc.clyxconsulting.com/</loc></url>
|
| 36 |
<url><loc>https://amc.clyxconsulting.com/metodologia/comparacion/</loc></url>
|