Notes
Notes - notes.io |
VAR _Fechas =
SUMMARIZE(
gaia_monitoring,
gaia_monitoring[Fecha],
"FechaStr", FORMAT(gaia_monitoring[Fecha], "DD/MM/YYYY")
)
-- Valores por fecha y regla (sin acumular, el acumulado lo haremos con EARLIER)
VAR _T =
ADDCOLUMNS(
_Fechas,
"V1", CALCULATE([Impacto Económico], gaia_monitoring[service_response_IIC] = "1"),
"V4", CALCULATE([Impacto Económico], gaia_monitoring[service_response_IIC] = "4"),
"V5c", CALCULATE([Impacto Económico], gaia_monitoring[service_response_IIC] = "5 (con 01)"),
"V5s", CALCULATE([Impacto Económico], gaia_monitoring[service_response_IIC] = "5 (sin 01)"),
"V67c", CALCULATE([Impacto Económico], gaia_monitoring[service_response_IIC] = "6 y 7 (con 01)"),
"V67s", CALCULATE([Impacto Económico], gaia_monitoring[service_response_IIC] = "6 y 7 (sin 01)"),
"V8", CALCULATE([Impacto Económico], gaia_monitoring[service_response_IIC] = "8")
)
-- Acumulados por regla usando EARLIER
VAR _TAcum =
ADDCOLUMNS(
_T,
"A1", CALCULATE(SUMX(_T, COALESCE([V1],0)), _T[Fecha] <= EARLIER(gaia_monitoring[Fecha])),
"A4", CALCULATE(SUMX(_T, COALESCE([V4],0)), _T[Fecha] <= EARLIER(gaia_monitoring[Fecha])),
"A5c", CALCULATE(SUMX(_T, COALESCE([V5c],0)), _T[Fecha] <= EARLIER(gaia_monitoring[Fecha])),
"A5s", CALCULATE(SUMX(_T, COALESCE([V5s],0)), _T[Fecha] <= EARLIER(gaia_monitoring[Fecha])),
"A67c", CALCULATE(SUMX(_T, COALESCE([V67c],0)),_T[Fecha] <= EARLIER(gaia_monitoring[Fecha])),
"A67s", CALCULATE(SUMX(_T, COALESCE([V67s],0)),_T[Fecha] <= EARLIER(gaia_monitoring[Fecha])),
"A8", CALCULATE(SUMX(_T, COALESCE([V8],0)), _T[Fecha] <= EARLIER(gaia_monitoring[Fecha]))
)
VAR _MaxVal =
MAXX(_TAcum,
COALESCE([A1],0) + COALESCE([A4],0) + COALESCE([A5c],0) +
COALESCE([A5s],0) + COALESCE([A67c],0) + COALESCE([A67s],0) + COALESCE([A8],0)
)
VAR _N = COUNTROWS(_Fechas)
-- Dimensiones del SVG
VAR W = 700
VAR H = 300
VAR PL = 60 -- padding left
VAR PR = 20 -- padding right
VAR PT = 20 -- padding top
VAR PB = 40 -- padding bottom
VAR ChartW = W - PL - PR
VAR ChartH = H - PT - PB
VAR _Colores = DATATABLE(
"Regla", STRING, "Color", STRING,
{
{"A1", "#185FA5"},
{"A4", "#0F6E56"},
{"A5c", "#534AB7"},
{"A5s", "#AFA9EC"},
{"A67c", "#D85A30"},
{"A67s", "#F0997B"},
{"A8", "#1D9E75"}
}
)
-- Líneas SVG por regla
VAR _LineA1 = CONCATENATEX(
_TAcum,
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
VAR y = PT + ChartH - DIVIDE(COALESCE([A1],0) * ChartH, _MaxVal)
RETURN FORMAT(x,"0") & "," & FORMAT(y,"0"),
" ", gaia_monitoring[Fecha], ASC)
VAR _LineA4 = CONCATENATEX(
_TAcum,
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
VAR y = PT + ChartH - DIVIDE(COALESCE([A4],0) * ChartH, _MaxVal)
RETURN FORMAT(x,"0") & "," & FORMAT(y,"0"),
" ", gaia_monitoring[Fecha], ASC)
VAR _LineA5c = CONCATENATEX(
_TAcum,
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
VAR y = PT + ChartH - DIVIDE(COALESCE([A5c],0) * ChartH, _MaxVal)
RETURN FORMAT(x,"0") & "," & FORMAT(y,"0"),
" ", gaia_monitoring[Fecha], ASC)
VAR _LineA5s = CONCATENATEX(
_TAcum,
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
VAR y = PT + ChartH - DIVIDE(COALESCE([A5s],0) * ChartH, _MaxVal)
RETURN FORMAT(x,"0") & "," & FORMAT(y,"0"),
" ", gaia_monitoring[Fecha], ASC)
VAR _LineA67c = CONCATENATEX(
_TAcum,
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
VAR y = PT + ChartH - DIVIDE(COALESCE([A67c],0) * ChartH, _MaxVal)
RETURN FORMAT(x,"0") & "," & FORMAT(y,"0"),
" ", gaia_monitoring[Fecha], ASC)
VAR _LineA67s = CONCATENATEX(
_TAcum,
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
VAR y = PT + ChartH - DIVIDE(COALESCE([A67s],0) * ChartH, _MaxVal)
RETURN FORMAT(x,"0") & "," & FORMAT(y,"0"),
" ", gaia_monitoring[Fecha], ASC)
VAR _LineA8 = CONCATENATEX(
_TAcum,
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
VAR y = PT + ChartH - DIVIDE(COALESCE([A8],0) * ChartH, _MaxVal)
RETURN FORMAT(x,"0") & "," & FORMAT(y,"0"),
" ", gaia_monitoring[Fecha], ASC)
-- Labels eje X (cada N fechas para no saturar)
VAR _Step = IF(_N <= 10, 1, IF(_N <= 30, 3, IF(_N <= 60, 7, 14)))
VAR _XLabels = CONCATENATEX(
FILTER(_TAcum, MOD(RANKX(_TAcum, [Fecha],, ASC, Dense) - 1, _Step) = 0),
VAR idx = RANKX(_TAcum, [Fecha],, ASC, Dense) - 1
VAR x = PL + DIVIDE(idx * ChartW, _N - 1)
RETURN "<text x='" & FORMAT(x,"0") & "' y='" & FORMAT(H - 5, "0") &
"' font-size='9' text-anchor='middle' fill='#999'>" & [FechaStr] & "</text>",
"", gaia_monitoring[Fecha], ASC)
-- Labels eje Y
VAR _Y1 = FORMAT(_MaxVal * 0.25 / 1000, "0.0") & "k"
VAR _Y2 = FORMAT(_MaxVal * 0.5 / 1000, "0.0") & "k"
VAR _Y3 = FORMAT(_MaxVal * 0.75 / 1000, "0.0") & "k"
VAR _Y4 = FORMAT(_MaxVal / 1000, "0.0") & "k"
VAR _YGrid =
"<line x1='" & PL & "' y1='" & FORMAT(PT + ChartH * 0.75,"0") & "' x2='" & FORMAT(W-PR,"0") & "' y2='" & FORMAT(PT + ChartH * 0.75,"0") & "' stroke='#eee' stroke-width='1'/>" &
"<line x1='" & PL & "' y1='" & FORMAT(PT + ChartH * 0.5, "0") & "' x2='" & FORMAT(W-PR,"0") & "' y2='" & FORMAT(PT + ChartH * 0.5, "0") & "' stroke='#eee' stroke-width='1'/>" &
"<line x1='" & PL & "' y1='" & FORMAT(PT + ChartH * 0.25,"0") & "' x2='" & FORMAT(W-PR,"0") & "' y2='" & FORMAT(PT + ChartH * 0.25,"0") & "' stroke='#eee' stroke-width='1'/>" &
"<text x='" & FORMAT(PL-4,"0") & "' y='" & FORMAT(PT + ChartH * 0.75 + 3,"0") & "' font-size='9' text-anchor='end' fill='#999'>" & _Y1 & "</text>" &
"<text x='" & FORMAT(PL-4,"0") & "' y='" & FORMAT(PT + ChartH * 0.5 + 3,"0") & "' font-size='9' text-anchor='end' fill='#999'>" & _Y2 & "</text>" &
"<text x='" & FORMAT(PL-4,"0") & "' y='" & FORMAT(PT + ChartH * 0.25 + 3,"0") & "' font-size='9' text-anchor='end' fill='#999'>" & _Y3 & "</text>" &
"<text x='" & FORMAT(PL-4,"0") & "' y='" & FORMAT(PT + 3,"0") & "' font-size='9' text-anchor='end' fill='#999'>" & _Y4 & "</text>"
RETURN
"<div style='font-family:Segoe UI,sans-serif;background:#fff;padding:12px;'>
<div style='display:flex;flex-wrap:wrap;gap:10px;margin-bottom:12px;font-size:11px;color:#555;'>
<span><span style='display:inline-block;width:10px;height:3px;background:#185FA5;margin-right:4px;vertical-align:middle;'></span>Regla 1</span>
<span><span style='display:inline-block;width:10px;height:3px;background:#0F6E56;margin-right:4px;vertical-align:middle;'></span>Regla 4</span>
<span><span style='display:inline-block;width:10px;height:3px;background:#534AB7;margin-right:4px;vertical-align:middle;'></span>Regla 5 (con 01)</span>
<span><span style='display:inline-block;width:10px;height:3px;background:#AFA9EC;margin-right:4px;vertical-align:middle;'></span>Regla 5 (sin 01)</span>
<span><span style='display:inline-block;width:10px;height:3px;background:#D85A30;margin-right:4px;vertical-align:middle;'></span>Regla 6 y 7 (con 01)</span>
<span><span style='display:inline-block;width:10px;height:3px;background:#F0997B;margin-right:4px;vertical-align:middle;'></span>Regla 6 y 7 (sin 01)</span>
<span><span style='display:inline-block;width:10px;height:3px;background:#1D9E75;margin-right:4px;vertical-align:middle;'></span>Regla 8</span>
</div>
<svg width='100%' viewBox='0 0 " & W & " " & H & "' preserveAspectRatio='xMidYMid meet'>
" & _YGrid & "
<line x1='" & PL & "' y1='" & PT & "' x2='" & PL & "' y2='" & FORMAT(PT+ChartH,"0") & "' stroke='#ddd' stroke-width='1'/>
<line x1='" & PL & "' y1='" & FORMAT(PT+ChartH,"0") & "' x2='" & FORMAT(W-PR,"0") & "' y2='" & FORMAT(PT+ChartH,"0") & "' stroke='#ddd' stroke-width='1'/>
<polyline points='" & _LineA1 & "' fill='none' stroke='#185FA5' stroke-width='2' stroke-linejoin='round'/>
<polyline points='" & _LineA4 & "' fill='none' stroke='#0F6E56' stroke-width='2' stroke-linejoin='round'/>
<polyline points='" & _LineA5c & "' fill='none' stroke='#534AB7' stroke-width='2' stroke-linejoin='round'/>
<polyline points='" & _LineA5s & "' fill='none' stroke='#AFA9EC' stroke-width='2' stroke-linejoin='round'/>
<polyline points='" & _LineA67c & "' fill='none' stroke='#D85A30' stroke-width='2' stroke-linejoin='round'/>
<polyline points='" & _LineA67s & "' fill='none' stroke='#F0997B' stroke-width='2' stroke-linejoin='round'/>
<polyline points='" & _LineA8 & "' fill='none' stroke='#1D9E75' stroke-width='2' stroke-linejoin='round'/>
" & _XLabels & "
</svg>
</div>"
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
