The Modern, Extensible and Interactive Number Exploration Library (or short: m.e.i.n.e.l) is a visualization library for various forms of data. It focuses on abstracting the interfaces in a way that one only needs to supply the data and few (optional) parameters to embed visually appealing charts into existing environments. These interfaces are implemented by utilizing Polymer components.
Plotly.js and D3.js for visualization and Polymer.js for leveraging the full power of Web Components build the base for the m.e.i.n.e.l. project.
Plotly.js is used for basic visualizations whereas D3.js is used for more complex and custom visualizations.
- clone the repo with
git clone https://github.com/openHPI/m.e.i.n.e.l.git
- change into the cloned directory with
cd m.e.i.n.e.l
- install Polymer
- perform
npm install
to install the dependencies - do
polymer serve
- head to
localhost:8081/components/m.e.i.n.e.l/
in your browser & you are done! 😊
-
copy an existing diagram's main file (i.e.
barchart-basic.html
for the barchart) -
copy the corresponding demo file in
demo/
(i.e.demo/barchart_basic_demo.html
) -
rename both to a name of choice (keep in mind that Polymer components need to have a dash in the name)
-
make the following changes to the main file you just copied from
src/
:- change the title in the first comment and also its description
- change the
@demo
reference to the new file you copied indemo/
- change the
<dom-module id=""
- change the Polymer ID in the JS part (functions
is()
andproperties()
) - change the rest of the code to match your needs
- document it correspondingly (see Polymer doc)
-
edit the file you copied in
demo/
:- change the title
- change the import tag to import your custom component
- change the headline (
<h3>
) - embed your component accordingly inside the
<demo-snippet><template>HERE</template></demo-snippet>
part
-
append your diagram to the
to all-imports.html
file -
Run
polymer analyze > analysis.json
from the projects root folder to regenerate the documentation file.
d3.select(...)
typically scans the whole DOM, how can I limit it to the local DOM of the Polymer component?- in your
<template>
section, use a<div>
which wraps all parts of your chart - every time when you would do
d3.select(...)
, make sure to do a preselection using that div's ID to limit traversal to the local DOM:d3.select(this.$.divID).select(...)
- in your
- When passing my function
f
to a D3 built-in function, I can't access my Polymer component's attributes usingthis.attributeName
insidef
- Make sure to pass
f.bind(this)
instead off
to the D3 built-in function
- Make sure to pass
- It seems like the
data
attribute isnull
when my code attempts to plot the diagram- Make sure to read up on Polymer Lifecycle Callbacks. If you're using the
ready
function as a trigger to plot your diagram, it might be worth to see whether usingconnectedCallback
can fix your issue. In that case, remember to callsuper.connectedCallback
as well!
- Make sure to read up on Polymer Lifecycle Callbacks. If you're using the
- The hover effect and some labels might be off for Plotly.js
- This is a known issue when using Plotly.js with Polymer. In that case, you need to import the shared
plotly-styles.html
: with<link rel="import" href="../shared-styles/plotly-styles.html">
and include these in you main style element with<style include="plotly-styles">
.
- This is a known issue when using Plotly.js with Polymer. In that case, you need to import the shared
-
Create the documentation:
npm run analyze
-
Bump version and build artefacts
npm version 3.1.2 npm run bundle
-
Push everything incl. the new tag
-
Zip the content from the build directory and name it
m.e.i.n.e.l-v3.1.2.zip
-
Create a new GitHub release named
Version 3.1.2
for the tag pushed a few moments ago and shortly describe your changes.
It is recommended to use the bundled version of m.e.i.n.e.l in production. It is created and attached to each release on GitHub, but can also be manually created by executing npm run build
. The bundle consists of the following files:
custom-elements-es5-adapter.js
: [ES5 only] Required to load the ES5 code to modern ES6-enabled browsers.polyfills-ie.js
: [ES5 only] Load before any other files of this bundle to support Internet Explorer 11.m.e.i.n.e.l.js
: Bundled version incl. required dependencies.webcomponents-bundle.js
: Polyfill loader for browsers that do not support WebComponents natively.
To use m.e.i.n.e.l in your web application without differing between ES5 and ES6, use the following imports:
<script src="build/es5/polyfills-ie.js"></script>
<script src="build/es5/custom-elements-es5-adapter.js"></script>
<script src="build/es5/webcomponents-bundle.js"></script>
<script src="build/es5/m.e.i.n.e.l.js"></script>
In modern browsers, the ES6 version should be used preferably.