Skip to content

GemCandlestickChart

A candlestick chart displays important datapoints for a (short) period of time, and is often used to show how stock prices changed over said periods. Each candlestick's horizontal position represents time, while its vertical bar and the line crossing through it represent the opening, closing, highest, and lowest price of that period. The candlestick's color indicates whether the price went up (green) or down (red), which determines whether the top of the bar shows the opening or closing price (and vice versa for the bottom). For example, it can be used to visualize the daily price movements of a stock or cryptocurrency over the course of a month.

Usage Example

/* (c) https://github.com/MontiCore/monticore */
package example_charts;

import Domain.Person;
import mc.fenix.charts.GemCandlestickChart;
import common.ExamplePage;

page GemCandlestickChartExample() {
  @ExamplePage(
    component = @GemCandlestickChart(
      data = getData(),
      showConfig = true
    ),
    basePath = "example_charts",
    componentName = "GemCandlestickChartExample"
  );
}

TypeScript implementation:

/* (c) https://github.com/MontiCore/monticore */
package example_charts;

import mc.fenix.charts.gemcandlestickcharttypes.GemCandlestickChartData;
import mc.fenix.charts.gemcandlestickcharttypes.GemCandlestickChartDataBuilder;
import mc.fenix.charts.gemcandlestickcharttypes.GemCandlestickChartEntry;
import mc.fenix.charts.gemcandlestickcharttypes.GemCandlestickChartEntryBuilder;
import umlp.jsweet.extension.annotation.Component;

import java.util.Arrays;

@Component
public class GemCandlestickChartExample extends GemCandlestickChartExampleTOP {

  /**
   * Provides sample data for the candlestick chart.
   * This method is called by the GUI file via "data = getData()".
   */
  @Override
  public GemCandlestickChartData getData() {

    // The expected order of values is: open, high, low, close
    // We use the ISO format YYYY-MM-DD for the date labels.

    GemCandlestickChartEntry entry1 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-01")
        .value(Arrays.asList(150f, 165f, 145f, 160f))
        .build().get();

    GemCandlestickChartEntry entry2 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-02")
        .value(Arrays.asList(160f, 170f, 155f, 168f))
        .build().get();

    GemCandlestickChartEntry entry3 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-03")
        .value(Arrays.asList(168f, 175f, 160f, 162f))
        .build().get();

    GemCandlestickChartEntry entry4 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-04")
        .value(Arrays.asList(162f, 165f, 140f, 145f)) // Sharp drop
        .build().get();

    GemCandlestickChartEntry entry5 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-05")
        .value(Arrays.asList(145f, 155f, 142f, 150f))
        .build().get();

    GemCandlestickChartEntry entry6 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-06")
        .value(Arrays.asList(150f, 180f, 148f, 175f)) // Strong recovery
        .build().get();

    GemCandlestickChartEntry entry7 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-07")
        .value(Arrays.asList(175f, 185f, 170f, 180f))
        .build().get();

    GemCandlestickChartEntry entry8 = new GemCandlestickChartEntryBuilder()
        .label("2026-03-08")
        .value(Arrays.asList(180f, 195f, 175f, 190f))
        .build().get();

    // Compile the entries into a single data object to be sent to the frontend
    return new GemCandlestickChartDataBuilder()
        .entries(Arrays.asList(entry1, entry2, entry3, entry4, entry5, entry6, entry7, entry8))
        .build().get();
  }
}

GUI Model

component GemCandlestickChart(
  GemCandlestickChartData data,
  boolean showConfig = false
)
Name Type Description Default value
data GemCandlestickChartData The data entries to be displayed in the candlestick chart. Each entry is expected to provide values in the order: open, high, low, close.
showConfig boolean Whether the chart's configuration panel is shown. false

Types

GemCandlestickChartTypes

package mc.fenix.charts;
import java.util.List;

<<pojoCD>>
classdiagram GemCandlestickChartTypes {

  public class GemCandlestickChartData {
    List<GemCandlestickChartEntry> entries;
  }

  public class GemCandlestickChartEntry {
    String label;

    List<Float> value;
  }

}

GemCandlestickChartData

Name Type Description Default value
entries List<GemCandlestickChartEntry> * The list of candlestick entries to be plotted on the chart.

GemCandlestickChartEntry

Name Type Description Default value
label String * The label for this specific entry, typically representing a time period or date on the horizontal axis.
value List<Float> * The list of values defining the candlestick's shape. * Expected order: open, high, low, close.