Raphael Rectangle Tooltip - raphael

I am drawing series of rectangle using the following code in a loop
paper.rect(((x) * cellSize), ((y) * cellSize), cellSize, cellSize).attr({ fill: rgbx, stroke: rgbx });
Is there a way show tooltip on those rectangle? Is there a library that can show ballon tooltip (fadding)
I found similar question but not sure it can be done?

Here's a simple Raphael plugin for tooltips: http://www.strathausen.eu/en/2010/04/25/raphael-svg-tooltip/
Although it mentiones SVG explicitly, it should work just fine on IE (VML backend) as well.

Try the title attribute.
element.attr({title: 'The tooltip to be displayed on mouse hover'});

Related

Vertical Line chart with ChartJS

I have a problem with the ChartJS API in order that I need to paint a Line graphic, but lines should be painted vertically instead of horizontally.
The only response I can found is to draw static vertical lines in a "standard" horizontal line chart, but that's not the feature I need.
I suppose that ChartJS should hace any graphic type or options in Line graphic type to do this, but I don't see it.
Using "chart.js": "2.9.3"
I need something like this:
Thanks for answers.
If you are using the beta (version 3) of Chart.js you can set the property indexAxis to y in your options object to get the desired behaviour
Example:
options: {
indexAxis: 'y'
}

How to hide the y axis and x axis line and label in my bar chart for chart.js

I am new to Chart.js and I want to hide the y axis and x axis line and label in my chart. I looked at the documentation and couldn't find a good option. Has anyone else encountered this problem and have a solution?
Using the showScale option would be better
var ctx = document.getElementById("LineWithLine").getContext("2d");
new Chart(ctx).Line(data, {
showScale: false
});
Fiddle - http://jsfiddle.net/wb3kcunt/
This hides gridlines too. If you want to hide only the axes and labels and not the grid lines, just set scaleFontColor and scaleLineColor to a transparent color.
I found that if you edit a library posted in this answer, you can achieve this
In chart.js, Is it possible to hide x-axis label/text of bar chart if accessing from mobile?

Chart.js Pie Chart: How to set background image for segment

I'm using Chart.js to create a pie chart (see below). Instead of the colors in each pie segment, I would like to use a background image.
Could you give me a pointer on how I could do this?
Thanks!
var data = [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
}
];
var myPieChart = new Chart(ctx[0]).Pie(data,options);
Subclass Pie, rewrite the initializer and addData - in the initializer re-define draw, adding one line:
if(this.bg_img)ctx.fillStyle=ctx.createPattern(this.bg_img,"repeat");
, right after it says:
ctx.fillStyle = this.fillColor;
(copy Pie's draw, add that line - or just copy my AltPie subclass from the bottom of the attached fiddle) This could be different for later versions but that's how Chart.js 1.01 is.
Also in your Pie subclass you will add a property (for example call it bg_img) for sending the background image through. To do this there is a one-line addition, so re-define addData inside AltPie and add the property inside the splice line:
bg_img : segment.bg_img,
for example somewhere around the line
fillColor : segment.color,
That's most of it - other than that you will load and then attach the images to the data you're making the chart with. To load them you can use
....img=new Image();...img.src=...and - img.onload=function()(..recurse-load-next,
with a recursing callback similar to solution #2 from this page:
stackoverflow.com/questions/4960111/image-as-a-background-to-a-drawn-shape
I think you would need to make sure the images are done loading before attaching them to the data and sending them through to the Chart.js renderer, hence the recursion pattern to load them one by one before attaching them to the chart data and then creating the new AltPie chart.
The end result is that your images will show up in the pie pieces backgrounds or you can still use a color background if there's no image. It changes the html5 canvas ink pattern
(ctx.fillStyle=ctx.createPattern(this.bg_img,"repeat"))
to be the image you attached to the chart data, also taken from solution #2 from the same page: stackoverflow.com/questions/4960111/image-as-a-background-to-a-drawn-shape.
For the complete working example see attached fiddle https://jsfiddle.net/arlon_arriola/pkwftkp2/
The dependencies for loading the page are Chart.js file (v1.01?) (which is just copy/pasted into the fiddle at the top making the code look extremely long but the relvant code is at the very bottom), and the images inside your ./imgs/patterns/ folder, and the reference to some hosted jquery (1.9?). (and a body tag)
I am sure you could get image rollovers too, just attach two images to the data, figure out where it re-draws for hovering and modify it the same way as the regular draw.

Visualization API - Issue with centering chart

Using the Visualization API, I am drawing a very simple ColumnChart, with no legend.
I don't know why, but the chart is not centered in its container, as if the space for the legend on the right was kept, although the legend is not displayed.
But if I change the legend position to bottom, for example, that space is still present. So I am not sure if this is related to the legend.
Please check my JSFiddle. Notice the big padding on the right (around 55px).
Any way to fix this? Thanks in advance!
The chartArea is centered in the chart (the axis labels are not considered part of the chartArea, it is easier to see that it is centered if you turn them off: http://jsfiddle.net/xyqF7/9/), what you want to do is move it off-center, which you can do via the chartArea options:
chartArea: {
width: '80%',
left: '15%'
}
http://jsfiddle.net/xyqF7/8/

Stroking not working on CCLabelTTF in cocos2d-x ios in c++

I am tryng to make an outline of green color in my label but its not working..
my code is
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "HoboStd", 50);
pLabel->setPosition(ccp(200,200));
pLabel->enableStroke(ccGREEN, 5.0,true);
this->addChild(pLabel);
Its not providing the outline around the label text Hello World.Any one here who can help me
I got the fix in ios7.0 on how to enable stroking on labels
The normal stroking code of a label doesn’t work in IOS 7.0 but it works successfuly below IOS 7.0
The basic code for enabling stroking is provided below. We need to add a CCLabelTTF and then call the enableStroke function
CCLabelTTF *label=CCLabelTTF::create("Hello", "Arial.fnt", 50);
label->setPosition(ccp(300,300));
label->enableStroke(ccGREEN, 1.0,true);
this->addChild(label);
This works fine with IOS below 7.0. But in IOS 7.0 there is no stroking effect on the label. In order to fix the issue just follow some steps
Step1
Find the CCImage.mm file in your project and find the following code written there
//actually draw the text in the context
//XXX: ios7 casting
[str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font
lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
Step2
Now add the following code just below this line
//New Code Start
if(pInfo->hasStroke)
{
CGContextSetTextDrawingMode(context, kCGTextStroke);
CGContextSetRGBFillColor(context, pInfo->strokeColorR, pInfo->strokeColorG, pInfo->strokeColorB,
1);
CGContextSetLineWidth(context, pInfo->strokeSize);
[str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font
lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
}
//New Code End
Save the CCImage.mm file and then again re-run your project. It will redraw stroke with correct color.Tested on 7.0 simulator
I tested your code and I get the outline. Try to reduce the stroke width to 1.0.
pLabel->enableStroke(ccGREEN, 1.0,true);