Change node style based on name / label - javascript

I'm using vis.js to visualise a network.
The network is created based on the DOT language (Directed graphs).
An example:
1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1
would create this graph / network:
More info about how this works here
My problem is that I want to make a node with a certain label ("1" for example) to be a different color.
Is this possible and how would I do this?

Related

Grouped bar chart displaying cross tab between groups

I'm trying to make a group bar chart that gives the frequency of two group combos. I referred to this site for rollup and nest function reference:
http://bl.ocks.org/phoebebright/raw/3176159/
I'm trying to use my own dataset to create the following effect:
https://bl.ocks.org/bricedev/0d95074b6d83a77dc3ad
My current attempt with my own data, drug1.csv:
https://blockbuilder.org/lydiawawa/9efb5df76c08640316efbef702437db7
In the console, the grouped counts do not seem to generate the right distributions. Something is wrong with my rollup and nest
const nestedData = d3.nest()
.key(function(d){return d.s_category})
.key(function(d){return d.drug_cat})
.rollup(function(leaves) { return leaves.length; })
.entries(data);
Following is the desired cross tab distribution count of s_category x drug_cat :
1 2 3 4 5 6
2 367 35 8 1 1 1
3 223 24 4 4 2 2
4 29 5 9 1 2 3
5 37 1 3 3 2 26
Static chart:
In the animated bar graph that I attempted to create, cross tab count should be the y-axis, drug_c is the x-axis and s_category determines the groups of the bar graph. Thank you for any help!
The moment you use the nest generator you don't have drug_cat and count as properties anymore: you have key and values (or value for the inner arrays).
Here is your block builder changing the names of those properties: https://blockbuilder.org/GerardoFurtado/f4c825a5f8c92e87cc5a81591ba1f7c9

OpenLayers fitting before add features

Problem: Open layers is fitting to map and only after is adding features (visually), how can i avoid this?
im doing this
step 1 - creating the features
var feature = new ol.Feature({...});
step 2 - adding them to source
source.addFeature(feature);
step 3 - and fitting like this
view.fit(source.getExtent(), { duration: 1000 });
but visually is showed step 3 -> step 1 -> step 2
i want to do step 1 -> step 2 -> step 3 (by code order)
You can try and fit the view on addfeature
source.on('addfeature', function() {
view.fit(source.getExtent());
});
The best way to achieve this is to create the layer without a source, and set the source of the layer after view.fit:
const layer = new ol.layer.Vector();
const source = new ol.source.Vector();
source.addFeature(feature);
view.fit(source.getExtent());
layer.setSource(source);

How do you remove the data value from the mouse-over result in radar chart?

Currently I am working with a dynamic set of data and Chart.js. There is no standardised scale within the data I am using, so I have created a simple algorithm, for example:
3 out of 7 for question 1 [3 * (12 / 7)]
2 out of 9 for question 2 [2 * (12 / 9)]
6 out of 7 for question 3 [6 * (12 / 7)]
So that all the results for the Radar Graph are measured equally at 12.
By doing this the value is not going to be correct, even though the position of the point in respect to the rest of the graph will be.
[Label]Question 1 (3/7) : [Value]5.14
I have already included the true value in the label by combining the label with the data in the label array.
So I would like to show just the label when the mouse hovers over the spoke or dot on the chart.
Question 1 (3/7)
Is there a way of doing this without messing around with the Chart.js file?
Use the tooltipTemplate option
new Chart(ctx).Radar(data, {
tooltipTemplate: "<%=label%>",
});
Fiddle - http://jsfiddle.net/dz6mt4dy/

Event Repots in 3 dimensions (piwik)

I'm using piwik, but I have a question about the Events Report. I would like to have for each Categories, the corresponding Actions, and for each Actions the corresponding Names. Like this : Categories -> Actions -> Name
Because right now I can see only 2 dimensions for the Events. So is it possible to have 3 dimensions ? or do I have to create my own report to get this ?
Thank you
You have to create your own report to get this (it's recommended to pre-archive it). Basically you will have to group the data by the 3 mentioned dimensions.

Simple HTML bar graph generation

I am a c++ Linux guy who is trying to make a bar graph using html or js.
I tried googling on how to generate the bar graph. But couldn't understand it properly.
I have a file (content.txt) with the following content:
A - 0
B - 3
C - 1
D - 2
E - 2
F - 0
All the alphabets needs to be represented in Y axis.
The bar color is based on the value in the file. (always the value will be in the range of 0 to 3)
All the four values needs to be represented in different colors.
The graph looks like below.
Please help me out in reading the content.txt file (which dynamically changes its value of A to F within 0 to 3) & represent as a graph.
As described above, the hardest part will be reading the data from the file system. If you could put your data into a JSON blob or an object, it'd be much easier.
Is there any reason you'd want the bar chart to be full on HTML? For simple charts, I highly recommend ChartJS (http://www.chartjs.org/docs/#bar-chart) ...it's very simple to use especially if your data is in JSON / Obj format.

Categories