GemVennDiagram
A Venn (Euler) diagram is a diagram style that shows the logical relation between sets. It is used to teach elementary set theory, and to illustrate simple set relationships in probability, logic, statistics, linguistics and computer science. For example, it can be used to show the overlap between customer segments who bought different products, or the shared skills between team members.
Usage Example
/* (c) https://github.com/MontiCore/monticore */
package example_charts;
import Domain.Person;
import mc.fenix.charts.GemVennDiagram;
import common.ExamplePage;
page GemVennDiagramExample(List<Person> persons) {
@ExamplePage(
component = venndiagramm@GemVennDiagram(
data = null,
showConfig = true
),
basePath = "example_charts",
componentName = "GemVennDiagramExample",
simple = true
);
}
TypeScript implementation:
/* (c) https://github.com/MontiCore/monticore */
package example_charts;
import com.google.common.collect.Lists;
import domain.Person;
import mc.fenix.charts.gemvenndiagramtypes.GemVennDiagramData;
import mc.fenix.charts.gemvenndiagramtypes.GemVennDiagramDataBuilder;
import mc.fenix.charts.gemvenndiagramtypes.GemVennDiagramEntry;
import mc.fenix.charts.gemvenndiagramtypes.GemVennDiagramEntryBuilder;
import umlp.jsweet.extension.annotation.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class GemVennDiagramExample extends GemVennDiagramExampleTOP {
public GemVennDiagramData getVenndiagrammData() {
if (this.getPersons() == null) {
return null;
}
List<GemVennDiagramEntry> entries = new ArrayList<>();
Map<String, List<Person>> mapOfriends = new HashMap<>();
for (Person person : this.getPersons()) {
GemVennDiagramEntry node = new GemVennDiagramEntryBuilder()
.sets(Lists.newArrayList(person.getName()))
.label(person.getName())
.size(person.getFriendsList().size()).build().get();
mapOfriends.put(person.getName(), person.getFriendsList());
entries.add(node);
}
mapOfriends.entrySet().forEach(e -> {
for (Person friend : e.getValue()) {
if (mapOfriends.containsKey(friend.getName())) {
GemVennDiagramEntry node = new GemVennDiagramEntryBuilder()
.sets(Lists.newArrayList(e.getKey(), friend.getName()))
.label("")
.size(1).build().get();
entries.add(node);
}
}
});
return new GemVennDiagramDataBuilder().entries(entries).build().get();
}
}
GUI Model
component GemVennDiagram(
GemVennDiagramData data,
boolean showConfig = false
)
| Name |
Type |
Description |
Default value |
data |
GemVennDiagramData |
The sets and their overlaps to be displayed in the diagram. |
|
showConfig |
boolean |
Whether the chart's configuration panel is shown. |
false |
Types
GemVennDiagramTypes
package mc.fenix.charts;
import java.util.List;
<<pojoCD>>
classdiagram GemVennDiagramTypes {
public class GemVennDiagramData {
List<GemVennDiagramEntry> entries;
}
public class GemVennDiagramEntry {
List<String> sets;
String label;
Integer size;
}
}
GemVennDiagramData
| Name |
Type |
Description |
Default value |
entries |
List<GemVennDiagramEntry> |
|
|
GemVennDiagramEntry
| Name |
Type |
Description |
Default value |
sets |
List<String> |
|
|
label |
String |
|
|
size |
Integer |
|
|