Vaadin InvientCharts formatterJsFunc - charts

I'm using a vaadin add-on for displaying some charts and I have such method available :
setFormatterJsFunc and I'm not sure what kind of variables would be available to it .
Has anyone encountered this ?
Thank you

It's input is a javascript function, that when you hover on a point in the chart, it shows the value at there.
For example;
tooltip.setFormatterJsFunc("function() {"
+ " return '' + this.series.name +': '+ this.y +''; " + "}");

Related

Building a dynamic WHERE filer in PySpark (DataBricks)

So I'm trying to dynamically load a set of SQL Server tables from info in DataBricks (the company's lakehouse for info) using Python / PySpark. I'm trying to make it as dynamic / data-driven as possible, so I'm trying to build out a dynamic WHERE to filter a dataframe with. Because each pull from the lakehouse will have a different date column to filter by, I need to be able to use both variables for the column to filter on, as well as variables for the dates in question.
I'm trying to do something like this:
where_condition = "((" + check_column + " > '" + start_date_str + "') & (" + check_column + " < '" + end_date_str + "'))"
filtered_df = df.where(where_condition)
But I get back the following error:
AnalysisException: cannot resolve '((`l0_createTime_` > CAST('2022-11-01' AS TIMESTAMP)) & (`l0_createTime_` < CAST('2022-11-02' AS TIMESTAMP)))' due to data type mismatch: '((`l0_createTime_` > CAST('2022-11-01' AS TIMESTAMP)) & (`l0_createTime_` < CAST('2022-11-02' AS TIMESTAMP)))' requires integral type, not boolean; line 1 pos 1;
I feel like I'm missing something (obviously)... I've tried multiple ways of building the where statement, but it's not seeing it as such.
Any suggestions on how to build something dynamic like this, containing both dynamic columns from the dataframe, as well as dynamic values to compare to those dynamic columns?
The & operator, in Spark SQL, is for bitwise AND and requires integral operands, as the error says.
What you want to use here is the logical AND operator, that is AND:
where_condition = "((" + check_column + " > '" + start_date_str + "') AND (" + check_column + " < '" + end_date_str + "'))"
A cleaner way to build your dynamic condition is to use PySpark API:
from pyspark.sql import functions as F
where_condition = (F.col(check_column) > start_date_str) & (F.col(check_column) < end_date_str)
filtered_df = df.where(where_condition)
in this case the & operator is used, which is an overloaded operator in the PySpark Column class.

Convert mmddyy to YYYY-MM-DD in expression task in SSIS

I'm trying to use the below code to convert data from
'010118' to '2018-01-01'
(DT_DATE)(RIGHT(DATE,2) + LEFT(DATE,2) + SUBSTRING(DATE,3,2))
When I run this in SSIS i'm getting conversion error
An error occurred while attempting to perform a type cast.
Any help is much appreciated. Thanks
Found a solution for this using the below code
"20" + RIGHT(DATE,2) + "-" + LEFT(DATE,2) + "-" + SUBSTRING(DATE,3,2)

How to dynamically change line spacing using IReport?

I'm trying to change the line spacing dynamically using styled markup with variable in IReport.
This is how I attempt to do it, inside of my textfield
"<style lineSpacingSize='" + $V{linespace} + "'>" + $P{long_paragraph} + "</style>"
but it seems it doesn't have lineSpacingSize attributes, Is there any other way to do it?

Scala new line without regex?

I am trying to insert a new line into a string in scala. I've been reading around and it seems to not be as straight forward as java or C++.
my problem is i have a class called usedCar and Im overriding the toString method which is a 1 liner.
override def toString = ("Make: " + _carMake + "\nYear of Car: " + _yearOfCar + "\nVin Number: " + _vinNumber + "\nOdometer Mileage: " + _odometerMileage + "\nCondition of Car: " + _carCondition + "\nBest Price: " + _bestPrice + "\nAsking Price: " + askingPrice);
if someone can tell me how to get new lines in that toString method I would greatly appreciate it.
The escape code in Java for a new line is \n.
In your original question before the edit you have /n which wasn't correct.
The idiomatic way to do this is to assign sys.props("line.separator") to a variable and append that instead.
A more modern idiomatic way to do this would be to use String.format() and build your String that way and supply the sys.props("line.separator") as well.
You're using the wrong kind of slash. You want a backslash (\n) not a forward slash (/n). The question has since been edited.
And if you are on Windows, you really want \r\n instead. There are better ways of deciding which one to use, as Jarrod mentions in his answer.

Crystal Reports formula: IsNull + Iif

There are hints of the answer to this question here and there on this site, but I'm asking a slightly different question.
Where does Crystal Reports document that this syntax does not work?
Trim({PatientProfile.First}) + " "
+ Trim(Iif(
IsNull({PatientProfile.Middle})
, Trim({PatientProfile.Middle}) + " "
, " "
)
)
+ Trim({PatientProfile.Last})
I know the solution is
If IsNull({PatientProfile.Middle}) Then
Trim({PatientProfile.First})
+ " " + Trim({PatientProfile.Last})
Else
Trim({PatientProfile.First})
+ " " + Trim({PatientProfile.Middle})
+ " " + Trim({PatientProfile.Last})
but how are we supposed to figure out we can't use the first version?
The documentation for IsNull says
Evaluates the field specified in the current record and returns TRUE if the field contains a null value
and Iif gives
[Returns] truePart if expression is True and falsePart if expression is False. The type of the returned value is the same as the type of truePart and falsePart.
I suppose if you stare at that line about "type of the return value" you can get it, but...
Where does Crystal Reports document that this syntax does not work?
I doubt there is anyplace large enough in the entire universe to document everything that does not work in Crystal Reports...
I know I'm years late on this one, but I came upon this question while trying to figure out the same thing. Funny enough, I couldn't even find the answer in Crystal Reports documentation, but instead in a link to IBM.
Baiscally, if you're using Crystal Reports 8.x or 10.x, ISNULL and IIF don't work together. From the site:
Cause
There is a defect in Crystal Reports 8.x and 10.x that prevents the above formula from working correctly. The 'IIF' and 'IsNull' commands cannot function together, and that includes attempting to use "Not" to modify the IsNull command; for example, IIF(Not IsNull ()).
Resolving the problem
The workaround is to use an "If-Then-Else" statement. For example,
If IsNull({~CRPT_TMP0001_ttx.install_date}) Then "TBD" Else "In Progress"
So if you're using CR 8.x or 10.x (which we are), you're out of luck. It makes it REAL fun when you are concatenating multiple fields together and one of them might be NULL.
I think CR evaluates both IIFs true and false parts. Because you have "Trim({PatientProfile.Middle})" part there, which will be evaluated aganst null value, CR formula evaluator seems just fail.
try this:
currencyvar tt;
currencyvar dect;
tt :={ship.comm_amount};
dect := tt - Truncate(tt);
tt := truncate(tt);
dect := dect * 100;
if dect = 0 then
UPPERCASE('$ ' + ToWords (tt,0 )) + ' ONLY'
else
UPPERCASE('$ ' + ToWords (tt,0) + ' And ' + ToWords(dect,0)) + ' ONLY ';