Search code examples
chartsdata-analysisanylogicenergy

Variable time axis in (time-)charts


I have built an energy flow simulation for factories in Anylogic. I would like to do a detailed analysis in the Anylogic model (not in Excel), looking at energy flows that I currently plot in a chart over the whole year at other levels of detail. For example, I would like to look at the energy profile of the same graph with a time axis that represents only one month, one week, or as the smallest unit, one day. Ideally, I can still change the time period after the simulation has run through.

My first approach was to simply create different graphs and link a parameter, e.g. the month, to the visibility of the graph.

However, the effort is very large, since I would have to create 365 diagrams just to be able to display each day. Does anyone of you know a way to automate this chart creation or a way to make the x-axis of charts more flexible. Are there already solutions for this problem or does anyone know how this could work?

Best Christoph


Solution

  • The easiest way is to:

    • have 1 time plot only (with no dataset at all initially)
    • have a dataset that stores all your data (x values are days, y values your data for the day)
    • use a function to create your own custom dataset mySpecificDS using DataSet mySpecificDS = new DataSet(numberOfDays) (see help to see how to code datasets directly) --> this should cover only the time period of interest from your full dataset that contains all days
    • add your custom mySpecificDS to your chart using plot.AddDataSet(mySpecificDS)

    You can remove old datasets from your plot as well using plot.remove(mySpecificDS) if you want to plot a new one.

    Check the help for those functions for more info