removing existing timeseries from dataset in Jfreechart - eclipse

I am using eclipse e4. I have three timeseries which has inputs dynamically from GUI.
/*some code to calculate the entries from a hashmap*/
for (i = 0; i < statValue.length; i++) {
if(statValue[i].equals("MIN"))
{
timeseries[i] = new TimeSeries(entries.getKey()+statValue[i],Second.class);
}
if(statValue[i].equals("MAX"))
{
timeseries[i] = new TimeSeries(entries.getKey()+statValue[i],Second.class);
}
if(statValue[i].equals("AVG"))
{
timeseries[i] = new TimeSeries(entries.getKey()+statValue[i],Second.class);
}
/* some code to calcluate the input to the timeseries */
if(statValue[i].equals("MIN")){
for(Entry<Timestamp,Long> seriesData : MinutesToMin.entrySet()){
System.out.println(new Second(seriesData.getKey())+" "+seriesData.getValue());
timeseries[i].add(new Second(seriesData.getKey()), seriesData.getValue());
}
dataset.addSeries(timeseries[i]);
}
System.out.println("MAX");
if(statValue[i].equals("MAX")){
for(Entry<Timestamp,Long> seriesData : MinutesToMax.entrySet()){
System.out.println(new Second(seriesData.getKey())+" "+seriesData.getValue());
timeseries[i].add(new Second(seriesData.getKey()), seriesData.getValue());
}
dataset.addSeries(timeseries[i]);
}
System.out.println("AVG");
if(statValue[i].equals("AVG")){
for(Entry<Timestamp,Long> seriesData : MinutesToAvg.entrySet()){
System.out.println(new Second(seriesData.getKey())+" "+seriesData.getValue());
timeseries[i].add(new Second(seriesData.getKey()), seriesData.getValue());
}
dataset.addSeries(timeseries[i]);
}
}
After the series are displayed in Jfreechart. In my code the timeseries may change depending on the "statValue" that I select from my GUI. The timeseries gets dynamically added. I do not want to add the timeseries if it is already present. How to check if timeseries is already present and is it is present I want to remove it.?

Every TimeSeries has a key to identify it. To see if a TimeSeries exists in a TimeSeriesCollection use the getSeries(Comparable) method in that class - it will return null if there is no series with that key. If it returns a non-null value, then you can call the removeSeries(TimeSeries) method to remove it.

Related

Blazorise chart with timeseries data

I am developing a portal with Blazor. The website will show some timeseries data in a chart.
For the charts I use Blazorise.Charts (1.0.5).
I want the chart to show the full date at the start of a day and between the days only hours (in a 24h format) and minutes. However it seems the Blazorise LineChartOptions do not accept my input.
My data model:
public class point
{
public double Value;
public DateTime ReceivedOn;
}
The options I use
public LineChartOptions _LineChartOptions { get; set; } = new LineChartOptions()
{
Parsing = new ChartParsing
{
XAxisKey = "ReceivedOn",
YAxisKey = "Value",
},
Scales = new ChartScales()
{
X = new ChartAxis()
{
Display = true,
Type = "timeseries",
Title = new ChartScaleTitle
{
Display = true,
Text = "Date"
},
Ticks = new ChartAxisTicks
{
StepSize = 1,
Major = new ChartAxisMajorTick
{
Enabled = true
},
},
}
}
}
I also tried adding the Time = new ChartAxisTime, but that option does not seem to work if you use Ticks.
The result I get when using these settings is:
Chart
Like you can see, it seems almost what I want, however the labels need to be in the HH:mm format and the date needs to be in the yyyy-MM-dd format.
What do I need to change to get this result?
I ran into the same issue. Honestly, after reading the Chart.js documentation, I just stopped trying to feed DateTime objects directly into the blazorise chart. According to the Chart.js documentation, it must be converted somewhere in blazorise, because the dates are fed into Chart.js as strings anyway. So I converted my DateTime[] to a string[] with DateTime pattern "O" (o Format Specifier de-DE Culture 2008-10-31T17:04:32.0000000) and everything went fine.
Furthermore, try time first instead of timeseries as the x scale type. Type timeseries behaves strangely on non-equidistant data.
My LineChartOptions:
public static LineChartOptions CreateLineChartOptions()
{
return new LineChartOptions()
{
Scales = new ChartScales()
{
X = new ChartAxis()
{
Type = "time",
Time = new ChartAxisTime()
{
Unit = "minute",
MinUnit = "minute"
}
}
}
};
}
My labels are wrongly formatted like yours; I'm still working on that.
My Razor Call:
<LineChart #ref="lineChart" TItem="double" Options="#LineChartOptions" />
For a minimum example, you can even leave the ChartAxisTime() object. It should run without it.
My minimal result:

arc-jsapi How can I st_geometry using a lookup field?

I am using the st_geometry field and try to view the PNU code value.
I tried two ways.
oracle DB query.
select a.pnu from LP_PA_CBND_4600000000 a
where sde.st_contains(a.shape,
sde.st_point(177566.6728471977,160430.12935426735, 4))=1
When an event occurs, click the map object
i got the evt.mapPoint(x,y).
4 is my srid.
this way is took a long time. and query was down...
i used the arcgis api`s IdentifyParameters
my code is follows.
PoiClick : function(map, evt) {
G_evt =evt;
console.log("ClickPoint ==== "+evt.mapPoint);
var targetLayerId = 'LP_PA_CBND';
var url = map.Layers.getLayerInfo(targetLayerId).SVC_URL;
var map = map.getMap();
//파라미터 설정.
var idParams = new krcgis.core.tasks.IdentifyParameters();
G_idparams =idParams;
idParams.geometry = evt.mapPoint;
idParams.mapExtent = map.extent;
idParams.returnGeometry = true;
idParams.tolerance = 3;
idParams.layerOption = krcgis.core.tasks.IdentifyParameters.LAYER_OPTION_ALL;
idParams.width = map.width;
idParams.height = map.height;
krcgis.Function.GetPoiInfo(url, idParams);
return evt.mapPoint;
},
//POI 정보를 가져온다.
GetPoiInfo : function(url, idParams) {
idTask = new krcgis.core.tasks.IdentyfyTask(url);
idTask
.execute(idParams)
.addCallback(function (response) {
G_response = response;
if (response) {
return response;
}
})
.addErrback(function (error) {
console.log('GetPoiInfo result error=', error);
});
}
It could be obtained in this way code pnu.
However, this way is different from the value that gets pnu code depending on the zoom level.
I want to get a single pnu code in a single x, y values.
how to get pnu code?
Database table :
IdentifyTask can be a little tricky, because it takes into account zoom levels, therefor it doesn't always return the same results.
I suggest that you use QueryTask. Just one problem - it doesn't have tolerance parameter, but you can buffer your evt.mapPoint and get Polygon.

How to pass more than one record between two forms?

I want to pass more than one record between two forms. The user opens Form-A, selects multiple records and then clicks a button that opens Form-B.
In Form-B there are two (or more) StringEdit controls and they should display values from the selected records.
I know how to pass only one record, to do that I use the following code in a method of Form-B:
if (element.args().parmEnumType() == enumNum(NoYes)
&& element.args().parmEnum() == NoYes::Yes)
{
myTable = element.args().record();
stringEdit.text(myTable.Field);
}
How should I change my code so that I can set the text of another StringEdit control to the field value of the next record that the user selected?
To do this, you can use an args to pass the records, which you will need to prepare in your Form-A, as below (taking the SalesTable as example);
int recordsCount;
SalesTable salesTable;
container con;
Args args = newArgs();
// gets the total records selected
recordsCount = salesTable_ds.recordsMarked().lastIndex();
salesTable = salesTable_ds.getFirst(1);
while(salesTable)
{
// storing recid of selected record in container
con = conIns(con,1, salesTable.RecId);
salesTable = SampleTable_ds.getNext(); // moves to next record
}
// passing container converted to string
args.parm(con2Str(con,','));
Then on your Form-B, you will need to override the init() method to read the args you created,
In order to retrieve passed arguments in the recipient from. Override the init() method of new form as shown
public void init()
{
container con;
int i;
super();
// string to container
con = str2con(element.args().parm(),'','');
// for sorting
for(i = 1;i<= conLen(con) ;i++)
{
salesTable_ds.query().dataSourceTable(Tablenum(SalesTable)).addRange(fieldNum(SalesTable,RecId)).value(SysQuery::value(conPeek(con,i)));
}
}
Hope it helps.
Taken from Ax-Forum
This will typically imply looping through the selected records in Form-A and changing the query in Form-B.
The idiomatic way to loop through selected records involves a for loop and the getFirst and getNext methods of the datasource:
SalesLine sl;
FormDataSourcs ds = _salesLine.dataSource();
for (sl = ds.getFirst(true) ? ds.getFirst(true) : ds.cursor(); sl; sl = ds.getNext())
{
//Do your thing, add a query range
}
The MultiSelectionHelper class may be of use here, as it does the thing:
public void init()
{
MultiSelectionHelper ms;
super();
if (element.args() && element.args().caller() && element.args().record())
{
this.query().dataSourceTable(tableNum(SalesLine)).clearDynalinks();
ms = MultiSelectionHelper::createFromCaller(element.args().caller());
ms.createQueryRanges(this.query().dataSourceTable(tablenum(SalesLine)), fieldstr(SalesLine, InventTransId));
}
}

Xcode>Instruments>Automation>Mac: is there a way to use regular expression within Automation in Instruments

I am totally new to Instruments>Automation. Trying to test the internal app using Automation in Instruments.
Here is my problem:
Our app has the UI cells generated on the fly. There is no way to predict how many cells will be created and what name they will have. But, all of them will contain a certain string (like "Courses"). The question is - How, using Automation, find out if particular cell contain that string in its name?
You are able to get total cells count simply using "length" property.
var cellsCount = <YourUIATableViewObject>.cells().length;
UIALogger.logMessage("total cells count = " + cellCount);
After that you will be able to get cell properties and operate with them:
for (var i = 0; i < cellsCount; i ++)
{
var cellValue = <YourUIATableViewObject>.cells()[i].value();
var cellName = <YourUIATableViewObject>.cells()[i].name();
UIALogger.logMessage("Cell #"+i+" properties: cellValue ="+cellValue+"; cellName ="+cellName);
//Try to use match() or search() functions to find what you need.
if ( cellName.search("Courses") != -1 )
//if (cellValue.search("Courses") != -1 )
{
UIAlogger.logMessage("Cell #"+i+" contains 'Courses'");
}
else
{
UIAlogger.logMessage("Cell #"+i+" does not contain 'Courses'");
}
}
This JavaScript tutorial will help you:

How to compare two data rows in one data set in BIRT

I'm new to BIRT and need an answer to the following question:
How to compare two data rows in one data set in BIRT and then print it out to the document?
I am assuming you have a reason for not using a self-join query to bring in the data. One simple thing you could do is have 2 identical datasets and then create a new joint dataset using the 2.
With an Oracle DB, you could easily achieve this with pure SQL using the "Analytic Function" LAG (see the Oracle documentation for details).
Independent from the DB, with BIRT, you could use a variable last_row:
Create some computed columns to keep the results of your comparisons. e.g. "FIRST_COLUMN_CHANGED" as boolean.
afterOpen event:
last_row = null;
onFetch event (pls note I'm not sure wether the actual data columns start at 0 or 1):
if (last_row != null) {
if (last_row[0] == row[0]) {
row["FIRST_COLUMN_CHANGED"] = false;
} else {
row["FIRST_COLUMN_CHANGED"] = true;
}
} else {
// do computations for the first record.
row["FIRST_COLUMN_CHANGED"] = true;
}
// Copy the current row to last_row
last_row = {};
// modify depending on the number of columns
for (var i=0; i<10; i++) {
last_row[i] = row[i];
}