How put dataset labels into multiTooltipTemplate? - chart.js

There is a color of current dataset element, but how can I put current dataset label into tooltip, exchange for label from xAxis?

In your options set multiTooltipTemplate to "<%=datasetLabel%> : <%= value %>" to do this.
From this Github issue : https://github.com/nnnick/Chart.js/issues/535

Related

change row background color based on column value in classic report in oracle apex

Is there a way to programmatically set the background color of a row based on data on column (exp . mgr =100 the row color
green other that blue ....ex ). Is there a method (javascript?) by which this can be achieved? Regards
You can do this with a combination of page inline CSS and "execute when page loads" Javascript like this:
Page inline CSS
#myreport td {background-color: #aaccff}
"Execute when page loads" Javascript
$('#myreport td[headers="MGR"]').filter(function(){
return $(this).text() === '100'
}).parent().children().css('background-color', '#aaffaa');
Here myreport is the static ID you assigned to the report region.
Another way without Javascript would be to build a bespoke report template with conditional column templates where one has the PL/SQL condition:
'#MGR#' = '100'

How to only display 'Edit' link on certain rows on apex interactive grid?

I have an interactive report apex5.0 which contains several fields.
Would like to disable 'edit' pencil option link where payment_date & code is populated.
Link is to be enabled only where payment_date & code is null.
Disable the edit button for a particular row, based on a specific value in its column.
For ex. If a grid has 3 columns A,B,C and if B contains "Apple", and '01-jan-17', the edit button for that row must be disabled.
What are the different options to do this kind of functionality in apex5.0, enable & disable "EDIT" based on certain criteria?
You could also add a case statement to your report's query.
E.g.
(Case when [some logic] then
--display link
'<img src="#IMAGE_PREFIX#menu/pencil16x16.gif" alt="" />'
End) as col_link
The above example will only display a link if the case statement is met. The link will point to page 47 and we will pass the query's Id column to page 47's item P47_ID
In order to treat this new column as a link you must change the "display as text" property to "standard report column"; you can achieve this when editing the report attributes.
One way is to use JavaScript on page load:
Let's asume that first column is with ID and used to show edit link. Second column is your product name like Apple. Just disable click on this element(cell with ID) or change link, img etc.
var table = $(".a-IRR-table tbody");
table.find('tr').each(function (i, el) {
var $tds = $(this).find('td'),
productId = $tds.eq(0).text(), //first column with ID and edit link
product = $tds.eq(1).text(), //second column
Quantity = $tds.eq(2).text(); //third column
if (product == 'Apple'){
$tds.eq(0).click(false);
$tds.eq(0).replaceWith('');
}
});
Thanks to this answer for JavaScript: Loop Through Each HTML Table Column and Get the Data using jQuery
EDIT:
To hide value based on your Query use CASE. For example:
SELECT
CASE
WHEN B = 'Apple' THEN
'<img src="#IMAGE_PREFIX#edit.gif" alt="">'
ELSE ''
END edit_link,
A,B,C
FROM TABLE_NAME
Click on column edit_link and make it of type Link
Choose your target to edit page
For link text select #EDIT_LINK#
Escape special characters must be set to NO
On Report Atributes set **Link Column** to **Exclude Link Column** (you have custom link column so don't display original link)
*Check your online workspace, page 3*

How to show icon if no row returned

How to conditional display a particular icon (for example 'ADD data') only when i have null in column.
You could do this:
case when name is not null
then name
else '<img src="myicon.png"/>'
end as name
You would need to change the column's Display As property to "Standard Report Column" so that this HTML is not escaped by APEX.
If you meant this icon to be a link you can do that the same way:
case when name is not null
then name
else '<img src="myicon.png"/>'
end as name
If you want to show the same icon for every empty cell in any column, you can just add appropriate html-code to attributes settings of your report:
Your_Report → Attributes → Show Null Values as → <img src="image.png">

How to display two values of two tables on chartkick (ruby on rails)

I have column vote_option belong to Vote table and title in VoteOption table
and now I want to show vote_option and title in pair in a pie chart(chartkick). So what exactly should I do? I mean what should I do with this code: <%= pie_chart Goal.group(:name).count %> to show vote_option and title like value and key of a hash?
Have you tried creating a table that references the data in the two tables?
For example you could combine the columns (reference by ID) from the two tables into a model table called Vote_title.
Then in your ruby code you could do something like the following:
In your controller (assuming this is on your index page):
def index
#vote_titles = Vote_title.all
end
On your index page:
<%= pie_chart #vote_titles.group(:title).sum('vote_option') %>
In that example, the pie chart would display each title as a slice/percentage of 'vote_option' relative to the other title's vote_options. The legend on the side would list all titles and their colors. Reverse title, and vote_option in the erb code on your index page if you want the opposite.

How to set plural label values in chart.js

I have chart.js (chartjs) all set up on my site and working wonderfully!
For my labels I declared:
tooltipTemplate: "<%if (label){%><%=label%> <%}%>(<%= value %> votes)",
But I would like that when there is just one vote it sets a label of 'vote' instead of 'votes', is this possible?
Sure, just use another if statement, for example:
tooltipTemplate: "<%if(label){%><%=label%> <%}%>(<%=value%>
<%if(value != 1){%>votes<%}else{%>vote<%}%>)"