I am having a highcharts chart, which is using a HTML-tooltip. That tooltip shows -of course- the values which are available on the x-axis.
chart: {
tooltip: {
shared: true,
useHTML: true,
formatter: function () {
var html = '<table>';
_.forEach(this.points, function (point) {
html += '<tr>' +
'<td style="color: ' + point.series.color + '">' + point.series.name + ': </td>' +
'<td style="text-align: right; font-weight: bold">' + $currency(point.y, point.point.symbol, 2) + '</td>' +
'</tr><tr>' +
'<td colspan="3" style="text-align: right">' + point.point.articelno + '</td>' +
'</tr>';
});
html += '</table>';
return html;
},
style: {
padding: 10
}
}
}
The problem is, that the series can have one-or-more points on the same x-line, which I want to display in the same tooltip, but I find no way to do so.
Any ideas for me?
Related
I am getting table data from ajax response as json.Some json datas am not displaying but I want it on a button click for other purpose.How can I get it?Please help me.
function leaveTable() {
for (var i = 0; i < leaveList.length; i++) {
var tab = '<tr id="' + i + '"><td>' + (i + 1) + '</td><td class="appliedOn">' + leaveList[i].appliedOn + '</td><td class="levType" >' + leaveList[i].levType + '</td><td class="leaveOn" >' + leaveList[i].leaveOn + '</td><td class="duration">' + leaveList[i].duration + '</td><td class="status">' + leaveList[i].status + '</td><td class="approvedOn">' + leaveList[i].approvedOn + '</td><td class="approvedBy">' + leaveList[i].approvedBy + '</td><td><i class="btn dltLev fa fa-times" onclick="cancelLeave(this)" data-dismiss="modal" value="Cancelled"></i></td><tr>';
$('#levListTable').append(tab)
}
}
from ajax response I want leaveTypeId and pass it into sendCancelReq() function.
Complete code :https://jsfiddle.net/tytzuckz/18/
It is complicated to know exactly what you want. I hope that helps you:
The first, I would change, is not to produce the JavaScript events in your html code var tab = .... I think, it is more clear and readable, when you add your event after the creation of the new dom elements. For example:
var tab = $('<tr id="' + i + '">' +
'<td>' + (i + 1) + '</td>' +
'<td class="appliedOn">' + leaveList[i].appliedOn + '</td>' +
'<td class="levType" >' + leaveList[i].levType + '</td>' +
'<td class="leaveOn" >' + leaveList[i].leaveOn + '</td>' +
'<td class="duration">' + leaveList[i].duration + '</td>' +
'<td class="status">' + leaveList[i].status + '</td>' +
'<td class="approvedOn">' + leaveList[i].approvedOn + '</td>' +
'<td class="approvedBy">' + leaveList[i].approvedBy + '</td>' +
'<td><i class="btn dltLev fa fa-times" data-dismiss="modal" value="Cancelled"></i></td>' +
'<tr>');
$(tab).find('.btn.dltLev').click(function () { cancelLeave(this); });
Then, you are able to send your necessary information more clearly, e.g.:
Instead of the last code
$(tab).find('.btn.dltLev').click(function () { cancelLeave(this); });
you can write
$(tab).find('.btn.dltLev').click(function () { cancelLeave(this, leaveList[i].leaveTypeId); });
and extend your method cancelLeave to:
function cancelLeave(elem, leaveTypeId) {
var id = $(elem).closest('tr').attr('id')
alert(id)
$("#cancelLeave").modal("show");
$('.sendCancelReq').val(id);
sendCancelReq(leaveTypeId);
}
Got solutionPlease check this:https://jsfiddle.net/tytzuckz/19/
function cancelLeave(elem) {
var levTypeId = $(elem).attr('id')
var id = $(elem).closest('tr').attr('id')
$('.currentLevTypeId').val(levTypeId);
$("#cancelLeave").modal("show");
$('.sendCancelReq').val(id);
}
function sendCancelReq() {
var a= $('.currentLevTypeId').val();
alert(a)
}
I want a button to call a function onclick but it does not. I tried ng-click which does not work. But when I try onclick it says my function is undefined. How can I accomplish that?
Thank you.
Function to customize the tooltip:
function createCustomHTMLContent(img, evtTime, cmname, evt, cust, serv, descr, duration) {
var html ='<script type="text/javascript" src="validate.js"></script><div class="myclass" style="padding:5px 5px 5px 5px;width: 300px;height: 350px;">' +
'<img src="'+img+'" style="width:285px;height:230px">' +
'<table>'+'<tr>'+
'<td><strong>Date :</strong></td>' +
'<td><b>'+evtTime+'</b></td>' + '</tr>' + '<tr>' +
'<td><strong>Event Type :</strong></td>' +
'<td><b>'+evt+'</b></td>' + '</tr>' + '<tr>' +
'<td><strong>Customer :</strong></td>' +
'<td><b>'+cust+'</b></td>' + '</tr>' + '<tr>' +
'<td><strong>Severity :</strong></td>' +
'<td><b>'+serv+'</b></td>' + '</tr>' + '<tr>' +
'<td><strong>Description :</strong></td>' +
'<td><b>'+descr+'</b></td>' + '</tr>' + '<tr>' +
'<td><form ng-form-commit name="myForm" action="" onsubmit="testfunt()" target="dummyframe" method="post" novalidate><div class="row"><div class="text-center"><button ng-click="timeline.heyfun();">View Video</button></div></form></div></td></tr></table>';
return html;
}
function addData() {
rows.push([""+cmname, ""+id,createCustomHTMLContent(thumbpath, evtTime, cmname, evt, cust, serv, descr, 0),new Date(datetime), new Date(datetime1),'color:'+colors[serv]]);
tc.dataTable.addRows(rows);
var options = {
width : $scope.width,
height: $scope.height,
title: 'Timeline',
hAxis: {
title: 'Date',
format:'yy-MM-dd\n\nHH:mm:ss'
},
timeline: { //colorByRowLabel: true,
showBarLabels: false},
// backgroundColor: '#ffd',
colors: grapghcols,
// This line makes the entire category's tooltip active.
focusTarget: 'category',
// Use an HTML tooltip.
tooltip: { isHtml: true,}
};
tc.chart.draw(tc.dataTable, options);
$compile(tc.dataTable)($scope);
}
There is alot of code. SO i tried to include the relevant snippets needed. Please let me know if you need more details.
the masonry not working in my ajax response.i have tried some like this but it is not working for me.
my code ajax code is:
<script>
function loadmore(cnt)
{
var val = document.getElementById("result_no").value;
$.ajax({
type: 'get',
url: '{{ URL::route('oi_array3') }}',
data: {
last:val,cnt
},
success: function (response) {
var content = document.getElementById("uf");
if (response == '') {
$("#load").hide();
}
` response.forEach(function(value){
var d = new Date(value.timestamp);
var n = d.toDateString();
var s = d.toLocaleTimeString();
content.innerHTML += '<div class="grid-item oi_data_tile">' +
'<div class="small-12 text-right timestamp columns">' + n + ' ' + s + '</div>' +
'<label class="small-6 columns">Underlying Index</label>' +
'<label class="small-6 text-right nifty_index columns">' +
'<strong>' + value.underlying_index + '</strong>' +
'</label>' +
'<label class="small-6 columns">Diff. in change in OI</label>' +
'<label class="small-6 text-right nifty_index columns">' +
'<strong>' + value.diff_in_change_in_oi + '</strong></label>' +
'<div class="small-12 columns">'+
'<table class="small-12 columns">'+
'<tr class="header">' +
'<td class="small-3">Chng in OI Call</td>' +
'<td class="small-3">Strike<br>price</td>' +
'<td class="small-3">Chng in OI Put</td>' +
'<td class="small-3">Diff in Chng in OI</td>' +
'</tr>'+
'<tr>' +
'<td class="text-right">' + value.derivatives[0].change_in_oi_call + '</td>' +
'<td class="text-right">' + value.derivatives[0].strike_price + '</td>' +
'<td class="text-right">' + value.derivatives[0].change_in_oi_put + '</td>' +
'<td class="text-right bullish">' + value.derivatives[0].diff_in_change_in_oi + '</td>' +
'</tr>' +
'<tr>' +
'<td class="text-right">' + value.derivatives[1].change_in_oi_call + '</td>' +
'<td class="text-right">' + value.derivatives[1].strike_price + '</td>' +
'<td class="text-right">' + value.derivatives[1].change_in_oi_put + '</td>' +
'<td class="text-right bullish">' + value.derivatives[1].diff_in_change_in_oi + '</td>' +
'</tr>' +
'<tr>' +
'<td class="text-right">' + value.derivatives[2].change_in_oi_call + '</td>' +
'<td class="text-right">' + value.derivatives[2].strike_price + '</td>' +
'<td class="text-right">' + value.derivatives[2].change_in_oi_put + '</td>' +
'<td class="text-right bearish">' + value.derivatives[2].diff_in_change_in_oi + '</td>' +
'</tr>' +
'</table>' +
'</div>'+
'</div>'
if(document.getElementById("result_no").value == '0')
document.getElementById("latestvalue").value = value.timestamp;
document.getElementById("result_no").value = value.timestamp;
});
}//response close
});//ajax close
}//loadmore close
$('.grid').masonry({
columnWidth : 320,
gutter: 15,
percentPosition: false,
fitWidth: true,
isFitWidth: true,
itemSelector: '.grid-item'
});
$('.grid').imagesLoaded(function() {
$('.grid').masonry('layout');
});
</script>
and Html code is:
<div class="small-12 columns" id="uf1">
<div class="grid" id="uf">
<!-- ajax response is added here.-->
</div>
<input type="hidden" id="result_no" value="0">
</div>
I want to put ajax response in id, and apply masonry on response.
You need to reinitialize the masonry after the content is added to the DOM. That is the way by which masonry will be able to target the newly added element.
$('.grid').masonry();
Call this after the new content is loaded everytime.
How do i get two xml results in one column as output. Now i get for evru output an column.
pub += '<td valign="top" class="col1">' + roepnaam + '</td>' + '\n';
pub += '<td valign="top" class="col2">' + naamMedewerker + '</td>' + '\n';
Can anyone help em out. I want those together. I tried this:
pub += '<td valign="top" class="col1">' + roepnaam + + naamMedewerker + '</td>' + '\n';
But didn't work. Please help me out?
Here: Remove +
pub += '<td valign="top" class="col1">' + roepnaam + naamMedewerker + '</td>' + '\n';
I want the each request type must be displayed in different color based on CSS class name.
code:
mcmShowTaskMessageBox: function(task, menu) {
var message = '<table class="eventTipBig">';
var requestType = task.get('RequestType');
var alert = task.get('Alerts');
if(requestType === 'OA VIP') {
menu.tdCls = 'OAVIP';
} else if(requestType === 'JL VIP') {
menu.tdCls = 'JLVIP';
} else if(requestType === 'BA VIP') {
menu.tdCls = 'BAVIP';
} else if(requestType === 'IB VIP') {
menu.tdCls = 'IBVIP';
} else if(requestType === 'QF VIP') {
menu.tdCls = 'QFVIP';
}
message +=
'<tr>' +
'<td class="icon-task">Name</td>' +
'<td class="value">' + task.get('Name') + '</td>' +
'</tr>' +
'<tr>' +
'<td class="icon-task">Ranking</td>' +
'<td class="value" style="color:red;">' + PriorityGreet + '</td>' +
'</tr>' +
'<tr>' +
'<td class="icon-task">Request Type</td>' +
'<td class="value">' + requestType + '</td>' +
'</tr>' +
'<tr>' +
'<td class="icon-task">Agent</td>' +
'<td class="value">' + task.get('AgentName') + '</td>' +
'</tr>' +
'<tr>' +
'<td class="icon-task">Service Type</td>' +
'<td class="value">' + task.get('TaskType') + '</td>' +
'</tr>' +
'<tr>' +
'<td class="icon-task">Task Status</td>' +
'<td class="value">' + task.get('TaskStatus') + '</td>' +
'</tr>' +
'<tr>' +
'<td class="icon-task">Task Category</td>' +
'<td class="value">' + task.get('TaskCategory') + '</td>' +
'</tr>'+
'<tr>' +
'<td class="icon-task">Notes</td>' +
'<td class="value">' + task.get('Notes') + '</tr>' +
'</tr>' +
'</table>';
App.mcmShowMessageBox({
id: 'TaskGrid' + task.get('Id'),
title: 'Task Information',
message: message,
editOption: { task: task, menu: menu }
});
//modification ended
}