Search code examples
data-analysisanylogic

Creation of time plots with a function (anylogic)


I would like to create a TimePlot after my simulation run using a called function. I used the Constructor Summary from this page: https://anylogic.help/api/com/anylogic/engine/analysis/TimePlot.html and the following Code in the function. I don't get any mistakes when I build the model, but when I call the function the chart isn't created or can't be seen anywhere. Can somebody help me with this?

Best Christoph

new TimePlot(
            PV.this, true, 3000.0, 2000.0, //"PV" is the agent name
            720.0, 320.0,
            white, null,
            50.0, 60.0,
            640.0, 210.0, white, black, black,
            20.0, Chart.SOUTH,
            1* month(), Chart.WINDOW_MOVES_WITH_DATA, "dd.MM HH:mm", Chart.SCALE_AUTO,
            0, 0, Chart.GRID_DEFAULT, Chart.GRID_DEFAULT,
            darkGray, darkGray, null, null, null );

Solution

  • You need to manually add it to your presentation.

    First, store the TimePlot you created in a local variable such as TimePlot myPlot = new TimePlot(...);.

    Then, call presentation.add(myPlot).

    Else, you only created an object but did not tell AnyLogic to actually show it.