Jasper Reports - HTML5 Reports(highcharts) - String Replace for Labels - javascript

Hoping someone can help. Trying to do a string replace on the labels for my bar chart. So this is built on jasper studio and is a html5 report.
Trying to add the replace function as a javascript function in the report "Advanced Properties". Previously I have successfully set a function here for xAxis.labels.formatter to append labels,
"function(){return this.value.toString().substring(0,5)}"
I have tried to update this for string replace and came up with the below:
"function(){return this.value.toString().str.replace("Section7","W3Schools")}"
This is not working.I dont have much javascript experience and I have tried different formats of the above but no luck so far, any suggestions would be much appreciated?

Got it working. The replace function, works with the below:
Set property name as:
xAxis.labels.formatter
Use as expression:
true
3.Property Value:
"function(){return this.value.replace(\"Section 7\",\"W3Schools\")}"
Or
<hc:chartProperty name="xAxis.labels.formatter">
<hc:propertyExpression><![CDATA["function(){return this.value.replace(\"Section 7\",\"W3Schools\")}"]]></hc:propertyExpression>
</hc:chartProperty>

Related

How do I use toCSS() in paper.js?

Paper.js says it has a function toCSS(hex) which returns the color as a CSS string, either in hex or not.
http://paperjs.org/reference/color/#tocss-hex
Does anyone know how to use this I have had no luck and can find no examples.
I am trying to convert a var Color which =hit.item.fillcolor which appears to be a ctor.
If I try to use toCSS I get Color.toCSS is not a function.
The function above toCSS in the documentation - toString() works fine.
Any clues?
I'm not exactly sure what you're asking but here is an issue.
The fill color is item.fillColor, not item.fillcolor, which is undefined.
That's why you get Color.toCSS() is not a function.
toCSS(false) returns this format: "rgb(0,230,191)"
toCSS(true) returns this format: "#00e6bf"

ajaxToolkit PopupControlExtender not working. Outdated?

I'm followed this tutorial but I'm getting runtime error when mouseover:
Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter
name: type
The problem is in this lines of code:
string OnMouseOverScript = string.Format("$find('{0}').showPopup();", behaviorID);
string OnMouseOutScript = string.Format("$find('{0}').hidePopup();", behaviorID);
img.Attributes.Add("onmouseover", OnMouseOverScript);
img.Attributes.Add("onmouseout", OnMouseOutScript);
Any thoughts on this? My goal is to get details of gridview row when mouseover a specific column, like the demo on the referenced linked.
Solved by updating AJAX Control Toolkit to it's last version (v15.1 from March 2015)!

data dump from nseindia to excel

I need to dump the data from nseindia to the excel.please find the preview of nseindia in below link. From the webpage i need the OPEN HIGH LOW CLOSE and TotalBuyQty, TotalSellQty values in the excel sheet, can anyone help me on the same. I tried normal webpage dump but it is not working.
"http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=WIPRO&instrument=FUTSTK&expiry=30OCT2014&type=-&strike=-"
Just use Excel to sort.
Thisis what happened when I recorded a sort in Excel.
Range("A1:A18").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Here's a good guide to using the sort function without recording--you can trim it down if you're not using special methods.
sheet("Sheet1").range("Range1").sort key1:=Range("A2"), _
order1:=xlAscending, Header:=xlYes
http://msdn.microsoft.com/en-us/library/office/ff840646(v=office.15).aspx
If you're doing other manipulations to the field after that, you might want to use the AutoFilter as well. Here's a helpful site for that if you're interested:
http://www.ozgrid.com/VBA/autofilter-vba.htm

Passing Javascript Object to Function & changing text field

This is probably a stupid mistake that i have made; i am still new to web development so be nice please :)
Here i create the object
var crs0 = {ID:1, TITLE:"test", DESC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",ER:"a",LENGTH:"a", FEE:"a"};
Here i use an onclick event to call a function & pass the object as a parameter
<div class = "btnDC" onclick="display(crs0)">test</div>
Here is the function that i use to replace data in some textarea's & text inputs with properties from the object.
function display(crs)
{
document.getElementById("ttl").value=crs.TITLE;
document.getElementById("dsc").value=crs.DESC;
document.getElementById("er").value=crs.ER;
document.getElementById("lng").value=crs.LENGTH;
document.getElementById("fees").value=crs.FEE;
document.getElementById("ID").value=crs.ID;
}
The onclick does nothing & i have no idea why. (Other javascript on the page does work so i haven't missed a semi-colon :D )
[Update 1]
All of the data is pulled from a database the code above is copied from the page it produces; i have done a few tweaks & i can get it to produce an alert box for the display function however if i try & make it show any data of the object within that alert box it doesn't display anything (i hate not having a debugger), which suggests that the object isn't being passed.
Here is the PHP code i use to create the onclick
echo '<div class = "btnDC" onclick="display(crs'.$n.')">'.$inf['TITLE'][$n].'</div>
Could that be the issue?
it produces this line of code
<div class = "btnDC" onclick="display(crs0)">test</div>
As mentioned the code i have shown works (thanks juvian);
I generated this code from php & although the javascript generated was correct there was a problem with some of the php, i didn't find the exact problem but i have re-written most of the php & now it works.
As mentioned the code i have shown works (thanks juvian); I generated this code from php & although the javascript generated was correct there was a problem with some of the php, i didn't find the exact problem but i have re-written most of the php & now it works.

Extract data from url with JavaScript

EDIT_2: I forgot to specify its for Android app, so i dont think this is any use, i made a new post instead :( Added Android TAG..
EDIT: Im making an Android App
I need help to extract a number from an url, generated by JavaScript!
Site is:
http://www.oddsportal.com/sure-bets/
And the path looks like this:
<span class="logos l60"> </span>
<div class="odds-nowrp" xodd="xzoxfxzox">2.62</div> // <- 2.62 is the numer i need
For full path see this screenshot:
What library would do this best? (I know Jsoup cant do it) I have searched a few like:
HtmlUnit
Java Script Engine
Apache Commons BSF
Rhino
But i cant really make sense of it or find any examples for android which look like my problem
or find any examples for android which look like my problem
You need it for android?
Pretty much any library allowing DOM traversing will allow you to do this providing you know how to find your value.
is this value exactly at the same position in DOM every time?
is it wrapped by an easy to identify element? i.e. with a static ID
are there any other value that look alike in the DOM that you don't want?
Based on that, using JQuery for example, you could select it like this :
$('.table-main td.center > a[href^="/bookmaker"] + div[xodd]')
or this:
$('.table-main tr:nth-child(3) div.odds-nowrp[xodd]')
Use Jquery:
var number = $(".odds-nowrp").text();
you can just use regex if you have the url already in escaped string format
reg = /[A-z\"\>\<=?()0-9 \/]*(\d+.\d+)[A-z\"\>\<=?()0-9 \/]*/
reg.exec(url)[1] // this will return your number
if it's already rendered and the xodd value doesn't change, you could do something like this
document.querySelectorAll('.odds-nowrp[xodd=xzoxfxzox]')[0].innerText

Categories