lib/index.js
/*----------------------------------------------------------------------------------
    * Create and update the Datetime text
    **---------------------------------------------------------------------------------*/
Create and update the Datetime text
Create and update the Datetime text
function displayDate() {
        var dateString = svg.selectAll('.dateString')
            .data([date]);
        dateString
            .text(function (d, i) {
            return d.toLocaleDateString();
        });
        dateString.enter()
            .append('text')
            .attr('class', 'dateString')
            .text(function (d, i) {
            return d.toLocaleDateString();
        })
            .attr('x', '100')
            .attr('y', '45')
            .attr('text-anchor', 'middle')
            .attr('fill', 'rgb(100,100,100)')
            .style('font-size', '22px');
        var timeString = svg.selectAll('.timeString')
            .data([date]);
        timeString
            .text(function (d, i) {
            return d.toLocaleTimeString();
        });
        timeString.enter()
            .append('text')
            .attr('class', 'timeString')
            .text(function (d, i) {
            return d.toLocaleTimeString();
        })
            .attr('x', '275')
            .attr('y', '45')
            .attr('text-anchor', 'middle')
            .attr('fill', 'rgb(100,100,100)')
            .style('font-size', '22px');
        var event = new CustomEvent(event_name, {
            "detail": date.toISOString()
        });
        document.dispatchEvent(event);
    }
function displayDate ( ) { var dateString = svg . selectAll ( '.dateString' ) . data ( [ date ] ) ; dateString . text ( function ( d , i ) { return d . toLocaleDateString ( ) ; } ) ; dateString . enter ( ) . append ( 'text' ) . attr ( 'class' , 'dateString' ) . text ( function ( d , i ) { return d . toLocaleDateString ( ) ; } ) . attr ( 'x' , '100' ) . attr ( 'y' , '45' ) . attr ( 'text-anchor' , 'middle' ) . attr ( 'fill' , 'rgb(100,100,100)' ) . style ( 'font-size' , '22px' ) ; var timeString = svg . selectAll ( '.timeString' ) . data ( [ date ] ) ; timeString . text ( function ( d , i ) { return d . toLocaleTimeString ( ) ; } ) ; timeString . enter ( ) . append ( 'text' ) . attr ( 'class' , 'timeString' ) . text ( function ( d , i ) { return d . toLocaleTimeString ( ) ; } ) . attr ( 'x' , '275' ) . attr ( 'y' , '45' ) . attr ( 'text-anchor' , 'middle' ) . attr ( 'fill' , 'rgb(100,100,100)' ) . style ( 'font-size' , '22px' ) ; var event = new CustomEvent ( event_name , { "detail" : date . toISOString ( ) } ) ; document . dispatchEvent ( event ) ; }
Create and update the Datetime text
Create and update the Datetime text
// Data join for date string // Update // Enter // Data join for time string // Update // Enter // On datetime update fire event with  // specified event name