Thursday, June 14, 2018

D3 tooltips - show tooltip in a different location

Sometimes you need to manually specify a target to act on. For instance, maybe you want the tooltip to appear over a different element than the one that triggered a mouseover event. You can specify an explicit target by passing an SVGElement as the last argument.

tip.show(data, target)

Check working example here 

The API for the above code is found here under Explicit targets

Wednesday, June 13, 2018

Get last element using D3

Method 1

You can use the selector :last-of-type to get the last element

var lastElement = parentObject.selectAll("rect:last-of-type");  


Method 2

Use selectAll and get the last element in array.

var lastElement = parentObject.selectAll("rect");
lastElement = lastElement[lastElement.length - 1]; // this will have the last element

Wednesday, May 16, 2018

Bulma - How to make text unselectable

Requirement: I want to restrict users selecting text in my website. How do I do this using Bulma

Use the class
.is-unselectable

See the Pen Bulma - make text unselectable by Kiran (@kiranvj) on CodePen.

Malayalam matrix screen

മലയാളം മാട്രിക്സ്

See the Pen Malayalam Matrix by Kiran (@kiranvj) on CodePen.

Bulma - left or right align an element

How to left or right align an element in Bulma

Use class .is-pulled-left to left align an element.

Use class .is-pulled-right to right align an element.


See the Pen Bulma - pull an element to right by Kiran (@kiranvj) on CodePen.

Friday, April 20, 2018

JavaScript set object key by variable

ES6

var key = "name";
var person = {[key]:"John"};
console.log(person); // should print  Object { name="John"}

Before ES6

var person = {};
var key = "name";

person[key] /* this is same as person.name */ = "John";

console.log(person); // should print  Object { name="John"}

Thursday, April 19, 2018

Give random colors to text in a page using D3

d3.selectAll("*").style("color", function() {
  return "hsl(" + Math.random() * 360 + ",100%,50%)";
});

Friday, June 30, 2017

Using filter filter example in Angular

<!doctype html>
<html>
<head>
    <script src="libs/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myController">
Enter subject<br />
<input type="text" ng-model="subjectName" /><br />
<p>Selected subject name is <span ng-bind="subjectName"></span></p>
<ul>
    <li ng-repeat="subject in student.subjects | filter : subjectName">{{subject.name}}</li>
</ul>
</div>
<script>
    var app = angular.module("myApp", []);
    app.controller("myController", function($scope) {
        $scope.student = {
            subjects : [{"name" : "English"}, {"name" : "Mathematics"}]
        };
    });
</script>
</body>
</html>

Monday, February 20, 2006

How to indent code in blogger

You can use <pre> tags to indent code in blogger.

<pre>
your code with indent, just white space will do, no need to add   in html
</pre>
This is testing for the posthttp://code.box.sk/forum.php?page=last&did=multC%2FC%2B%2B&thread=16758


if (d > 0){
/* results are real numbers */
q = pow (d, 1./2);

x1 = (-b + q)/(2*a);
x2 = (-b - q)/(2*a);
printf ("X1=%f X2=%f\n", x1, x2);
}
else if (d == 0)
{
/* there’s only one result */
x1 = -b/(2*a);
printf ("X1=X2=%f\n", x1);
}
else
{
/* results are conjugated complex numbers */
q = pow(-d, 1./2);
x1r = -b/(2*a) ;
x2r = x1r;
x1i = q/(2*a);
x2i = -x1i;
printf ("X1 = (%f,%f)\n", x1r, x1i);
printf ("X2 = (%f,%f)\n", x2r, x2i);
}

Thursday, February 09, 2006

My First weBLOG

This is my first blog. I will be updating soon.

Posted on 9-2-2006, 4.09 pm IST from isquaretechnologies, vtk.

Get Indian financial year based on date

This function lets you get the start and end date of Indian financial year based on given date. This can also be modified for US financia...