How to add 2 lines of label on X axis on Fusion Chart? - fusioncharts

The purpose is to have 2 lines of text on the X axis for each bar.
e.g
JUN
2018
and style each line in a different way ( like color the year label in green ) .
Can we do it?
This is how I populate the bars in a custom way.
str += '<set label="' + months[i].toUpperCase() + ' ' + currentyear + '" value="' + amount + '" color="08cf77" toolText="' + cur_symbol + amount + '" />\n';

Simply use
'
'
So the line should be updated as;
str += '<set label="' + months[i].toUpperCase() + '
' + currentyear + '" value="' + amount + '" color="08cf77" toolText="' + cur_symbol + amount + '" />\n';

Related

HTML String on Object Property Won't Update

I have an object constructor that sets some properties, and later uses them to concatenate a string to write to the DOM. I can see that this works in some cases, but not in others.
function Fighter(name, level, attackPts, defencePts, imgSource) {
// TRUNCATED PROPERTY ASSIGNMENTS AREA:
this.attackPts = attackPts;
this.defencePts = defencePts;
// DOM ELEMENT CONSTRUCTORS:
this.img = "style='background: #444 url(" + imgSource + ") no-repeat center'";
this.char_card_name = "<h3>" + this.name + "</h3>";
this.char_card_hitdef = "<h4>" + this.attackPts + "/" + this.defencePts + "</h4>";
this.char_card = "<div class='fighter " + faction + "' " + "id='" + this.name + "'>" + this.img + this.char_card_name + this.char_card_hitdef + "</div>";
In a game function later on I modify the attack and defense points for this "Fighter" object, and that works as expected, and my console.log() tests verify that the concatenated properties also update . . . . up until the final string to pull it all together and display:
this.char_card = "<div class='fighter " + faction + "' " + "id='" + this.name + "'>" + this.img + this.char_card_name + this.char_card_hitdef + "</div>";
When I log this property, those attack and defense numbers don't budge, even though they update successfully in the previous property, this.char_card_hitdef
What could I be overlooking here? I crawled all over the web looking for scope or variable reference issues, but my log statements bring me right back to this one pinching point.
Because you are still in the constructor, you need to refer to the variables without this. that are a parameter AND property of the Object Fighter.
So change
this.char_card = "<div class='fighter " + faction + "' " + "id='" + this.name + "'>" + this.img + this.char_card_name + this.char_card_hitdef + "</div>";
to
this.char_card = "<div class='fighter " + faction + "' " + "id='" + name + "'>" + this.img + this.char_card_name + this.char_card_hitdef + "</div>"
And all other properties that refer to properties above them.
You can read more about constructors here

Cordova geolocation timestamp

Timestamp(location.getTime()) returned by this plugin is same as mobile device and not of GPS server. I have tested the same on Android 5 version. Please advise.
Given below is the code.
navigator.geolocation.getCurrentPosition(onSuccess, onError);
var onSuccess = function(position) {
$scope.currentPosition.lat = position.coords.latitude;
$scope.currentPosition.lon = position.coords.longitude;
$scope.currentPosition.timestamp = position.timestamp;
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n' +
'Date time: ' + new Date(position.timestamp) + '\n');
};
I need to store this position.timestamp for some purpose but it is giving mobile time and not of GPS server. User can manipulate this time which will defeat the application purpose. Let me know if any more info is required.

Trying to use Mustasche in Tinymce preview

As the title suggests I am trying to get Mustasche templates to work in the Tinymce preview but it does not work.
In Tinymce Plugins/Preview/plugin.js
previewHtml = (
'<!DOCTYPE html>' +
'<html>' +
'<head>' +
'<script type="text/javascript" src="~/Scripts/mustache.js"></script>' +
headHtml +
'</head>' +
'<body id="' + bodyId + '" class="mce-content-body ' + bodyClass + '"' + dirAttr + '>' +
editor.getContent() +
'</body>' +
'</html>'
);
Stuff to preview:
var obj1 = { user: "John", age: 22, country: "United States" };
{{obj1.user}}
It is fixed now and this is how it's done:
In Tinymce Plugins/Preview/plugin.js
var json = $.parseJSON($('#yourtextarea').val());
previewHtml = (
'<!DOCTYPE html>' +
'<html>' +
'<head>' +
headHtml +
'</head>' +
'<body id="' + bodyId + '" class="mce-content-body ' +
bodyClass + '"' + dirAttr + '>' +
Mustache.to_html(editor.getContent(),json)
+
'</body>' +
'</html>'
);

Using FTSearch with date fields

I have code that will search particular fields in the document to find the values that the user selects and places those documents in a folder. I have the code working, but I'm stuck on how to proceed with doing the same thing with date fields. I need to be able to find documents within a date range. Can anyone help me with how to go about doing this? Here is the code that I have:
Sub Initialize
On Error GoTo ErrHandler
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim RemoveView As NotesView
Dim RemoveDoc As NotesDocument
Dim RemoveEntry As NotesViewEntryCollection
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim view As NotesView
Dim j As Integer
Dim DialogDoc As NotesDocument
Set db = session.CurrentDatabase
Folder$ = "(UseOfForceSearch)"
'Clear folder before inputting current search results.
Set RemoveView = db.GetView(Folder$)
Set RemoveDoc = RemoveView.GetFirstDocument
If Not (RemoveDoc Is Nothing) Then
Set RemoveEntry = RemoveView.AllEntries
Call RemoveEntry.RemoveAllFromFolder(Folder$)
End If
If Not (db.IsFTIndexed) Then
answer = MessageBox(" Sorry. This database is not full-text indexed." + "Do you want to create an index?", MB_YESNO)
If (answer = IDYES) Then
Call db.UpdateFTIndex(True)
End If
End If
Set DialogDoc = db.Createdocument
searchForm$ = "$Force"
Form$ = "ReportDialog" 'Ask user for specifics of search using ReportDialog
Title$ = "Use of Force Search Criteria"
DialogDoc.Form = Form$
DialogDoc.StartDate = DialogDoc.StartDate(0)
DialogDoc.EndDate = DialogDoc.EndDate(0)
DialogDoc.Field1 = DialogDoc.Field1(0)
DialogDoc.Value1 = DialogDoc.Value1(0)
DialogDoc.Field2 = DialogDoc.Field2(0)
DialogDoc.Value2 = DialogDoc.Value2(0)
DialogDoc.Field3 = DialogDoc.Field3(0)
DialogDoc.Value3 = DialogDoc.Value3(0)
DialogDoc.Field4 = DialogDoc.Field4(0)
DialogDoc.Value4 = DialogDoc.Value4(0)
DialogDoc.Field5 = DialogDoc.Field5(0)
DialogDoc.Value5 = DialogDoc.Value5(0)
DialogDoc.Logic1 = DialogDoc.Logic1(0)
EnterDialog:
If (ws.DialogBox(Form$, True, True, False, True, False, False, Title$,DialogDoc,True)) Then
Else
Exit Sub
End If
SDate$ = CStr(DialogDoc.StartDate(0))
EDate$ = CStr(DialogDoc.EndDate(0))
Field1$ = UCase(CStr(DialogDoc.Field1(0)))
Field2$ = UCase(CStr(DialogDoc.Field2(0)))
Field3$ = UCase(CStr(DialogDoc.Field3(0)))
Field4$ = UCase(CStr(DialogDoc.Field4(0)))
Field5$ = UCase(CStr(DialogDoc.Field5(0)))
Oper$ = "contains"
Value1$ = UCase(CStr(DialogDoc.Value1(0)))
Value2$ = UCase(CStr(DialogDoc.Value2(0)))
Value3$ = UCase(CStr(DialogDoc.Value3(0)))
Value4$ = UCase(CStr(DialogDoc.Value4(0)))
Value5$ = UCase(CStr(DialogDoc.Value5(0)))
Logic1$ = UCase(CStr(DialogDoc.Logic1(0)))
Logic2$ = UCase(CStr(DialogDoc.Logic2(0)))
Logic3$ = UCase(CStr(DialogDoc.Logic3(0)))
Logic4$ = UCase(CStr(DialogDoc.Logic4(0)))
Set Date1 = New NotesDateTime(SDate$)
Set Date2 = New NotesDateTime(EDate$)
Date1ForReport$ = Date1.DateOnly
Date2ForReport$ = Date2.DateOnly
datemax = Date2.timedifference(Date1)
DaysBetween = datemax \ 86400
If(DaysBetween > (366 * 1)) Then
MessageBox "Date range cannot exceed 1 year.",48,"Error:"
GoTo EnterDialog
End If
For i = 1 To 1
searchForm$ = "(FIELD Form contains $Force) and "
Expr1$ = "FIELD " + Field1$ + " " + Oper$ + " " + Value1$
Expr2$ = "FIELD " + Field2$ + " " + Oper$ + " " + Value2$
Expr3$ = "FIELD " + Field3$ + " " + Oper$ + " " + Value3$
Expr4$ = "FIELD " + Field4$ + " " + Oper$ + " " + Value4$
Expr5$ = "FIELD " + Field5$ + " " + Oper$ + " " + Value5$
FinalExpr$ = searchForm$ + Expr1$
If(Logic1$ <> "") Then
FinalExpr$ = FinalExpr$ + " " + Logic1$ + " " + Expr2$
ElseIf (Logic2$ <> "") Then
FinalExpr$ = FinalExpr$ + " " + Logic1$ + " " + Expr2$ + " " + Logic2$ + " " + Expr3$
ElseIf (Logic3$ <> "") Then
FinalExpr$ = FinalExpr$ + " " + Logic1$ + " " + Expr2$ + " " + Logic2$ + " " + Expr3$ + " " + Logic3$ + " " + Expr4$
ElseIf (Logic4$ <> "") Then
FinalExpr$ = FinalExpr$ + " " + Logic1$ + " " + Expr2$ + " " + Logic2$ + " " + Expr3$ + " " + Logic3$ + " " + Expr4$ + " " + Logic4$ + " " + Expr5$
End If
FinalExpr$ = FinalExpr$
Print "Searching..."
' the number 16384 means fuzzy search
Set dc = db.FTSearch(FinalExpr$,0,,16384)
Folder$ = "(UseOfForceSearch)"
Call dc.PutAllInFolder(Folder$,True)
Next
Print "Search Completed with " + CStr(dc.Count) + " results."
Set view = db.getView(Folder$)
Exit Sub
ErrHandler:
MessageBox "Error" & Str(Err) & ": " & Error$,16,"Error!"
Exit Sub
End Sub
You can use operators = / < / > / <= / >= for date fields in FTSearch.
Example: FIELD YourDateField > 01/30/2013 or [YourDateField] > 01/30/2013.
To find documents within a date range you'd write:
[YourDateField] >= 01/01/2013 AND [YourDateField] <= 12/31/2013
Look here for a complete list of search options.

libpq, insert with parameters

I am wondering if I can make parameterized queries directly from C/C++ with libpq instead of using strings and if do how should this code look's like?
string tblins = "";
tblins = "INSERT INTO " + commtable + " "
"(vdoc, bdoc, mytime, txml) VALUES ("
"'" + cxml.vdoc + "', "
+ cxml.bdoc + ", " //integer
"'" + cxml.mytime + "', "
"'" + cxml.txml + "')";
result = PQexec(conn, tblins.c_str());
Thanks.
Yes, you can use the PQexecParams function as explained in the documentation.
If parameters are used, they are referred to in the command string as $1, $2, etc. nParams is the number of parameters supplied; it is the length of the arrays paramTypes[], paramValues[], paramLengths[], and paramFormats[].