<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Group_Control_Typography;
use Elementor\Core\Schemes\Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;

use EcafeAddons\EcafeElementLoad;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

class Ecafe_Chart extends Widget_Base {

	public function get_name() {
		return 'ecafe-chart';
	}

	public function get_title() {
		return esc_html__( 'Chart', 'essential-classy-addons-for-elementor' );
	}

	public function get_icon() {
		return 'ecafe-ele-back-icon ecafe-chart-icon';
	}

	public function get_categories() {
		return array( 'essential' );
	}

	public function get_keywords() {
		return array( 'advanced chart', 'chart', 'line', 'bar', 'vertical bar', 'horizontal bar', 'radar', 'pie', 'doughnut', 'polararea', 'bubble', 'datachart', 'infograph', 'info graph' );
	}

	public function get_script_depends() {
		return array( 'ecafe-chart' );
	}
	public function get_custom_help_url() {
		return 'https://store.kapasias.com/helpdesk/';
	}
	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}
	protected function register_controls() {

		$this->start_controls_section(
			'chartsContent',
			array(
				'label' => esc_html__( 'Chart', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'selectChart',
			array(
				'label'   => esc_html__( 'Type', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'line',
				'options' => array(
					'line'          => esc_html__( 'Line', 'essential-classy-addons-for-elementor' ),
					'bar'           => esc_html__( 'Vertical Bar', 'essential-classy-addons-for-elementor' ),
					'horizontalBar' => esc_html__( 'Horizontal Bar', 'essential-classy-addons-for-elementor' ),
					'radar'         => esc_html__( 'Radar', 'essential-classy-addons-for-elementor' ),
					'pie'           => esc_html__( 'Pie', 'essential-classy-addons-for-elementor' ),
					'doughnut'      => esc_html__( 'Doughnut', 'essential-classy-addons-for-elementor' ),
					'polarArea'     => esc_html__( 'Polar Area', 'essential-classy-addons-for-elementor' ),
					'bubble'        => esc_html__( 'Bubble', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'mainLabel',
			array(
				'label'       => esc_html__( 'Label Values', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( 'Jan , Feb , Mar', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
			)
		);
		$this->end_controls_section();

		/*line,bar,radar dataset start*/
		$this->start_controls_section(
			'chartDataset',
			array(
				'label'     => esc_html__( 'Dataset', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart' => array( 'line', 'bar', 'horizontalBar', 'radar' ),
				),
			)
		);
		$repeater = new \Elementor\Repeater();
		$repeater->add_control(
			'loopLabel',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter label', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),

			)
		);
		$repeater->add_control(
			'loopData',
			array(
				'label'       => esc_html__( 'Data', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '0 , 10 , 35', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
			)
		);
		$repeater->add_control(
			'individualDotBg',
			array(
				'label'        => esc_html__( 'Individual Dot Background', 'essential-classy-addons-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off'    => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'no',
				'separator'    => 'before',
			)
		);
		$repeater->add_control(
			'DotBg',
			array(
				'label'     => esc_html__( 'Dot Background', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgb(0 0 0 / 0.5)',
				'condition' => array(
					'individualDotBg!' => 'yes',
				),
			)
		);
		$repeater->add_control(
			'individualDotBgPass',
			array(
				'label'       => esc_html__( 'Dot Background', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#bd3b1b80,#d6a80080,#b9d87080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by , ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'condition'   => array(
					'individualDotBg' => 'yes',
				),
			)
		);
		$repeater->add_control(
			'individualDotBorder',
			array(
				'label'        => esc_html__( 'Individual Border', 'essential-classy-addons-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off'    => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'no',
				'separator'    => 'before',
			)
		);
		$repeater->add_control(
			'dotBorder',
			array(
				'label'     => esc_html__( 'Dot Border', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgb(0 0 0 / 0.5)',
				'condition' => array(
					'individualDotBorder!' => 'yes',
				),
			)
		);
		$repeater->add_control(
			'individualDotBorderPass',
			array(
				'label'       => esc_html__( 'Dot Border', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#bd3b1b80,#d6a80080,#b9d87080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'condition'   => array(
					'individualDotBorder' => 'yes',
				),
			)
		);
		$repeater->add_control(
			'fillOpt',
			array(
				'label'       => esc_html__( 'Fill', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::SWITCHER,
				'label_on'    => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off'   => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'     => 'yes',
				'description' => esc_html__( 'Please Note : Fill options works in Line and Radar chart only', 'essential-classy-addons-for-elementor' ),
				'separator'   => 'before',
			)
		);
		$repeater->add_control(
			'lineStylingOpt',
			array(
				'label'       => esc_html__( 'Border Dash', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::SWITCHER,
				'label_on'    => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off'   => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'     => 'no',
				'description' => esc_html__( 'Please Note : Fill options works in Line and Radar chart only', 'essential-classy-addons-for-elementor' ),
				'separator'   => 'before',
			)
		);
		$this->add_control(
			'chartContent',
			array(
				'label'       => esc_html__( 'Chart Data Boxes', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater->get_controls(),
				'default'     => array(
					array(
						'loopLabel' => esc_html__( 'Jan', 'essential-classy-addons-for-elementor' ),
						'loopData'  => esc_html__( '0 , 10 , 35 ', 'essential-classy-addons-for-elementor' ),
						'DotBg'     => '#bd3b1b80',
						'dotBorder' => '#bd3b1b80',
					),
					array(
						'loopLabel' => esc_html__( 'Feb', 'essential-classy-addons-for-elementor' ),
						'loopData'  => esc_html__( '5 , 12 , 46', 'essential-classy-addons-for-elementor' ),
						'DotBg'     => '#d6a80080',
						'dotBorder' => '#d6a80080',
					),
					array(
						'loopLabel' => esc_html__( 'Mar', 'essential-classy-addons-for-elementor' ),
						'loopData'  => esc_html__( '15 , 20 , 60', 'essential-classy-addons-for-elementor' ),
						'DotBg'     => '#b9d87080',
						'dotBorder' => '#b9d87080',
					),
				),
				'title_field' => '{{{ loopLabel }}}',
			)
		);
		$this->end_controls_section();
		/*line,bar,radar dataset end*/

		/*pie dataset start*/
		$this->start_controls_section(
			'chartDatasetSeprate',
			array(
				'label'     => esc_html__( 'Dataset', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart' => array( 'pie', 'polarArea' ),
				),
			)
		);
		$this->add_control(
			'seprateData',
			array(
				'label'       => esc_html__( 'Data', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '5 , 10 , 15', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
			)
		);
		$this->add_control(
			'seprateBgColors',
			array(
				'label'       => esc_html__( 'Background Colors', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#bd3b1b80,#d6a80080,#b9d87080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
			)
		);
		$this->add_control(
			'seprateBorderColors',
			array(
				'label'       => esc_html__( 'Border Colors', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#bd3b1b80,#d6a80080,#b9d87080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
				'condition'   => array(
					'selectChart' => 'pie',
				),
			)
		);
		$this->add_control(
			'seprateBorderColorsPolar',
			array(
				'label'       => esc_html__( 'Border Colors', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#bd3b1b80,#d6a80080,#b9d87080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
				'condition'   => array(
					'selectChart' => 'polarArea',
				),
			)
		);
		$this->end_controls_section();
		/*pie dataset end*/

		/*doughnut dataset start*/
		$this->start_controls_section(
			'doughnutChartDataset',
			array(
				'label'     => esc_html__( 'Dataset', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart' => 'doughnut',
				),
			)
		);
		$repeater2 = new \Elementor\Repeater();
		$repeater2->add_control(
			'doughnutLoopLabel',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter label', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),

			)
		);
		$repeater2->add_control(
			'doughnutLoopData',
			array(
				'label'       => esc_html__( 'Data', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '5 , 10 , 15', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
			)
		);
		$repeater2->add_control(
			'doughnutLoopBackground',
			array(
				'label'       => esc_html__( 'Background Colors', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#b6c61a80,#b9d87080,#d6a80080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
			)
		);
		$repeater2->add_control(
			'doughnutLoopBorder',
			array(
				'label'       => esc_html__( 'Border Colors', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#00634480,#00634480,#00634480', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
			)
		);
		$this->add_control(
			'doughnutChartDatasets',
			array(
				'label'       => esc_html__( 'Chart Data Boxes', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater2->get_controls(),
				'default'     => array(
					array(
						'doughnutLoopLabel'      => esc_html__( 'Jan', 'essential-classy-addons-for-elementor' ),
						'doughnutLoopData'       => esc_html__( '5 , 10 , 15 ', 'essential-classy-addons-for-elementor' ),
						'doughnutLoopBackground' => '#b6c61a80,#b9d87080,#d6a80080',
						'doughnutLoopBorder'     => '#00634480,#00634480,#00634480',
					),
					array(
						'doughnutLoopLabel'      => esc_html__( 'Feb', 'essential-classy-addons-for-elementor' ),
						'doughnutLoopData'       => esc_html__( '7 , 12 , 24', 'essential-classy-addons-for-elementor' ),
						'doughnutLoopBackground' => '#bd3b1b80,#d6a80080,#b9d87080',
						'doughnutLoopBorder'     => '#40e0d0,#40e0d0,#40e0d0',
					),
					array(
						'doughnutLoopLabel'      => esc_html__( 'Mar', 'essential-classy-addons-for-elementor' ),
						'doughnutLoopData'       => esc_html__( '15 , 21 , 45', 'essential-classy-addons-for-elementor' ),
						'doughnutLoopBackground' => '#71d1dc99,#b9d87080,#b6c61a80',
						'doughnutLoopBorder'     => '#00634480,#00634480,#00634480',
					),
				),
				'title_field' => '{{{ doughnutLoopLabel }}}',
			)
		);
		$this->end_controls_section();
		/*doughnut dataset end*/

		/*bubble dataset start*/
		$this->start_controls_section(
			'chartDatasetBubble',
			array(
				'label'     => esc_html__( 'Datasets', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart' => 'bubble',
				),
			)
		);
		$repeaterBubble = new \Elementor\Repeater();
		$repeaterBubble->add_control(
			'loopLabel',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter label', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),

			)
		);
		$repeaterBubble->add_control(
			'bubbleValues',
			array(
				'label'       => esc_html__( 'Data', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '[5,10,15][7,18,9][8,12,20]', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'separator'   => 'before',
			)
		);
		$repeaterBubble->add_control(
			'individualDotBg',
			array(
				'label'        => esc_html__( 'Individual Background Colors', 'essential-classy-addons-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off'    => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'no',
				'separator'    => 'before',
			)
		);
		$repeaterBubble->add_control(
			'DotBg',
			array(
				'label'     => esc_html__( 'Background', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgb(0 0 0 / 0.5)',
				'condition' => array(
					'individualDotBg!' => 'yes',
				),
			)
		);
		$repeaterBubble->add_control(
			'individualDotBgPass',
			array(
				'label'       => esc_html__( 'Background', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#bd3b1b80,#d6a80080,#b9d87080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'condition'   => array(
					'individualDotBg' => 'yes',
				),
			)
		);
		$repeaterBubble->add_control(
			'individualDotBorder',
			array(
				'label'        => esc_html__( 'Individual Border Colors', 'essential-classy-addons-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off'    => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'no',
				'separator'    => 'before',
			)
		);
		$repeaterBubble->add_control(
			'dotBorder',
			array(
				'label'     => esc_html__( 'Dot Border', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgb(0 0 0 / 0.5)',
				'condition' => array(
					'individualDotBorder!' => 'yes',
				),
			)
		);
		$repeaterBubble->add_control(
			'individualDotBorderPass',
			array(
				'label'       => esc_html__( 'Dot Background Colors', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( '#bd3b1b80,#d6a80080,#b9d87080', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Seprate by ,(Comma) ', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
				'condition'   => array(
					'individualDotBorder' => 'yes',
				),
			)
		);
		$this->add_control(
			'bubbleContent',
			array(
				'label'       => esc_html__( 'Chart Data Boxes', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeaterBubble->get_controls(),
				'default'     => array(
					array(
						'loopLabel'    => esc_html__( 'Jan', 'essential-classy-addons-for-elementor' ),
						'bubbleValues' => esc_html__( '[5,10,15][7,18,9][8,14,20]', 'essential-classy-addons-for-elementor' ),
						'DotBg'        => '#bd3b1b80',
						'dotBorder'    => '#bd3b1b80',
					),
					array(
						'loopLabel'    => esc_html__( 'Feb', 'essential-classy-addons-for-elementor' ),
						'bubbleValues' => esc_html__( '[7,8,17][5,20,7][10,12,14]', 'essential-classy-addons-for-elementor' ),
						'DotBg'        => '#d6a80080',
						'dotBorder'    => '#d6a80080',
					),
					array(
						'loopLabel'    => esc_html__( 'Mar', 'essential-classy-addons-for-elementor' ),
						'bubbleValues' => esc_html__( '[6,9,16][6,19,8][9,14,16]', 'essential-classy-addons-for-elementor' ),
						'DotBg'        => '#b9d87080',
						'dotBorder'    => '#b9d87080',
					),
				),
				'title_field' => '{{{ loopLabel }}}',
			)
		);
		$this->end_controls_section();
		/*bubble dataset end*/

		/*bar options start*/
		$this->start_controls_section(
			'chartBarOptions',
			array(
				'label'     => esc_html__( 'Bar Options', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart' => array( 'bar', 'horizontalBar' ),
				),
			)
		);
		$this->add_responsive_control(
			'maxbarThickness',
			array(
				'type'  => Controls_Manager::SLIDER,
				'label' => esc_html__( 'Bar Size', 'essential-classy-addons-for-elementor' ),
				'range' => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
			)
		);
		$this->add_responsive_control(
			'barThickness',
			array(
				'type'  => Controls_Manager::SLIDER,
				'label' => esc_html__( 'Bar Space', 'essential-classy-addons-for-elementor' ),
				'range' => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
			)
		);
		$this->end_controls_section();
		/*bar options end*/

		/*grid lines options start*/
		$this->start_controls_section(
			'chartGridLinesOptions',
			array(
				'label'     => esc_html__( 'Grid Lines Options', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart!' => array( 'pie', 'doughnut' ),
				),
			)
		);
		$this->add_control(
			'showGridLines',
			array(
				'label'     => esc_html__( 'Grid Lines', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->start_controls_tabs( 'tabsAxesStyle' );
		$this->start_controls_tab(
			'tabAxesX',
			array(
				'label'     => esc_html__( 'X Axes', 'essential-classy-addons-for-elementor' ),
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'gridColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgb(0 0 0 / 0.5)',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'zeroLinecolorX',
			array(
				'label'     => esc_html__( 'Zero Line Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgba(0, 0, 0, 0.25)',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'drawBorderX',
			array(
				'label'     => esc_html__( 'Draw Border', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'no',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'drawOnChartAreaX',
			array(
				'label'     => esc_html__( 'Draw Border on Chart Area', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabAxesY',
			array(
				'label'     => esc_html__( 'Y Axes', 'essential-classy-addons-for-elementor' ),
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'gridColorXAxes',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgb(0 0 0 / 0.5)',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'zeroLinecolorY',
			array(
				'label'     => esc_html__( 'Zero Line Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgba(0, 0, 0, 0.25)',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'drawBorderY',
			array(
				'label'     => esc_html__( 'Draw Border', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'no',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->add_control(
			'drawOnChartAreaY',
			array(
				'label'     => esc_html__( 'Draw Border on Chart Area', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
				'condition' => array(
					'showGridLines' => 'yes',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*grid lines options end*/

		/*scaleLabel start*/
		$this->start_controls_section(
			'chart_scale_label_options',
			array(
				'label'     => esc_html__( 'Scale Label Options', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart!' => array( 'pie', 'doughnut' ),
				),
			)
		);
		$this->start_controls_tabs( 'tabs_sl_style' );
		$this->start_controls_tab(
			'tab_sl_x',
			array(
				'label' => esc_html__( 'X Axes', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'scaleLabelXtext',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'Enter label', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),

			)
		);
		$this->add_control(
			'scaleLabelXtextc',
			array(
				'label'   => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::COLOR,
				'default' => 'rgb(0 0 0 / 0.5)',
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tab_sl_y',
			array(
				'label' => esc_html__( 'Y Axes', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'scaleLabelYtext',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'Enter label', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),

			)
		);
		$this->add_control(
			'scaleLabelYtextc',
			array(
				'label'   => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::COLOR,
				'default' => 'rgb(0 0 0 / 0.5)',
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*scaleLabel end*/

		/*labels options start*/
		$this->start_controls_section(
			'chartLabelsOptions',
			array(
				'label'     => esc_html__( 'Labels Options', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_CONTENT,
				'condition' => array(
					'selectChart!' => array( 'pie', 'doughnut' ),
				),
			)
		);
		$this->add_control(
			'showLabels',
			array(
				'label'     => esc_html__( 'Labels', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_control(
			'showLabelsColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#666',
				'condition' => array(
					'showLabels' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'showLabelsSize',
			array(
				'type'      => Controls_Manager::SLIDER,
				'label'     => esc_html__( 'Size', 'essential-classy-addons-for-elementor' ),
				'range'     => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
				'default'   => array(
					'size' => 12,
				),
				'condition' => array(
					'showLabels' => 'yes',
				),
			)
		);
		$this->end_controls_section();
		/*labels options end*/

		/*legend options start*/
		$this->start_controls_section(
			'chartLegendOptions',
			array(
				'label' => esc_html__( 'Legend Options', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'showLegend',
			array(
				'label'     => esc_html__( 'Legend', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_responsive_control(
			'showLegendSize',
			array(
				'type'      => Controls_Manager::SLIDER,
				'label'     => esc_html__( 'Size', 'essential-classy-addons-for-elementor' ),
				'range'     => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
				'default'   => array(
					'size' => 12,
				),
				'condition' => array(
					'showLegend' => 'yes',
				),
			)
		);
		$this->add_control(
			'showLegendColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#666',
				'condition' => array(
					'showLegend' => 'yes',
				),
			)
		);
		$this->add_control(
			'showLegendPosition',
			array(
				'label'     => esc_html__( 'Position', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'left'   => array(
						'title' => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'top'    => array(
						'title' => esc_html__( 'Top', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-v-align-top',
					),
					'bottom' => array(
						'title' => esc_html__( 'Bottom', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-v-align-bottom',
					),
					'right'  => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'default'   => 'top',
				'condition' => array(
					'showLegend' => 'yes',
				),
			)
		);
		$this->add_control(
			'showLegendAlign',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'start'  => array(
						'title' => esc_html__( 'Start', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'end'    => array(
						'title' => esc_html__( 'End', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'default'   => 'center',
				'condition' => array(
					'showLegend' => 'yes',
				),
			)
		);
		$this->end_controls_section();
		/*legend options end*/

		/*tooltip options start*/
		$this->start_controls_section(
			'chartTooltipOptions',
			array(
				'label' => esc_html__( 'Tooltip Options', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'showTooltip',
			array(
				'label'     => esc_html__( 'Tooltip', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_control(
			'tooltipEvent',
			array(
				'label'     => esc_html__( 'Event', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'hover',
				'options'   => array(
					'hover' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
					'click' => esc_html__( 'Click', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'showTooltip' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'tooltipFontSize',
			array(
				'type'      => Controls_Manager::SLIDER,
				'label'     => esc_html__( 'Font Size', 'essential-classy-addons-for-elementor' ),
				'range'     => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
				'default'   => array(
					'size' => 12,
				),
				'condition' => array(
					'showTooltip' => 'yes',
				),
			)
		);
		$this->add_control(
			'tooltipColor',
			array(
				'label'     => esc_html__( 'Title Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#fff',
				'condition' => array(
					'showTooltip' => 'yes',
				),
			)
		);
		$this->add_control(
			'tooltipBodyFontColor',
			array(
				'label'     => esc_html__( 'Body Font Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#fff',
				'condition' => array(
					'showTooltip' => 'yes',
				),
			)
		);
		$this->add_control(
			'tooltipBg',
			array(
				'label'     => esc_html__( 'Tooltip Background', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'showTooltip' => 'yes',
				),
			)
		);
		$this->end_controls_section();
		/*tooltip options end*/

		/*animation options start*/
		$this->start_controls_section(
			'chartAnimationOptions',
			array(
				'label' => esc_html__( 'Animation Options', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'customAnimation',
			array(
				'label'   => esc_html__( 'Animation', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'easeOutQuart',
				'options' => array(
					'linear'           => esc_html__( 'linear', 'essential-classy-addons-for-elementor' ),
					'easeInQuad'       => esc_html__( 'easeInQuad', 'essential-classy-addons-for-elementor' ),
					'easeOutQuad'      => esc_html__( 'easeOutQuad', 'essential-classy-addons-for-elementor' ),
					'easeInOutQuad'    => esc_html__( 'easeInOutQuad', 'essential-classy-addons-for-elementor' ),
					'easeInCubic'      => esc_html__( 'easeInCubic', 'essential-classy-addons-for-elementor' ),
					'easeOutCubic'     => esc_html__( 'easeOutCubic', 'essential-classy-addons-for-elementor' ),
					'easeInOutCubic'   => esc_html__( 'easeInOutCubic', 'essential-classy-addons-for-elementor' ),
					'easeInQuart'      => esc_html__( 'easeInQuart', 'essential-classy-addons-for-elementor' ),
					'easeOutQuart'     => esc_html__( 'easeOutQuart', 'essential-classy-addons-for-elementor' ),
					'easeInOutQuart'   => esc_html__( 'easeInOutQuart', 'essential-classy-addons-for-elementor' ),
					'easeInQuint'      => esc_html__( 'easeInQuint', 'essential-classy-addons-for-elementor' ),
					'easeOutQuint'     => esc_html__( 'easeOutQuint', 'essential-classy-addons-for-elementor' ),
					'easeInOutQuint'   => esc_html__( 'easeInOutQuint', 'essential-classy-addons-for-elementor' ),
					'easeInSine'       => esc_html__( 'easeInSine', 'essential-classy-addons-for-elementor' ),
					'easeOutSine'      => esc_html__( 'easeOutSine', 'essential-classy-addons-for-elementor' ),
					'easeInOutSine'    => esc_html__( 'easeInOutSine', 'essential-classy-addons-for-elementor' ),
					'easeInExpo'       => esc_html__( 'easeInExpo', 'essential-classy-addons-for-elementor' ),
					'easeOutExpo'      => esc_html__( 'easeOutExpo', 'essential-classy-addons-for-elementor' ),
					'easeInOutExpo'    => esc_html__( 'easeInOutExpo', 'essential-classy-addons-for-elementor' ),
					'easeInCirc'       => esc_html__( 'easeInCirc', 'essential-classy-addons-for-elementor' ),
					'easeOutCirc'      => esc_html__( 'easeOutCirc', 'essential-classy-addons-for-elementor' ),
					'easeInOutCirc'    => esc_html__( 'easeInOutCirc', 'essential-classy-addons-for-elementor' ),
					'easeInElastic'    => esc_html__( 'easeInElastic', 'essential-classy-addons-for-elementor' ),
					'easeOutElastic'   => esc_html__( 'easeOutElastic', 'essential-classy-addons-for-elementor' ),
					'easeInOutElastic' => esc_html__( 'easeInOutElastic', 'essential-classy-addons-for-elementor' ),
					'easeInBack'       => esc_html__( 'easeInBack', 'essential-classy-addons-for-elementor' ),
					'easeOutBack'      => esc_html__( 'easeOutBack', 'essential-classy-addons-for-elementor' ),
					'easeInOutBack'    => esc_html__( 'easeInOutBack', 'essential-classy-addons-for-elementor' ),
					'easeInBounce'     => esc_html__( 'easeInBounce', 'essential-classy-addons-for-elementor' ),
					'easeOutBounce'    => esc_html__( 'easeOutBounce', 'essential-classy-addons-for-elementor' ),
					'easeInOutBounce'  => esc_html__( 'easeInOutBounce', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_responsive_control(
			'customAnimationDuration',
			array(
				'type'    => Controls_Manager::SLIDER,
				'label'   => esc_html__( 'Duration', 'essential-classy-addons-for-elementor' ),
				'range'   => array(
					'px' => array(
						'min'  => 1,
						'max'  => 10000,
						'step' => 100,
					),
				),
				'default' => array(
					'size' => 1000,
				),
			)
		);
		$this->end_controls_section();
		/*animation options end*/

		/*advanced options start*/
		$this->start_controls_section(
			'chartAdvancedOptions',
			array(
				'label' => esc_html__( 'Advanced Options', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'tension',
			array(
				'label'     => esc_html__( 'Smooth Tension', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
				'separator' => 'before',
				'condition' => array(
					'selectChart' => 'line',
				),
			)
		);
		$this->add_control(
			'customizePointStyles',
			array(
				'label'     => esc_html__( 'Customize Point Styles', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'no',
				'separator' => 'before',
				'condition' => array(
					'selectChart' => array( 'line', 'radar', 'bubble' ),
				),
			)
		);
		$this->add_control(
			'pointStylesSelect',
			array(
				'label'     => esc_html__( 'Point Styles', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'circle',
				'options'   => array(
					'circle'      => esc_html__( 'Circle', 'essential-classy-addons-for-elementor' ),
					'cross'       => esc_html__( 'Cross', 'essential-classy-addons-for-elementor' ),
					'crossRot'    => esc_html__( 'CrossRot', 'essential-classy-addons-for-elementor' ),
					'dash'        => esc_html__( 'Dash', 'essential-classy-addons-for-elementor' ),
					'line'        => esc_html__( 'Line', 'essential-classy-addons-for-elementor' ),
					'rect'        => esc_html__( 'Rect', 'essential-classy-addons-for-elementor' ),
					'rectRounded' => esc_html__( 'RectRounded', 'essential-classy-addons-for-elementor' ),
					'rectRot'     => esc_html__( 'RectRot', 'essential-classy-addons-for-elementor' ),
					'star'        => esc_html__( 'Star', 'essential-classy-addons-for-elementor' ),
					'triangle'    => esc_html__( 'Triangle', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'selectChart'          => array( 'line', 'radar', 'bubble' ),
					'customizePointStyles' => 'yes',
				),
			)
		);
		$this->add_control(
			'pointBg',
			array(
				'label'     => esc_html__( 'Point Background', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#b6c61a80',
				'condition' => array(
					'selectChart'          => array( 'line', 'radar' ),
					'customizePointStyles' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'pointNSize',
			array(
				'type'      => Controls_Manager::SLIDER,
				'label'     => esc_html__( 'Point Normal Size', 'essential-classy-addons-for-elementor' ),
				'range'     => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
				'default'   => array(
					'size' => 5,
				),
				'condition' => array(
					'selectChart'          => array( 'line', 'radar' ),
					'customizePointStyles' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'pointHSize',
			array(
				'type'      => Controls_Manager::SLIDER,
				'label'     => esc_html__( 'Point Hover Size', 'essential-classy-addons-for-elementor' ),
				'range'     => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
				'default'   => array(
					'size' => 10,
				),
				'condition' => array(
					'selectChart'          => array( 'line', 'radar' ),
					'customizePointStyles' => 'yes',
				),
			)
		);
		$this->add_control(
			'pointBorderColor',
			array(
				'label'     => esc_html__( 'Point Border', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#00634480',
				'condition' => array(
					'selectChart'          => array( 'line', 'radar' ),
					'customizePointStyles' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'pointBorderWidth',
			array(
				'type'      => Controls_Manager::SLIDER,
				'label'     => esc_html__( 'Point Border Width', 'essential-classy-addons-for-elementor' ),
				'range'     => array(
					'px' => array(
						'min'  => 1,
						'max'  => 50,
						'step' => 1,
					),
				),
				'default'   => array(
					'size' => 1,
				),
				'condition' => array(
					'selectChart'          => array( 'line', 'radar' ),
					'customizePointStyles' => 'yes',
				),
			)
		);
		$this->add_control(
			'aspectRatio',
			array(
				'label'     => esc_html__( 'Aspect Ratio', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'no',
				'separator' => 'before',
			)
		);
		$this->add_control(
			'maintainAspectRatio',
			array(
				'label'     => esc_html__( 'Maintain Aspect Ratio', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
				'separator' => 'before',
			)
		);
		$this->end_controls_section();
		/*advanced options end*/

		/*Notice panel*/
		$ecwidgetdemolink = esc_url( 'https://ecaddons.com/elements/chart/' );
		$ecwidgetdoclink  = esc_url( 'https://ecaddons.com/docs/chart-widget-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';
	}

	public function bubbleValues( $bubbleValues ) {
		$bubbleValues = trim( $bubbleValues );
		$divideValue  = preg_match_all( '#\[([^\]]+)\]#U', $bubbleValues, $getAndVerify );
		if ( ! $divideValue ) {
			return array();
		} else {
			$bubbleValue = $getAndVerify[1];
			$bubble      = array();
			foreach ( $bubbleValue as $itemValue ) {
				$itemValue = trim( $itemValue, '][ ' );
				$itemValue = explode( ',', $itemValue );

				if ( count( $itemValue ) != 3 ) {
					continue;
				}

				$xYR      = new \stdClass();
				$xYR->x   = floatval( trim( $itemValue[0] ) );
				$xYR->y   = floatval( trim( $itemValue[1] ) );
				$xYR->r   = floatval( trim( $itemValue[2] ) );
				$bubble[] = $xYR;
			}
			return $bubble;
		}
	}

	protected function render() {
		$settings = $this->get_settings_for_display();
		$type     = ! empty( $settings['selectChart'] ) ? $settings['selectChart'] : 'line';

		$getValues = $datasets = $datasetsSec = $datasetsThird = array();

		if ( ! empty( $type ) ) {
			if ( $type == 'pie' || $type == 'doughnut' || $type == 'polarArea' ) {
				if ( $type == 'pie' || $type == 'polarArea' ) {
					$seprateData = array_map( 'floatval', explode( ',', $settings['seprateData'] ) );
					if ( ! empty( $seprateData ) ) {
						$datasets[] = array(
							'data'            => $seprateData,
							'backgroundColor' => explode( ',', $settings['seprateBgColors'] ),
						);
					}

					if ( $type == 'pie' && ! empty( $settings['seprateBorderColors'] ) ) {
						$datasets[] = array(
							'borderColor' => explode( ',', $settings['seprateBorderColors'] ),
						);
					}

					if ( $type == 'polarArea' && ! empty( $settings['seprateBorderColorsPolar'] ) ) {
						$datasets[] = array(
							'borderColor' => explode( ',', $settings['seprateBorderColorsPolar'] ),
						);
					}
				} elseif ( $type == 'doughnut' ) {
					foreach ( $settings['doughnutChartDatasets'] as $item1 ) {

						$datasets2['data'] = array_map( 'floatval', explode( ',', $item1['doughnutLoopData'] ) );

						$datasets2['backgroundColor'] = ( $item1['doughnutLoopBackground'] ) ? explode( ',', $item1['doughnutLoopBackground'] ) : array();

						$datasets2['borderColor'] = ( $item1['doughnutLoopBorder'] ) ? explode( ',', $item1['doughnutLoopBorder'] ) : array();

						$datasets[] = $datasets2;
					}
				}
			} else {
				$datasetsThird = ( $type == 'bubble' ) ? $settings['bubbleContent'] : $settings['chartContent'];
				foreach ( $datasetsThird as $item ) {
					$datasetsSec['label'] = $item['loopLabel'];

					if ( ! empty( $type ) && $type == 'bubble' ) {
						$datasetsSec['data'] = $this->bubbleValues( $item['bubbleValues'] );
					} else {
						$datasetsSec['data'] = array_map( 'floatval', explode( ',', $item['loopData'] ) );
					}

					if ( ( isset( $item['individualDotBg'] ) && $item['individualDotBg'] == 'yes' ) && ! empty( $item['individualDotBgPass'] ) ) {
						$datasetsSec['backgroundColor'] = explode( ',', $item['individualDotBgPass'] );
					} else {
						$datasetsSec['backgroundColor'] = $item['DotBg'];
					}

					if ( ( isset( $item['individualDotBorder'] ) && $item['individualDotBorder'] == 'yes' ) && ! empty( $item['individualDotBorderPass'] ) ) {
						$datasetsSec['borderColor'] = explode( ',', $item['individualDotBorderPass'] );
					} else {
						$datasetsSec['borderColor'] = $item['dotBorder'];
					}

					$datasetsSec['borderDash'] = array();
					if ( ( $type == 'line' || $type == 'radar' ) && ( isset( $item['lineStylingOpt'] ) && $item['lineStylingOpt'] == 'yes' ) ) {
						$datasetsSec['borderDash'] = array( 5, 5 );
					}

					if ( isset( $item['fillOpt'] ) && $item['fillOpt'] == 'yes' ) {
						$datasetsSec['fill'] = true;
					} else {
						$datasetsSec['fill'] = false;
					}

					if ( $type == 'line' || $type == 'radar' || $type == 'bubble' ) {
						if ( isset( $settings['customizePointStyles'] ) && $settings['customizePointStyles'] == 'yes' ) {
							if ( ! empty( $settings['pointStylesSelect'] ) ) {
								$datasetsSec['pointStyle'] = $settings['pointStylesSelect'];
							}
							if ( ! empty( $settings['pointBg'] ) && $type != 'bubble' ) {
								$datasetsSec['pointBackgroundColor'] = $settings['pointBg'];
							}
							if ( ! empty( $settings['pointNSize']['size'] ) && $type != 'bubble' ) {
								$datasetsSec['pointRadius'] = $settings['pointNSize']['size'];
							}
							if ( ! empty( $settings['pointHSize']['size'] ) && $type != 'bubble' ) {
								$datasetsSec['pointHoverRadius'] = $settings['pointHSize']['size'];
							}
							if ( ! empty( $settings['pointBorderWidth']['size'] ) && $type != 'bubble' ) {
								$datasetsSec['borderWidth'] = $settings['pointBorderWidth']['size'];
							}
							if ( ! empty( $settings['pointBorderColor'] ) && $type != 'bubble' ) {
								$datasetsSec['pointBorderColor'] = $settings['pointBorderColor'];
							}

							if ( $type == 'line' && ( isset( $settings['tension'] ) && $settings['tension'] == 'yes' ) ) {
								$datasetsSec['lineTension'] = 0.4;
							} else {
								$datasetsSec['lineTension'] = 0;
							}
						}
					}

					if ( ! empty( $type ) && ( $type == 'bar' || $type == 'horizontalBar' ) ) {
						if ( ! empty( $settings['barThickness']['size'] ) ) {
							/*space*/
							$datasetsSec['barThickness'] = $settings['barThickness']['size'];
						}
						if ( ! empty( $settings['maxbarThickness']['size'] ) ) {
							/*size*/
							$datasetsSec['maxbarThickness'] = $settings['maxbarThickness']['size'];
						}
					}

					$datasets[] = $datasetsSec;
				}
			}
			$scaleLabelXtext  = ! empty( $settings['scaleLabelXtext'] ) ? $settings['scaleLabelXtext'] : '';
			$scaleLabelXtextc = ! empty( $settings['scaleLabelXtextc'] ) ? $settings['scaleLabelXtextc'] : '';
			$scaleLabelYtext  = ! empty( $settings['scaleLabelYtext'] ) ? $settings['scaleLabelYtext'] : '';
			$scaleLabelYtextc = ! empty( $settings['scaleLabelYtextc'] ) ? $settings['scaleLabelYtextc'] : '';

			if ( $type == 'pie' ) {
				$getValues['cutoutPercentage'] = 0;
			} elseif ( $type == 'doughnut' ) {
				$getValues['cutoutPercentage'] = 50;
			} elseif ( isset( $settings['showGridLines'] ) && $settings['showGridLines'] == 'yes' ) {
					$getValues['scales'] = array(
						'yAxes' => array(
							array(
								'ticks'      => array(
									'display'   => ( isset( $settings['showLabels'] ) ) ? true : false,
									'fontColor' => $settings['showLabelsColor'],
									'fontSize'  => $settings['showLabelsSize']['size'],
								),
								'gridLines'  => array(
									'color'           => $settings['gridColor'],
									'zeroLineColor'   => $settings['zeroLinecolorY'],
									'drawBorder'      => ( ! empty( $settings['drawBorderY'] ) ) ? true : false,
									'drawOnChartArea' => ( ! empty( $settings['drawOnChartAreaY'] ) ) ? true : false,

								),
								'scaleLabel' => array(
									'display'     => true,
									'labelString' => $scaleLabelYtext,
									'fontColor'   => $scaleLabelYtextc,
								),
							),
						),
						'xAxes' => array(
							array(
								'ticks'      => array(
									'display'   => ( isset( $settings['showLabels'] ) ) ? true : false,
									'fontColor' => $settings['showLabelsColor'],
									'fontSize'  => $settings['showLabelsSize']['size'],
								),
								'gridLines'  => array(
									'color'           => $settings['gridColorXAxes'],
									'zeroLineColor'   => $settings['zeroLinecolorX'],
									'drawBorder'      => ( ! empty( $settings['drawBorderX'] ) ) ? true : false,
									'drawOnChartArea' => ( ! empty( $settings['drawOnChartAreaX'] ) ) ? true : false,
								),
								'scaleLabel' => array(
									'display'     => true,
									'labelString' => $scaleLabelXtext,
									'fontColor'   => $scaleLabelXtextc,
								),
							),
						),
					);
			} else {
				$getValues['scales'] = array(
					'yAxes' => array(
						array(
							'ticks'      => array(
								'display'   => isset( $settings['showLabels'] ) ? true : false,
								'fontColor' => $settings['showLabelsColor'],
								'fontSize'  => $settings['showLabelsSize']['size'],
							),
							'gridLines'  => array(
								'display' => false,
							),
							'scaleLabel' => array(
								'display'     => true,
								'labelString' => $scaleLabelYtext,
								'fontColor'   => $scaleLabelYtextc,
							),
						),
					),
					'xAxes' => array(
						array(
							'ticks'      => array(
								'display'   => isset( $settings['showLabels'] ) ? true : false,
								'fontColor' => $settings['showLabelsColor'],
								'fontSize'  => $settings['showLabelsSize']['size'],
							),
							'gridLines'  => array(
								'display' => false,
							),
							'scaleLabel' => array(
								'display'     => true,
								'labelString' => $scaleLabelXtext,
								'fontColor'   => $scaleLabelXtextc,
							),
						),
					),
				);
			}

			if ( isset( $settings['showLegend'] ) && $settings['showLegend'] == 'yes' ) {
				if ( ! empty( $settings['showLegendPosition'] ) ) {
					$getValues['legend'] = array(
						'position' => $settings['showLegendPosition'],
						'align'    => $settings['showLegendAlign'],
						'labels'   => array(
							'fontColor' => $settings['showLegendColor'],
							'fontSize'  => $settings['showLegendSize']['size'],
						),
					);
				}
			} else {
				$getValues['legend'] = array( 'display' => false );
			}

			if ( ! empty( $settings['customAnimation'] ) && ! empty( $settings['customAnimationDuration']['size'] ) ) {
				$getValues['animation'] = array(
					'duration' => $settings['customAnimationDuration']['size'],
					'easing'   => $settings['customAnimation'],
				);
			}

			if ( isset( $settings['showTooltip'] ) && $settings['showTooltip'] == 'yes' ) {
				if ( ! empty( $settings['tooltipBg'] ) || ! empty( $settings['tooltipColor'] ) || ! empty( $settings['tooltipBodyFontColor'] ) ) {
					$getValues['tooltips'] = array(
						'backgroundColor' => $settings['tooltipBg'],
						'titleFontColor'  => $settings['tooltipColor'],
						'bodyFontColor'   => $settings['tooltipBodyFontColor'],
						'titleFontSize'   => $settings['tooltipFontSize']['size'],
						'bodyFontSize'    => $settings['tooltipFontSize']['size'],
					);
				}
				if ( ! empty( $settings['tooltipEvent'] ) && $settings['tooltipEvent'] == 'click' ) {
					$getValues['events'] = array( 'click' );
				}
			} else {
				$getValues['tooltips'] = array( 'enabled' => false );
			}

			if ( isset( $settings['aspectRatio'] ) && $settings['aspectRatio'] == 'yes' ) {
				$getValues['aspectRatio'] = 1;
			}

			if ( empty( $settings['maintainAspectRatio'] ) ) {
				$getValues['maintainAspectRatio'] = false;
			}

			$this->add_render_attribute(
				array(
					'passAllValue' => array(
						'data-options' => array(
							wp_json_encode(
								array_filter(
									array(
										'type'    => $type,
										'data'    => array(
											'labels'   => explode( ',', $settings['mainLabel'] ),
											'datasets' => $datasets,
										),
										'options' => $getValues,
									)
								)
							),
						),
					),
				)
			);

			$output      = '<div class="eca-chart" data-id="' . esc_attr( uniqid( 'chart' ) ) . '" ' . $this->get_render_attribute_string( 'passAllValue' ) . '>';
				$output .= '<canvas id="' . uniqid( 'chart' ) . '"></canvas>';
			$output     .= '</div>';

			echo wp_kses_normalize_entities( $output );
		}
	}
}
