Showing posts with label Html. Show all posts
Showing posts with label Html. Show all posts

Monday, August 20, 2018

Link Bootstrap to your React JS application.

Once you have already installed the Bootstrap using npm command do the below to include the Bootstrap in your React app


index.js

import '../node_modules/bootstrap/dist/css/bootstrap.min.css';

App.js (to test)

<button type="button" className="btn btn-primary">Primary</button>

The entire App.js will something like this

import React, { Component } from 'react'; 

class App extends Component { 

 render() { 
 return ( 
 <div> 
 <button type="button" className="btn btn-primary">Primary</button> 
 </div> );
 } 

export default App;

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

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...