Maintainer: Danijel Beljan
Q election executive is one tool of the Q toolbox to display results of executive elections. Test it in the demo.
git clone [email protected]:nzzdev/Q-election-executive.git
cd ./Q-election-executive
nvm use
npm install
npm run build
There is one env variable IMAGE_SERVICE_URL
to be defined. It should contain a URL with 3 parameters that will get replaced before the URL is used to load the images.
{key}
will be replaced by the string Q-server stored as the key when the file got uploaded through Q-servers /file
endpoint provided by the file plugin
{width}
is replaced by the width the image should be loaded
{format}
will be png
or webp
(a picture
element is used in the HTML with multiple source
elements)
Example: https://q-images.nzz.ch/{key}?width={width}&format={format}
Start the Q dev server:
npx @nzz/q-cli server
To run the tool create a new file called dev.js
and use the env-variable listed above with the local urls.
process.env.IMAGE_SERVICE_URL = "https://q-images.nzz.ch/{key}?width=108&format=png&auto=webp";
require('./index.js');
You can then start the tool with:
node dev.js
The testing framework used in this repository is Code.
Run the tests:
npm run test
When changing or implementing...
- A
route
, it needs to be tested in thee2e-tests.js
file - Something on the frontend, it needs to be tested in the
dom-tests.js
file
We provide automatically built docker images. There are three options for deployment:
- Use the provided images
- Build your own docker images
- Deploy the service using another technology
- Deploy
nzzonline/q-election-executive
to a docker environment - Set the ENV variables as described in the configuration section
If a tool then it can use this reference to the Q-server documentation about Q-tools:
The tool structure follows the general structure of each Q tool. Further information can be found in Q server documentation - Developing tools.
Q Election Executive uses svelte3 to render the markup on server-side.
Here is what the tool looks like on mobile and other devices. The example shows survey results of the presidential elections in France in 2017. It's in German because we do not have multilanguage support (yet).
Each graphic has the following three sections:
- Header: contains specified title, subtitle and legend
- Main Part: displays results for each candidate. Optionally candidate pictures are shown on the left. As soon as the results are final a checkmark for elected candidates or a crossmark for voted off candidates are displayed. Additionally all candidates who have not been elected have b/w pictures and a less saturated color bar. If applicable a majority line will be shown.
- Footer: contains further notes (e.g. how many municipalities already finished counting), source(s) and update information
Here is a completely fictional example to show you the different states (currently part of the government, elected, voted off) and the majority line:
In case withErrorMargin
is true, the rendering looks different to show the error margin.
If withErrorMargin
is set to true, the candidates votes
input is hidden, instead the inputs errorMargin.lower
, errorMargin.bestGuess
and errorMargin.upper
are shown. These should be used to enter the errorMargin best guess as long as the lower and upper bound of the error margin.
Display options can be set before embedding the graphic in the article.
Allows to hide the title
Copyright (c) 2019 Neue Zürcher Zeitung. All rights reserved.
This software is licensed under the MIT License.