How do I get a chart to redraw itself when the model is paused? - anylogic

I have a Time Stack Chart whose data set can be changed by clicking on a radio button. While the model is running, the chart instantaneously updates its appearance when a radio button is clicked. When the model is paused, however, the chart's area becomes blank when a radio button is clicked; the legend, in contrast, updates automatically. How do I manually force the chart area to redraw itself?

When you pause a model, only a part of Anylogic is actually paused. The thread that handles the GUI keeps running, which is why you can navigate around in the model while it is paused.
This also means that if you try to update a chart's data while the simulation is paused, the appearance will refresh but -- as your data is being updated in another thread that is currently paused -- it will not have received that data.
If you want to pause the simulation and still be able to switch the data being displayed in a chart, you could take a look at the Airport example model. It provides a good method to switch between different charts by making them visible/invisible and adjusting the width, height, x and y. Essentially, you make all of the charts you need, overlap them perfectly, and then make visible the one that is currently of interest to you.
If you want to create the charts programmatically, on top of creating the chart with, e.g., new TimeStackChart(...), you also have to add it to the top level presentation group with main.presenation.add(...). If you don't do this, the chart will never appear in the model as the model won't have anything to display! To find more information on how to create a chart programmatically, make a chart in Main and then open Main in the Java editor. Find the chart you created, take a look at it's constructor (there are a lot of arguments!), and use it as rough template for the charts you wish to create. The Help documentation will further make sense of the parameters you see.

have you tried the chart.refresh(); method?
Also try to update the embedding agent using agent.onChange().
hope that helps

I encountered the exact same problem, and came up with workaround.
Try this, which I know works in AnyLogic v7:
if (getEngine.getState() == getEngine().PAUSED ){
dynChart.setSelectedItemIndices( new int[]{0} );
dynChart.setSelectedItemIndices( null );
}
I was able to get the chart to refresh manually when paused or finished by selecting/deselecting one of the legend items. I spent a few hours try out API variations to no avail, so I just emulated what was actually working in the UI and it worked.
I am dynamically generating a text item as the chart title, but I have not had the same luck getting the text to refresh when paused like the chart. Any ideas on that one?

Related

Echarts 5 line graph click to change colour not working

I'm trying to make a line graph change color on mouse click by using the select.lineStyle.color attribute.
I'm able to trigger a colour change for the points upon mouse click using select.itemStyle.color and I'm expecting the select.lineStyle.color attribute to change the color of the graph but , it doesn't seem to work despite the documentation saying that select should work for all series.
I even programmatically fired the "select" event (not in the sandbox) but no changes were observed in my line graph.
My code sandbox
Extract from the docs
In addition, we've added click to select to all series, an interaction that was previously only available in a few series such as pie charts and maps, allowing developers to set it to single or multiple selection mode, and to listen to the selectchanged event to get all the selected shapes for further processing. As with emphasis and blur, the selection style can also be configured in select.
Please help me. I've been working on this for a week and found no solutions here. Is there something I'm missing?
Got my answer directly via posting an issue on their Github page.
Apparently, select is only applicable for data object, not series objects(or whatever you call it). So this feature is not available.
What I did, like most people, is to listen to the mouseclick event and update the series-line.lineStyle.opacity property in options directly to blur out other lines. Set triggerLineEvent:true so that clicking any part of the line will fire the mouseclick event, instead of just the data points.

Visibility parameter of WPF control not visible with UI Automation?

I started writing test for a WPF application with FlaUI (UI Automation framework). Now I want to get the Visibility value of a couple of buttons.
These buttons are located on the same position in the WPF window. The first is a start button which will start a measurement. When clicked, the measurement button is replaced with a stop button. The visibility of these buttons are set in the code behind of the xaml and needs to be checked/verified.
With FlaUI I only get IsEnabled boolean and OffScreen boolean. But when using the Offscreen parameter, this boolean is not set or is set to the correct value for a couple of seconds but is changed again while the measurement is still running.
I also tried other ways, like looking for a clickable point of the not visible button. But those are not working.
Can this be done without extending the button class with an AutomationPeer and exposing a ValuePattern? I googled a bit but cannot find an (decent) answer. Hopefully someone can help.
I think an important part of your question is the word "replaced". Commonly a program draws one set of controls (in your case the start button) and later draws another set. Possible on top to hide the first, or possible by deleting them.
Commonly controls, including buttons, are drawn within other containing controls and so it may be that the button controls are not there at all, hence the visibility checks should be done on the parent or ancestor controls.
This Q&A seems related to the problem you are having and it may provide some more insight.

mapbox with markers and checkboxes - disable all from showing on initial load?

I have a page I built to display wind direction/velocity in various locations along a bike trail:
http://microflush.org/cgi-bin/pathInfo.cgi
I have several markers in a legend, with check boxes to enable/disable them from showing up on the map.
My goal is to have NONE of the checkable markers show up on the initial load. However, when the page is loaded for the first time, ALL show up-- even though they're not checked. If I select 1, they all go away except for the one I selected, which will then disappear if I un-check that box.
Is there a way to make them all be invisible at first, and only show up if they're selected?
(You can view the source of the link above to see the code. I wasn't sure if I should post that all, since it's kinda long with all the points I've added.)
Thanks!
Resolved. The 'var map' needed to be defined earlier in the code. Working properly now.

How may I force a redraw of all Vaadin charts in a dashboard to toggle dataLabels on or off?

How may I force a redraw of All Vaadin charts in a dashboard to toggle dataLabels on or off?
I would like to allow my app user to add/remove chart dataLabels for All charts on their dashboard; forcing a redraw similar to when changing themes say from VaadinTheme to GridTheme.
How may I achieve this?
How does changing themes work under the hood, what is the source code that does this?
e.g.;
I know I could redraw a single chart individually by resetting its plot options and then redrawing it:
.
.
.
PlotOptionsColumnRange columnRange = new PlotOptionsColumnRange();
columnRange.setDataLabels(new Labels(true));
columnRange.setDataLabels.setFormatter(/* some javascript about this.y */);
conf.setPlotOptions(columnRange);
chart.drawChart(conf);
But I want to do it for All charts on a dashboard; like having a Listener that does
ChartOptions.get().setTheme(new VaadinTheme())
then
ChartOptions.get().setTheme(new GridTheme())
and viceversa
Maybe I can reset the plotOption dataLabels then reset the theme to force a redraw with the new dataLabel state?
Please advise...
p.s.
I don't want to make changes to my user saved data in my database, i.e., I don't want this label toggle to be persistent. I want to toggle dataLabels just like a toggling themes.
Please look at:
http://demo.vaadin.com/charts/#ColumnRange
to see what I mean.
Ok, two solutions:
A coworker of mine that worked on the Dashboards helped me with the first answer to this question.
Basically, you have to clear all charts, then iterate through ea. chart in a particular dashboard (stored in the DB), and rebuild ea. chart w/ your decision to have or not have a dataLabel, placing it back in that dashboard; but I wanted to avoid this as it might take a performance hit.
Also I later got a response from Pekka of the Vadding team, as follows:
'You can easily hide the dataLabels with basic css. For example, if you can apply a stylename "dataLabelsHidden" to you UI, then you could write in your stylesheet a specific enough rule for hiding the labels. I quickly tested the demo with this:
.v-ui.dataLabelsHidden g.highcharts-data-labels {
display: none;
}
This way you won't have to update all your charts when the labels on/off is triggered.'

Showing markers programmatically

Is there a way to (programmatically) make a certain IMarker be shown in the problem view, similar to what happens when the user selects "View in..." from the context menu? I have a wizard which may cause markers to appear, and I would like to make these markers visible in the problem view when the wizard is complete.
You will just have to make your markers to be problems. However there are separate Markers view that shows all the markers.
To show marker you can use MarkerViewUtil.showMarker(..)
Ignoring all good API rules, you could look into the internals of FiltersConfigurationDialog to create a new resource filter in the problems view programmatically. But I repeat: there is no API for creating problems filters and this might then break at any time.