Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

ChartArchitecture

Álvaro Carrera edited this page Jun 18, 2013 · 1 revision

= Introduction =

In order to see any relevant piece of information at a glance, you can add three different types of charts to your simulation: a Time chart, a Scatter Plot or an Histogram.

= Time chart =

http://shanks-with-mason.googlecode.com/svn/wiki/images/architecture/TimeChart.png

This is a simple something-time chart. To create it, call the method addTimeChart(name, xlabel, ylabel) in the GUI you are using (either 2D or 3D). This method takes as parameters a unique name for the chart, and the labels for the axis.

Once created, you can add the data using the method addDataSerieToTimeChart(chartID, dataID, x, y) in the ScenarioPortrayal. It would take four parameters, the name of the chart, a String with the data ID, and the coordinates of the data to add.

An usual way of using this is giving simulation.schedule.getSteps() as the x coordinate, thus becoming the time variable.

Notice that you can have several functions in the same chart, simply by giving them a different dataID String.

= Scatter Plot =

http://shanks-with-mason.googlecode.com/svn/wiki/images/architecture/scatterPlot.png

To create this kind of graph, call the addScatterPlot(name, xlabel, ylabel) method. This method takes as parameters a unique name for the chart, and the labels for the axis.

The first time you add the data you must use the method addDataSerieToScatterPlot(scatterID, data). This method will take two variables, the name of the chart, and the data to add. This data must be a two dimensions array of double. The first dimension must be 2, since it stands for the coordinates, but the second dimension can be any integer, since is the array itself.

If you want to add some data to the same chart, by using the same method a new chart will be created, on top of the first one. To keep thing simple, we recommend the usage of the updateDataSerieOnScatterPlot(scatterID, index, data). As usual, this will take the data double[][] array and update the graph corresponding with the scatterID. If you only have one graph on the window,the index var would be 0.

But if you actually want to have a few different charts one in top of the others, the index tells the program which one is to be updated. It is the order of the graph you are using. I.e, if you have used three times the addDataSerieToScatterPlot(...) method, three graphs would have been created, and a 0 would be the one from the first call, a 1 the second graph created, an a 2 the last one.

= Histogram =

http://shanks-with-mason.googlecode.com/svn/wiki/images/architecture/histogram.png

To create and add histogram to your simulation, the method addHistogram(histogramID, xlabel, ylabel) is to be used. As in the other two charts, this method takes an unique name for the chart, and both the x and y axis labels.

To add data, use the addDataSerieToHistogram(histogramID, data, binsCount). In this case, the data must be and array with a set of values. Be careful, this array should not contain the values of the different bins, but a set of data to be counted. The binsCount variable is the number of bins you want in your graph.

Given the number of bins, this will show a count on the number of times a value is repeated. For example: [1,2,3,1,1,3], and bins = 3 Will provide a graph similar to the one on top.

If the number of values is different than the number of bins, then each bin will represent the number of values in a range, evenly distributed between the minimum and the maximum value. For example: [1,2,3,1,1,3], and bins = 2 Two ranges will be considered: [1,2) and [2,3]. The middle value would be assigned to the upper range. In this example, the histogram will look:

http://shanks-with-mason.googlecode.com/svn/wiki/images/architecture/histogram2.png

= Know issues =

If two different charts have the same name, the program crashes. That is because the name of the window holding the charts is the graph name, and that would cause a conflict with java.

Clone this wiki locally