JFreeChart customize BoxAndWhiskerToolTip - tooltip

I am adding tooltip to Box and Whisker plot.
final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
String tooltipformat = "Max: {5}\nQ3: {7}\nQ1: {6}\nMin: {4}\nMean: {2}\nMedian: {3}";
renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator(tooltipformat,NumberFormat.getNumberInstance()));
I get the result below.
Instead of getting the tooltip label in a column, I got it in a row. Why does the \n is useless?

Use HTML will do.
String tooltipformat = "<html><body>Max: {5}<br>Q3: {7}<br>Median: {3}<br>Q1: {6}<br>Min: {4}<br>Mean: {2}</body></html>";
renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator(tooltipformat,NumberFormat.getNumberInstance()));

Because ChartPanel uses a ToolTipManager.sharedInstance(), you can break multi-line tooltips as suggested here and here. As another example, the following changes to BarChartDemo1, seen here, produce the results illustrated below.
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(
"<html>Series: {0}<br>Category: {1}<br>Value: {2}</html>",
NumberFormat.getInstance()));

Related

amCharts 4: display legend tooltip on truncated (with ellipsis) values only

I've enabled the legend on a amCharts v4 chart with the following code but I have issues with ellipsis:
// Add legend
chart.legend = new am4charts.Legend();
chart.legend.fontSize = 11;
// Truncate long labels (more than 160px)
chart.legend.labels.template.maxWidth = 160;
chart.legend.labels.template.truncate = true;
chart.legend.labels.template.fullWords = true;
// Set custom ellipsis as default one is not displayed correctly
chart.legend.labels.template.ellipsis = "...";
// Set tooltip content to name field
chart.legend.itemContainers.template.tooltipText = "{name}";
As you can see I had to set a custom ellipsis property because Firefox v76 displayed €| instead of … on the truncated legend labels. It happens even on the sample on the amChart website but, surprisingly, not if I open the same URL in a private tab... How can I fix that?
Then I would like to display the tooltip on the legend only for truncated labels. Adding an adapter:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
// 'text' here contains the non-truncated string
return "My modified " + text;
})
of course works, but how can I identify inside the adapter code if the label that I'm processing is truncated and clear the text variable? It doesn't make sense to display tooltips for non-truncated legend items.
Not sure the most ideal way but...
You get the text inside the adaptor callback.
You can add a text.length check like:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
// 'text' here contains the non-truncated string
return text.length > someValyeBasedOnMaxwidth> ? "My modified " + text: "";
})
I found the answer about the tooltip adapter; this works:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
if (!target.dataItem.label.isOversized) {
// Legend label is NOT truncated, disable the tooltip
return "";
}
// Legend label is truncated, display the tooltip
return text;
})
Still I don't know why the ellipsis are not displayed correctly without setting the property...

How to get gmail-create account-password field ToolTip information using web driver selenium

I am trying to get text box Tool tip (Gmail-Create Account-Password field) information but I am failing to handle this situation.
I am using Selenium WebDriver (java). Please find below code what I have used:
WebDriver wd = new FirefoxDriver();
wd.navigate().to("https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Ftab%3Dwm&hl=en");
WebElement NewButton = wd.findElement(By.xpath(".//*[#id='Passwd']"));
NewButton.click();
String Tooltip = NewButton.getText();
/*String Tooltip = NewButton.getAttribute("title"); // used this getattribute method also */
System.out.println(Tooltip);
I have used other methods also similar like this method but not working Properly & not showing any errors in console also.
Please find below methods also:
//2nd method
/*Actions ActionChains = new Actions(wd);
WebElement NewButton = wd.findElement(By.xpath(".//*[#id='Passwd']"));
ActionChains.clickAndHold(NewButton).build().perform();
System.out.println("hold");
String Tooltip = NewButton.getText();
String Tooltip = NewButton.getAttribute("title");
System.out.println("done");
System.out.println(Tooltip);*/
//3rd method
/*String tooltip=wd.findElement(By.xpath(".//*[#id='Passwd']")).getAttribute("title");
System.out.println(tooltip);
System.out.println("Done");*/
//4th method
/*WebElement ToolTip = wd.findElement(By.xpath(".//*[#id='Passwd']"));
System.out.println(ToolTip.getText());
System.out.println("Done");*/
If you want to get that tooltip which will be visible next to the Password field, you have to get that WebElement instead of the Password field. That field hasn't got title attribute, or text value. You can find the tooltip in the DOM if you search for:
<div class="jfk-bubble">...</div>
Code:
this.driver.get("copy your link here");
WebElement passwordField = this.driver.findElement(By.id("Passwd");
passwordField.click();
// Example: get the title of the tooltip
WebElement tooltipTitle = this.driver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/p/strong"));
System.out.println("The title is: " + tooltipTitle.getText());
Return:
The title is: Password strength:
This tooltip is not in the DOM at the beginning so you must set the WebElement only after click and use maybe WebDriverWait to avoid problems because of slow net connection, etc...

Highcharts custom styling connect and label

How to I custom donuts in highcharts with, each start point connect label have a circle, and style the connect line, and hidden the lower value.
I using highcharsjs
like this one
In Highcharts you can only edit softness of connector and color/length. If you want to change that, then you need to overwrite drawDataLabels function for pie series. Or update series.data[index].connector path after rendering to fit your needs.
Something like this: http://jsfiddle.net/yzob09ks/
function redrawConnectors() {
var chart = this,
d;
Highcharts.each(chart.series[0].data, function(point, i) {
if(point.connector) {
d = point.connector.d.split(' ');
d = [d[0], d[1], d[2], d[10], d[11], d[12]];
point.connector.attr({
d: d
});
}
});
}
Note: Demo just shows how to change default behavior for connectors, now just render proper shape you want to.

Remove datalabels from formatter with Highchart

I'm using the highchart library and try to display some datalabels with a dinamic format ( using the formatter mecanism).
I need to hide some of the labels, but any try to remove it let the background and the border color visible.
as seen in this JSFiddle (They are still some little yellow circles)
code :
formatter:function() {
if(this.y > 150)
return this.y;
else
return "";
}
By returning "" I set the label empty. I would like it to be entirely hidden but its not.
The question is:
Is there a way to hide some datalabels from the formatter ?
I know I could set the datalabels enabled or not for each point in the chart initialisation but I need to change it at run time dynamicaly.
Replace return "" with return null and datalables wil be correct.

In a Highchart, how to display the legend text in next row if the text is too long?

I have highchart like this.
How can I display the legend (Firefox,IE,chrome...) text in next row if the text is too long? Image describing my problem is
P.S. I am not familiar with jQuery.
Expecting a solution
You will need to make use of a labelFormatter
labelFormatter: function()
{
var legendName = this.name;
var match = legendName.match(/.{1,10}/g);
return match.toString().replace(/\,/g,"<br/>");
}
I have made an edit to the fiddle and you can find it Here. It pushes the legend item text to next line after every 10 characters. Guess this is what you needed.Hope this helps.

Resources