From d8d77a137a738cd1fbae4c779effa6601895eaaf Mon Sep 17 00:00:00 2001 From: higsch Date: Wed, 2 Dec 2020 23:58:41 +0100 Subject: [PATCH] polarization data visualized --- public/global.css | 30 +++++++ src/components/EventTooltip.svelte | 54 ++++-------- src/components/ImpactStrip.svelte | 52 +++++++++++ src/components/PolarizationLegend.svelte | 52 +++++++++++ src/components/PolarizationStrip.svelte | 108 +++++++++++++++++++++++ src/inputs/polarization.js | 22 +++++ src/utils/loadData.js | 6 +- 7 files changed, 282 insertions(+), 42 deletions(-) create mode 100644 src/components/ImpactStrip.svelte create mode 100644 src/components/PolarizationLegend.svelte create mode 100644 src/components/PolarizationStrip.svelte create mode 100644 src/inputs/polarization.js diff --git a/public/global.css b/public/global.css index e94a379..f54c683 100644 --- a/public/global.css +++ b/public/global.css @@ -141,6 +141,36 @@ a:hover, span.pseudolink:hover { background-color: #e24545a1; } +/* polarization */ +.pol-l { + background-color: #2e64a0; + opacity: 0.8; +} + +.pol-ll { + background-color: #61a3de; + opacity: 0.8; +} + +.pol-c { + background-color: #96659e; + opacity: 0.8; +} + +.pol-lr { + background-color: #a15552; + opacity: 0.8; +} + +.pol-r { + background-color: #ca0800; + opacity: 0.8; +} + +.pol-undef { + background-color: #e0d3e2; + opacity: 0.8; +} /* the landing page */ .page-wrapper { diff --git a/src/components/EventTooltip.svelte b/src/components/EventTooltip.svelte index 16a4525..a71a381 100644 --- a/src/components/EventTooltip.svelte +++ b/src/components/EventTooltip.svelte @@ -4,7 +4,7 @@ import { width, panelHeight, controlsHeight } from '../stores/dimensions'; import { tooltip } from '../stores/eventSelections'; import { fade, slide } from 'svelte/transition'; - import { timeFormat, format } from 'd3'; + import { timeFormat } from 'd3'; import { extractHostname } from '../utils/misc'; import { platformFilter, @@ -20,6 +20,8 @@ import EventTooltipCross from './EventTooltipCross.svelte'; import ScoreBar from './ScoreBar.svelte'; import ScoreQuestions from './ScoreQuestions.svelte'; + import ImpactStrip from './ImpactStrip.svelte'; + import PolarizationLegend from './PolarizationLegend.svelte'; import Share from './Share.svelte'; const offset = { @@ -32,7 +34,6 @@ const attributionTf = timeFormat('%B %d, %Y'); const activityTf = timeFormat('%B %Y'); - const commaFormat = format(','); let elem; let tWidth, tHeight; @@ -181,19 +182,19 @@

pending

{:else} + {#if ($tooltip.tp.polarization.fulfills10Articles || $tooltip.tp.polarization.fulfills25Percent)} + + {/if} {/if} {#if ($tooltip.tp.imageUrl)} @@ -426,26 +427,6 @@ display: flex; } - .smi li { - margin: 0.2rem 0.3rem 0.2rem 0; - font-size: 0.8rem; - } - - .smi-score { - padding: 0 0.2rem; - border: none; - border-radius: 3px; - box-shadow: 0 1px 2px rgba(0,0,0,0.07), - 0 2px 4px rgba(0,0,0,0.07); - } - - .smi-label { - display: inline-block; - padding: 0 0.1rem; - border: none; - border-radius: 3px; - } - a { text-decoration: none; } @@ -458,11 +439,6 @@ font-size: 0.6rem; } - .no-break { - word-break: keep-all; - white-space: nowrap; - } - .scroll-wrapper .image { min-height: 1%; width: 100%; diff --git a/src/components/ImpactStrip.svelte b/src/components/ImpactStrip.svelte new file mode 100644 index 0000000..9d1498a --- /dev/null +++ b/src/components/ImpactStrip.svelte @@ -0,0 +1,52 @@ + + +
  • +
    + {commaFormat(value)} +
    + + {label} + + {#if ((polarization.fulfills10Articles || polarization.fulfills25Percent) && value > 0)} + + {/if} +
  • + + diff --git a/src/components/PolarizationLegend.svelte b/src/components/PolarizationLegend.svelte new file mode 100644 index 0000000..d39f9cd --- /dev/null +++ b/src/components/PolarizationLegend.svelte @@ -0,0 +1,52 @@ + + +
    +

    Polarization:

    +
      + {#each categories as category (category)} +
    • +
      +

      {category.name}

      +
    • + {/each} +
    +
    + + diff --git a/src/components/PolarizationStrip.svelte b/src/components/PolarizationStrip.svelte new file mode 100644 index 0000000..fb0d7b9 --- /dev/null +++ b/src/components/PolarizationStrip.svelte @@ -0,0 +1,108 @@ + + +
    + + + + + {Math.round(engagementExplained * 100)}% + + +
    + {#each categories as category (category.id)} +
    +
    + {/each} +
    +
    + + diff --git a/src/inputs/polarization.js b/src/inputs/polarization.js new file mode 100644 index 0000000..993ec3c --- /dev/null +++ b/src/inputs/polarization.js @@ -0,0 +1,22 @@ +export const categories = [ + { + id: 'l', + name: 'left' + }, + { + id: 'll', + name: 'leanleft' + }, + { + id: 'c', + name: 'center' + }, + { + id: 'lr', + name: 'leanright' + }, + { + id: 'r', + name: 'right' + }, +]; diff --git a/src/utils/loadData.js b/src/utils/loadData.js index 8604002..bba4d1a 100644 --- a/src/utils/loadData.js +++ b/src/utils/loadData.js @@ -92,21 +92,21 @@ const loadData = async () => { lr: +d.allsides_engagments_leanright, r: +d.allsides_engagments_right }, - fb: { + facebook: { l: +d.allsides_engagments_left_facebook, ll: +d.allsides_engagments_leanleft_facebook, c: +d.allsides_engagments_center_facebook, lr: +d.allsides_engagments_leanright_facebook, r: +d.allsides_engagments_right_facebook }, - tw: { + twitter: { l: +d.allsides_engagments_left_twitter, ll: +d.allsides_engagments_leanleft_twitter, c: +d.allsides_engagments_center_twitter, lr: +d.allsides_engagments_leanright_twitter, r: +d.allsides_engagments_right_twitter }, - re: { + reddit: { l: +d.allsides_engagments_left_reddit, ll: +d.allsides_engagments_leanleft_reddit, c: +d.allsides_engagments_center_reddit,