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<%}%>)"
Related
I have a Query function in Sheet2 which is based on a dropdown selection in cell I11 of Sheet1. In the Sheet2 Query, I want to automatically highlight the name selected in the Sheet1 dropdown. Per my example below, if 'New Zealand' is selected in the dropdown I want New Zealand to be highlighted like this:
I have tried MATCH, EXACT, INDIRECT and combinations of these but cannot get any to work. I would really appreciate some help.
on range A2:F use this custom formula:
=COUNTIF(A2, INDIRECT("Sheet1!I11"))
or:
=REGEXMATCH(LOWER(A2), LOWER(INDIRECT("Sheet1!I11")))
Is it possible to make a bar chart a double y-axis?
I have a bar chart with 4 bars, generated by the query, returning 4 rows.
Is there a way for me to make each bar a different color and on the right-hand side, instead of series name, specify colors along with labels for each bar?
Click on one of the chart series and look for the 'Assign to Y-Axis' attribute
Not how this is next to a 'Color' attribute. You can source this colour from your SQL, substituting your value using the using &COLUMN_ALIAS. syntax.
An example from the sample charts application in the linked form post shows how colour can be row based (with column alias adjusted to match my screenshot)
select a.product_name,
b.quantity,
b.customer,
-- This is the column you're looking for
case when b.quantity > 50 then 'gold'
when b.quantity <= 30 then 'red'
when b.quantity > 30 then 'green'
else 'blue'
end as colour
from eba_demo_chart_products a, eba_demo_chart_orders b
where a.product_id = b.product_id
and customer = 'Store A'
I have a interactive grid, made from a full join on the title from the table wwv_flow_qb_saved_query and apex_collection. The result looks like this:
The first three columns are the queries built with the query builder from the wwv_flow_qb_saved_query. The last three columns are from an uploaded query to the apex_collections. The column "qb_sql" is a clob filled with the whole sql statement from the query, which looks in the single row view like this:
Now the end user should be able to see the differences in the column group "imported queries" => "qb_sql" with different colors. So that the part, that is different in the second qb_sql is for example red.
Is there any possibility to achieve this?
Thanks..
In grid view you can give all the cells in a column a special class using the declarative attribute Appearance: CSS Classes. But this does not apply to single row view.
The attribute Advanced: CSS Classes applies just to the editable field. Which is the same in both grid and single row view.
There is an advanced column option property, fieldCssClasses, that applies to the field in single row view. So for each of the fields/columns you want to look different add this to the Advanced: JavaScript Code attribute:
function(config) {
config.defaultGridColumnOptions = {
fieldCssClasses: "special"
}
return config;
}
Then add a CSS rule for .special to the page attribute CSS: Inline or add the rule to your application css file if you have one. For example:
.special {
font-weight: bold;
color: green;
}
Use whatever name you like for the css class; "special" is just an example.
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
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.