Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add groups to legend. #51

Open
ConnorHayward opened this issue Aug 10, 2015 · 15 comments
Open

Add groups to legend. #51

ConnorHayward opened this issue Aug 10, 2015 · 15 comments

Comments

@ConnorHayward
Copy link

Hello.

I have produced a graph which has groups made by a node attribute, Department. Using one of the other tips, I have managed to change the group selector to show the correct group names and colours.

However, I would also like to have a similar list visible in the legend part, to allow easier reading of the graph without opening the drop down. I have fudged it by creating separate images and calling those from the style sheet, but I was wondering if there was a more elegant solution using the main.js?

I have very little CSS, html or JavaScript knowledge, so I apologise if this is an easy fix.

@computermacgyver
Copy link
Member

Hi Connor,
This is a nice idea for a new feature to be added in a future version, and I will keep it open as a reminder for that. Also, longer term, but linked with this, is a need to make sure the legend doesn't become too tall such that it doesn't fit on the screen (particularly with mobile devices).

I don't have a quick and easy fix for you to implement right now, I'm afraid. The nicest looking solution would probably be editing the HTML of the index.html file to add in the legend, but this will require some more familiarity with HTML.

@ConnorHayward
Copy link
Author

I have had a good look at the scripts running in the background, and with a fair bit of poking around, have found a fairly simple solution. It requires reading through the nodes to get the groups, then pushing these to a table.

You can also reuse the html from the group select box to populate the table, although the reliance on color to group makes this somewhat unreliable.

@CBC88
Copy link

CBC88 commented Feb 22, 2017

Hi Connor

This is a long shot but I seem to have the same issue (for example I want to change 'Group 1' to 'Material' and so on). Could you explain how you managed to fix this please? Bare in mind I'm a complete noob for programming.

This is for a network of all researchers in additive manufacturing

@ConnorHayward
Copy link
Author

Well, it has been a long time since I have looked at any of it, or JS in general, but I will help as much as I can.

Step 1:
In the config.json file that is generated, there is a line like:

"groupSelectorAttribute": "foo",

Where foo is the attribute storing the group name in the node (this is what the column is called in Gephi, I believe).

Now this is where my memory is hazy, as I added a few more features as well, and I only vaguely remember what was what (I should comment my code more).

In essence, you need to loop over all the nodes, reading in their value for the foo variable, filter to get unique names, then use that to populate a table in the legend section. I can give code examples when I get my head around what I did last time.

Sorry I can't be of more help right now.

@CBC88
Copy link

CBC88 commented Feb 23, 2017 via email

@ConnorHayward
Copy link
Author

Found the line! I may have fist pumped on a train too!

In the main.js file, there is a function called configSigmsElements

This function does a lot, but the line you want looks like

For(b in sigInst.clusters) a.push...

Then some HTML stuff. In here, it has 'Group' + x++' which assigns the groups their name. Change the x++ to sigInst.clusterTitles[b] and that should get the names to appear in the group selector.

A similar line in the legend section can be added to make a legend too, iirc.

@ConnorHayward
Copy link
Author

Forgot a few key points!

Around line 90 something, there is a line
Dataready = function()

Add a line:
a.clusterTitles = {};
Below this.

Then in the function(b) section add an if statement reading in the group titles if they match what ever attribute you set in the config file. I can give more details if needed.

@CBC88
Copy link

CBC88 commented Feb 27, 2017 via email

@CBC88
Copy link

CBC88 commented Mar 2, 2017 via email

@StoicNZ
Copy link

StoicNZ commented Jun 2, 2017

network.zip

@CBC88

Replace your network.zip with this or extract this and copy it over your exported directory.

If you have groupings checked, it'll name the groups after your group value.

@computermacgyver I'll pull request this, this evening - it's a little weird pull-requesting a zip file though, heh.

@computermacgyver
Copy link
Member

Thank you, @StoicNZ! I can grab the zip from here --- no need for a pull request of the zip. If do have time to create a pull request, the best place for that would be the "network" folder of this repository where the HTML code is

@StoicNZ
Copy link

StoicNZ commented Jun 5, 2017

Seems to be quite a few changes in that repo, @computermacgyver - with CSS, ReadMes, config files. Having some 2FA issues (moved country, 2FA issues to push - thankfully still logged in here though). Do you mind pushing that network file to this repo and I'll go ahead and migrate changes to that other repo this coming weekend?

@schignel
Copy link

I have a very similar issue as @ConnorHayward. I have a column that I would like to base the groups off of so that people can slice the graph by different categories. @StoicNZ and @computermacgyver, it looks like you were working on a simple way to do this? I'd be very grateful for any help!

@computermacgyver
Copy link
Member

Hi @schignel , Thank you for flagging that this still needed to be incorporated. Does replacing your js/main.js file exported from Gephi with the file of the same name from the zip file uploaded by StoicNZ do what you want? Please keep all the other files the same and only replace the js/main.js file. When you export your graph from Gephi, you should choose choose the column with the names as the column to use for the group values.

@schignel
Copy link

schignel commented Dec 27, 2017

Thanks @computermacgyver! Replacing the js/main.js file as you suggested worked.

I have a quick follow up question on this:

The legend worked for three of my groups (the black, white, and grey nodes). However, I have separate colors assigned to different nodes in the fourth group, "Sustainable Development Goals." Is there a way to have these represented as a single group based on the column value rather than split out by the node colors? I've attached a screenshot for you.
groups

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants