Expanding circle counter width display


  • Member
    eclerkin
    March 11, 2017 at 1:58 am #31182

    About 2 years ago, you folks helped me modify boc_circle_counter to include a decimal point on the number entered. It works fine for number like 8.2% but truncates the decimal point and value for anything with 2 digits like 18.2%. What would I need to change to show 99.9% instead of 99%? Is it the class circ_counter_text_holder causing the truncation?

    // Register Shortcode
    if( ! function_exists( 'shortcode_boc_circle_counter' ) ) {
    	function shortcode_boc_circle_counter( $atts, $content = null ) {
    	
    		$atts = vc_map_get_attributes('boc_circle_counter', $atts );
    		extract( $atts );
    
    		$id = rand(0,10000);
    
    		if(!$custom_color) {
    			$color = boc_get_main_color();
    		}
    		if($centered) {
    			$css_classes .= ' center';
    		}
    		if($angle) {
    			$css_classes .= ' half_circle';
    		}
    		if($size == 120) {
    			$css_classes .= ' small_counter';
    		} elseif($size == 80) {
    			$css_classes .= ' large_counter';
    		}
            
            //EC Added the following modification for decimal numbers (removed (int))
            //<canvas width='.esc_attr($size).' height='.esc_attr($size).'  data-end-nu="'.(int) $number.'"></canvas>
            //<div class="circ_counter_text_holder"><span class="circ_counter_text"  id="circ_counter_text'.$id.'"></span><span class="counter_percent_sign heading_font">%</span></div>
    
            
    		$str = '<div class="circ_numbers_holder '.esc_attr($css_classes).' '.($white_text ? "white_text" : "").'">
    					<div class="circ_counter" data-color="'.esc_attr($color).'" data-angle="'.esc_attr($angle).'" data-size="'.esc_attr($size).'" data-white_text="'.($white_text ? "1" : "0").'">
    						<canvas width='.esc_attr($size).' height='.esc_attr($size).'  data-end-nu="'.$number.'"></canvas>
                            <div class="circ_counter_text_holder"><span class="circ_counter_text"  id="circ_counter_text'.$id.'"></span><span class="counter_percent_sign heading_font">%</span></div>
    
    						<div class="circ_counter_desc">'.wp_kses_post($title).'</div>
    					</div>
    				</div>';
    
    		return $str;
    	}
    	
    	add_shortcode('boc_circle_counter', 'shortcode_boc_circle_counter');

    Sorry, this forum is for verified users only. Please Login or Register to continue

Comments are closed.