GemScatterPlot
A scatter plot visualizes a set of scattered points in a two dimensional space. The axes have a certain range and provide more detail with a title. For example, it can be used to visualize the correlation between a person's height and weight, or between advertising spend and sales revenue. It can also be used to show the distribution of exam scores against hours studied.
Usage Example
/* (c) https://github.com/MontiCore/monticore */
package example_charts;
import Domain.Person;
import mc.fenix.charts.GemScatterPlot;
import common.ExamplePage;
page GemScatterPlotExample(List<Person> persons) {
@ExamplePage(
component = @GemScatterPlot(
data = getSimpleData(),
xAxis = null,
yAxis = null,
showConfig = true
),
basePath = "example_charts",
componentName = "GemScatterPlotExample"
);
}
TypeScript implementation:
/* (c) https://github.com/MontiCore/monticore */
package example_charts;
import com.google.common.collect.Lists;
import mc.fenix.charts.gemscatterplottypes.GemScatterPlotData;
import mc.fenix.charts.gemscatterplottypes.GemScatterPlotDataBuilder;
import mc.fenix.charts.gemscatterplottypes.GemScatterPlotPoint;
import mc.fenix.charts.gemscatterplottypes.GemScatterPlotPointBuilder;
import mc.fenix.charts.gemscatterplottypes.GemScatterPlotSet;
import mc.fenix.charts.gemscatterplottypes.GemScatterPlotSetBuilder;
import umlp.jsweet.extension.annotation.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Component
public class GemScatterPlotExample extends GemScatterPlotExampleTOP {
public GemScatterPlotData getSimpleData() {
List<GemScatterPlotSet> entries = new ArrayList<>();
List<GemScatterPlotPoint> points = Lists.newArrayList(
new GemScatterPlotPointBuilder().x(7.0).y(5.0).label("").build().get(),
new GemScatterPlotPointBuilder().x(9.0).y(6.0).label("").build().get(),
new GemScatterPlotPointBuilder().x(10.0).y(7.0).label("").build().get());
Optional<GemScatterPlotSet> greenSet = new GemScatterPlotSetBuilder().label("Green data")
.color(Optional.of("green")).points(points).build();
greenSet.ifPresent(e -> entries.add(e));
points = Lists.newArrayList(new GemScatterPlotPoint(3.0, 3.0, "", Optional.empty()));
Optional<GemScatterPlotSet> blueSet = new GemScatterPlotSetBuilder().label("Blue data")
.color(Optional.of("blue")).points(points).build();
blueSet.ifPresent(e -> entries.add(e));
return new GemScatterPlotDataBuilder().sets(entries).build().get();
}
}
GUI Model
component GemScatterPlot(
GemScatterPlotData data,
GemScatterPlotAxis xAxis,
GemScatterPlotAxis yAxis,
boolean showConfig = false
)
| Name |
Type |
Description |
Default value |
data |
GemScatterPlotData |
The points to be displayed in the chart. |
|
xAxis |
GemScatterPlotAxis |
Configuration (range, title) of the horizontal axis. |
|
yAxis |
GemScatterPlotAxis |
Configuration (range, title) of the vertical axis. |
|
showConfig |
boolean |
Whether the chart's configuration panel is shown. |
false |
Types
GemScatterPlotTypes
package mc.fenix.charts;
import java.util.List;
import java.util.Optional;
<<pojoCD>>
classdiagram GemScatterPlotTypes {
public class GemScatterPlotData {
List<GemScatterPlotSet> sets;
}
public class GemScatterPlotAxis {
Optional<String> label;
Optional<Double> minValue;
Optional<Double> maxValue;
Optional<Double> stepWidth;
}
public class GemScatterPlotSet {
String label;
Optional<GemScatterPlotShape> shape;
List<GemScatterPlotPoint> points;
Optional<String> color;
Optional<String> hoverColor;
}
public class GemScatterPlotPoint {
double x;
double y;
String label;
Optional<Integer> pointRadius;
}
public enum GemScatterPlotShape {
CIRCLE,
SQUARE,
ROUNDED_SQUARE,
ROTATED_SQUARE,
CROSS,
ROTATED_CROSS,
DASH,
LINE,
STAR,
TRIANGLE;
}
}
GemScatterPlotData
| Name |
Type |
Description |
Default value |
sets |
List<GemScatterPlotSet> |
|
|
GemScatterPlotAxis
| Name |
Type |
Description |
Default value |
label |
Optional<String> |
|
|
minValue |
Optional<Double> |
|
|
maxValue |
Optional<Double> |
|
|
stepWidth |
Optional<Double> |
|
|
GemScatterPlotSet
| Name |
Type |
Description |
Default value |
label |
String |
|
|
shape |
Optional<GemScatterPlotShape> |
|
|
points |
List<GemScatterPlotPoint> |
|
|
color |
Optional<String> |
|
|
hoverColor |
Optional<String> |
|
|
GemScatterPlotPoint
| Name |
Type |
Description |
Default value |
x |
double |
|
|
y |
double |
|
|
label |
String |
|
|
pointRadius |
Optional<Integer> |
|
|