JavaScript upload file max size - javascript

I have to upload the code
this code for Datalife engine. How do I make the file size limit ~5Mb. And where to put the code? Sorry I'm bad speaking English. Thanks for help.
$allowed_extensions = array ("gif", "jpg", "png", "jpe", "jpeg" );
if ((isset($_FILES['post_add']) && $_FILES['post_add']!='')) {
$file_prefix = time() + rand( 1, 100 );
$file_prefix .= "_";
define( 'FOLDER_PREFIX', date( "Y-m" ) );
if( ! is_dir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX ) ) {
#mkdir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777 );
#chmod( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777 );
#mkdir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/thumbs", 0777 );
#chmod( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/thumbs", 0777 );
}
$config_path_image_upload = ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/";
$current_image = 'post_add';
$image = $_FILES[$current_image]['tmp_name'];
$image_name = $_FILES[$current_image]['name'];
$image_size = $_FILES[$current_image]['size'];
$error_code = $_FILES[$current_image]['error'];
$img_name_arr = explode( ".", $image_name );
$type = totranslit( end( $img_name_arr ) );
if( $image_name != "" ) {
$curr_key = key( $img_name_arr );
unset( $img_name_arr[$curr_key] );
$image_name = totranslit( implode( ".", $img_name_arr ) ) . "." . $type;
}
if ( in_array( strtolower( $type ), $allowed_extensions) ) {
#move_uploaded_file( $image, $config_path_image_upload . $file_prefix . $image_name );
if( #file_exists( $config_path_image_upload . $file_prefix . $image_name ) ) {
#chmod( $config_path_image_upload . $file_prefix . $image_name, 0666 );
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_images where author = '{$member_id[name]}' AND news_id = '$idpost'" );
if( ! $row['count'] ) {
$added_time = time() + ($config['date_adjust'] * 60);
$inserts = FOLDER_PREFIX . "/" . $file_prefix . $image_name;
$db->query( "INSERT INTO " . PREFIX . "_images (images, author, news_id, date) values ('$inserts', '{$member_id[name]}', '$idpost', '$added_time')" );
} else {
$row = $db->super_query( "SELECT images FROM " . PREFIX . "_images where author = '{$member_id[name]}' AND news_id = '$idpost'" );
if( $row['images'] == "" ) $listimages = array ();
else $listimages = explode( "|||", $row['images'] );
foreach ( $listimages as $dataimages ) {
if( $dataimages == FOLDER_PREFIX . "/" . $file_prefix . $image_name ) $error_image = "stop";
}
if( $error_image != "stop" ) {
$listimages[] = FOLDER_PREFIX . "/" . $file_prefix . $image_name;
$row['images'] = implode( "|||", $listimages );
$db->query( "UPDATE " . PREFIX . "_images set images='{$row['images']}' where author = '{$member_id[name]}' AND news_id = '$idpost'" );
}
}
include_once ENGINE_DIR . '/classes/thumb.class.php';
$tumb_ok = false;
$_POST['make_thumb'] = true;
$_POST['make_watermark'] = $config['allow_watermark'];
if( isset( $_POST['make_thumb'] ) ) {
$thumb = new thumbnail( $config_path_image_upload . $file_prefix . $image_name );
if( $thumb->size_auto( $config['max_image'], $_POST['t_seite'] ) ) {
$thumb->jpeg_quality( $config['jpeg_quality'] );
if( $config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
$thumb->save( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name );
}
if( #file_exists( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name ) ) $tumb_ok = true;
#chmod( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name, 0666 );
}
$config['max_up_side'] = intval( $config['max_up_side'] );
if( ($config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes") or $config['max_up_side'] ) {
$thumb = new thumbnail( $config_path_image_upload . $file_prefix . $image_name );
$thumb->jpeg_quality( $config['jpeg_quality'] );
if( $config['max_up_side'] ) $thumb->size_auto( $config['max_up_side'] );
if( $config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
$thumb->save( $config_path_image_upload . $file_prefix . $image_name );
}
$short_story = preg_replace('/^<br \/>(.*?)(<br \/>)*?$/is', '$1', $short_story);
if ( $tumb_ok ) $short_story = "<!--TBegin--><a href=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/{$file_prefix}{$image_name}\" onclick=\"return hs.expand(this)\" ><img align=\"left\" src=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/thumbs/{$file_prefix}{$image_name}\" alt='$title' title='$title' /></a><!--TEnd-->".$short_story;
else $short_story = "<img src=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/{$file_prefix}{$image_name}\" align=\"left\" alt='$title' title='$title' />".$short_story;
$full_story = "<img src=\"{$config['http_home_url']}uploads/posts/".FOLDER_PREFIX."/{$file_prefix}{$image_name}\" align=\"center\" alt='$title' title='$title' />".$full_story;
$short_story = addslashes($short_story);
$full_story = addslashes($full_story);
$db->query( "UPDATE " . PREFIX . "_post SET short_story='$short_story', full_story='$full_story' where id = '$idpost'" );
}
}
}
I wrote to google translate

why do you want to play around with your code while you can set it in admin cp? the option can be set in system settings for both files and images, the new version of DLE settings are moved to Usergroup Manager

Related

How can I get similar count of data

I want to get set if statement of no. of count of array from database. I already have a if statement checking the count but I am unable to use it in my file.
Help me replicate the count if statement here. I want to wrap pro_type and is_pro in if statement of no. of counts similar in reaferandearn page .
My function where I need if count statement :
users.php file
public function update_valid_refer_point($id){
global $db;
$user_balance = $db->where('id',$id)
->getOne('users',array('balance'));
$_POST['pro_type'] =4;
$_POST['is_pro'] =1;
$bal =$user_balance['balance']+500;
$updated = $db->where('id', $id)
->update('users', array('pro_type' => 4,'is_pro' => 1,'balance' => $bal));
return TRUE;
}
The file where I have similar if count statement but I have no idea how to use it above :
referandearn.php
if(count($data['refferal_data']['data']) > 0){
for($u=0; $u<count($data['refferal_data']['data']);$u++){
$userFirstName = $data['refferal_data']['data'][$u]->first_name;
$userLastName = $data['refferal_data']['data'][$u]->last_name;
$userName = $userFirstName.' '.$userLastName;
$userProfilePhoto = $data['refferal_data']['data'][$u]->avater;
$refferalDate = date('d - M - Y',strtotime($data['refferal_data']['data'][$u]->refferalDate));
$userRefferalCode = $data['refferal_data']['data'][$u]->refferalCode;
?>
<li>
<img src="<?php echo $userProfilePhoto;?>" width="75" height="75" viewBox="0 0 24 24" style="margin-right: 15px; border-radius: 50%;"/>
<?php echo $userName."<br>".$refferalDate;?>
</li>
<?php
}
}else{
?>
<li>
<?php echo 'No reffered user yet';?>
</li>
<?php
}
?>
referandearn controller :
Class Referearn extends Theme {
public static function LoadreffralUsers() {
global $_AJAX, $_CONTROLLERS;
$data = '';
$ajax_class = realpath($_CONTROLLERS . 'aj.php');
$ajax_class_file = realpath($_AJAX . 'loadmore.php');
if (file_exists($ajax_class_file)) {
require_once $ajax_class;
require_once $ajax_class_file;
$_POST['page'] = 1;
$loadmore = new Loadmore();
$refferal_users = $loadmore->refferal_users();
parent::$data['refferal_data'] = $refferal_users;
/*if (isset($refferal_users['html'])) {
$data = $refferal_users['html'];
}*/
}
return $data;
}
}
And loadmore referusers function :
function refferal_users() {
global $db, $_BASEPATH, $_DS,$_excludes;
if (self::ActiveUser() == NULL) {
return array(
'status' => 403,
'message' => __('Forbidden')
);
}
$error = '';
$page = 0;
$perpage = 7;
$html = '';
$html_imgs = '';
$template = '';
if (isset($_POST) && !empty($_POST)) {
if (isset($_POST[ 'page' ]) && (!is_numeric($_POST[ 'page' ]) || empty($_POST[ 'page' ]))) {
$error = '<p>• ' . __('no page number found.') . '</p>';
} else {
$page = (int) Secure($_POST[ 'page' ]) - 1;
}
}
if ($error == '') {
$limit = $perpage;
$offset = $page * $perpage;
//$query = GetRefferalUserQuery(self::ActiveUser()->id, $limit, $offset);
//exit;
//$refferal_users = $db->rawQuery($query);
$sql = 'SELECT U.id,U.online,U.lastseen,U.username,U.avater,U.country,U.first_name,U.last_name,U.location,U.birthday,U.language,U.relationship,U.height,U.body,U.smoke,U.ethnicity,U.pets,U.gender, RU.refferalDate, RU.refferalCode FROM users U INNER JOIN refferalusers RU ON RU.refferalBy = U.id ';
$sql .= ' WHERE RU.refferalTo = '.self::ActiveUser()->id.' AND ( ';
$sql .= ' U.verified = "1" AND U.privacy_show_profile_random_users = "1" ';
// to exclude blocked users
$notin = ' AND U.id NOT IN (SELECT block_userid FROM blocks WHERE user_id = '.self::ActiveUser()->id.') ';
// to exclude liked and disliked users users
$notin .= ' AND U.id NOT IN (SELECT like_userid FROM likes WHERE ( user_id = '.self::ActiveUser()->id.' OR like_userid = '.self::ActiveUser()->id.' ) ) ';
$sql .= ' ) ';
$sql .= ' ORDER BY U.id DESC LIMIT '.$limit.' OFFSET '.$offset.';';
$random_users = $db->objectBuilder()->rawQuery($sql);
$theme_path = $_BASEPATH . 'themes' . $_DS . self::Config()->theme . $_DS;
//$template = $theme_path . 'partails' . $_DS . 'find-matches' . $_DS . 'random_users.php';
//$template1 = $theme_path . 'partails' . $_DS . 'find-matches' . $_DS . 'matches_imgs.php';
if (file_exists($template)) {
foreach ($random_users as $random_user) {
if($random_user->id!=(int)auth()->id){
ob_start();
require($template);
$html .= ob_get_contents();
ob_end_clean();
}
}
}
return array(
'status' => 200,
'page' => $page + 2,
'html' => $html,
'data' => $random_users
);
} else {
return array(
'status' => 400,
'message' => $error
);
}
}

How to call similar variables in php

I want to get set if statement of no. of count of array from database. I already have a if statement checking the count but I am unable to use it in my file.
Help me replicate the count if statement here. I want to wrap pro_type and is_pro in if statement of no. of counts similar in reaferandearn page .
My function where I need if count statement :
users.php file
public function update_valid_refer_point($id){
global $db;
$user_balance = $db->where('id',$id)
->getOne('users',array('balance'));
$_POST['pro_type'] =4;
$_POST['is_pro'] =1;
$bal =$user_balance['balance']+500;
$updated = $db->where('id', $id)
->update('users', array('pro_type' => 4,'is_pro' => 1,'balance' => $bal));
return TRUE;
}
The file where I have similar if count statement but I have no idea how to use it above :
referandearn.php
if(count($data['refferal_data']['data']) > 0){
<?php
}>
referandearn controller :
Class Referearn extends Theme {
public static function LoadreffralUsers() {
global $_AJAX, $_CONTROLLERS;
$data = '';
$ajax_class = realpath($_CONTROLLERS . 'aj.php');
$ajax_class_file = realpath($_AJAX . 'loadmore.php');
if (file_exists($ajax_class_file)) {
require_once $ajax_class;
require_once $ajax_class_file;
$_POST['page'] = 1;
$loadmore = new Loadmore();
$refferal_users = $loadmore->refferal_users();
parent::$data['refferal_data'] = $refferal_users;
/*if (isset($refferal_users['html'])) {
$data = $refferal_users['html'];
}*/
}
return $data;
}
}
And loadmore referusers function :
function refferal_users() {
global $db, $_BASEPATH, $_DS,$_excludes;
if (self::ActiveUser() == NULL) {
return array(
'status' => 403,
'message' => __('Forbidden')
);
}
$error = '';
$page = 0;
$perpage = 7;
$html = '';
$html_imgs = '';
$template = '';
if (isset($_POST) && !empty($_POST)) {
if (isset($_POST[ 'page' ]) && (!is_numeric($_POST[ 'page' ]) || empty($_POST[ 'page' ]))) {
$error = '<p>• ' . __('no page number found.') . '</p>';
} else {
$page = (int) Secure($_POST[ 'page' ]) - 1;
}
}
if ($error == '') {
$limit = $perpage;
$offset = $page * $perpage;
//$query = GetRefferalUserQuery(self::ActiveUser()->id, $limit, $offset);
//exit;
//$refferal_users = $db->rawQuery($query);
$sql = 'SELECT U.id,U.online,U.lastseen,U.username,U.avater,U.country,U.first_name,U.last_name,U.location,U.birthday,U.language,U.relationship,U.height,U.body,U.smoke,U.ethnicity,U.pets,U.gender, RU.refferalDate, RU.refferalCode FROM users U INNER JOIN refferalusers RU ON RU.refferalBy = U.id ';
$sql .= ' WHERE RU.refferalTo = '.self::ActiveUser()->id.' AND ( ';
$sql .= ' U.verified = "1" AND U.privacy_show_profile_random_users = "1" ';
// to exclude blocked users
$notin = ' AND U.id NOT IN (SELECT block_userid FROM blocks WHERE user_id = '.self::ActiveUser()->id.') ';
// to exclude liked and disliked users users
$notin .= ' AND U.id NOT IN (SELECT like_userid FROM likes WHERE ( user_id = '.self::ActiveUser()->id.' OR like_userid = '.self::ActiveUser()->id.' ) ) ';
$sql .= ' ) ';
$sql .= ' ORDER BY U.id DESC LIMIT '.$limit.' OFFSET '.$offset.';';
$random_users = $db->objectBuilder()->rawQuery($sql);
$theme_path = $_BASEPATH . 'themes' . $_DS . self::Config()->theme . $_DS;
//$template = $theme_path . 'partails' . $_DS . 'find-matches' . $_DS . 'random_users.php';
//$template1 = $theme_path . 'partails' . $_DS . 'find-matches' . $_DS . 'matches_imgs.php';
if (file_exists($template)) {
foreach ($random_users as $random_user) {
if($random_user->id!=(int)auth()->id){
ob_start();
require($template);
$html .= ob_get_contents();
ob_end_clean();
}
}
}
return array(
'status' => 200,
'page' => $page + 2,
'html' => $html,
'data' => $random_users
);
} else {
return array(
'status' => 400,
'message' => $error
);
}
}

WP_NAV_MENU does not work including my #Media Queries

** Original Navbar**
*This is the structure of my actual navbar which includes a hamburger menu dropdown in mobile size. This doesn't work anymore when I try to make my own custom theme in Wordpress. Somehow the css works partly but the function does not use my JavaScript.
I tried a walker menu (see below) but it still does not work. *
<nav class="navbar">
<div class="container">
<h1 class="logo"> <?php the_title(); ?> </h1>
<div class="hamburger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
<ul class="nav">
<li>Home</li>
<li>About</li>
<li>Location</li>
</ul>
</div>
</nav>
Here my funcions.php
function demo1_menus(){
$locations= array(
'primary' => 'Desktop primary top navbar',
'footer' => 'Footer Menu items'
);
register_nav_menus($locations);
}
add_action('init', 'demo1_menus');
Here my header.php
<?php
wp_nav_menu(
array(
'menu' => 'primary',
'container' => '',
'theme_location' => 'primary',
'items_wrap' => '<ul id="" class="nav">%3$s</ul>',
'walker' => new Demo1_Walker_Nav_Primary()
)
);
?>
Here the walker
Can someone tell me why its not working or provide me another solution to my problem please*
<?php
class Demo1_Walker_Nav_Primary extends Walker_Nav_Menu{
function start_lvl( $output, $depth ){
$indent = str_repeat("\t", $depth );
$submenu =($depth > 0) ? 'sub-menu' : '';
$output .= "\n$indent<ul class=\"nav$submenu depth_$depth\">\n";
}
function start_el( &$output, $item, $depth=0, $args = array(), $id=0 ){
$indent = ( $depth) ? str_repeat( "\t", $depth ) : '';
$li_attributes = '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = ($args->has_children) ? 'nav' : '';
$classes[] = ($item->current || $item->current_item_anchestor) ? 'active': '';
$classes[] = 'menu-item-' . $item->ID;
if($depth && $args->has_children){
$classes[] = 'nav li';
}
$class_names = join(' ',apply_filter('nav_menu_css_class', array_filter($classes ), $item, $args) );
$class_names = ' class="' . esc_attr($class_names) . '"';
$id =apply_filter('nav_menu_item_id', 'menu-item-'.$item->ID, $item, $args);
$id = strlen($id) ? 'id="' . esc_attr($id) . '"' : '';
$output .= $indent . '<li' . $id . $value . $class_names . '>';
// Link attributes.
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$attributes .= ' class="nav' . ( $depth > 0 ? 'line1' : 'line2' ) . '"';
// Build HTML output and pass through the proper filter.
$item_output = sprintf( '%1$s<a%2$s>%3$s%4$s%5$s</a>%6$s',
$args->before,
$attributes,
$args->link_before,
apply_filters( 'the_title', $item->title, $item->ID ),
$args->link_after,
$args->after
);
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= "</li>\n";
}
}
}
?>

Modify DOM and replace mail addresses

I would like to make use of Simple HTML DOM parser to search for mail-adresses in the content of a html-site and replace them.
The replacement contains a span element and a little bit JS (this should obfuscate the addresses.
At the moment this works as follows:
$pattern =
"/(?:[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")#(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/";
preg_match_all( $pattern, $content, $matches );
foreach ( $matches[ 0 ] as $email ) {
$content = $this->searchDOM(
$content,
$email,
$this->hide_email($email)
);
}
This is the searchDOM-method:
private function searchDOM( $content, $search, $replace, $excludedParents = [] )
{
$dom = HtmlDomParser::str_get_html(
$content,
true,
true,
DEFAULT_TARGET_CHARSET,
false,
DEFAULT_BR_TEXT,
DEFAULT_SPAN_TEXT
);
foreach ( $dom->find( 'text' ) as $element ) {
if ( !in_array( $element->parent()->tag, $excludedParents ) ) {
$element->innertext = preg_replace(
'/(?<!\w)' . preg_quote( $search, "/" ) . '(?!\w)/i',
$replace,
$element->innertext
);
}
}
return $dom->save();
}
and this is the hide_email-method:
function hide_email( $email )
{
$character_set = '+-.0123456789#ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
$key = str_shuffle( $character_set );
$cipher_text = '';
$id = 'e' . rand( 1, 999999999 );
for ( $i = 0; $i < strlen( $email ); $i += 1 )
$cipher_text .= $key[ strpos( $character_set, $email[ $i ] ) ];
$script = 'var a="' . $key . '";var b=a.split("").sort().join("");var c="' . $cipher_text . '";var d="";';
$script .= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
$script .= 'document.getElementById("' . $id . '").innerHTML=""+d+""';
$script = "eval(\"" . str_replace( [ "\\", '"' ], [ "\\\\", '\"' ], $script ) . "\")";
$script = '<script type="text/javascript">/*<![CDATA[*/' . $script . '/*]]>*/</script>';
return '<span id="' . $id . '">[javascript protected email address]</span>' . $script;
}
Well - this is not working as expected, because the rendered page shows only "[javascript protected email address]". If I have a look at the source, the a-tag is missing.

Chart.js Start Y-Axis at a defined value

A Plugin that I use on my website use Chart.js
I try to start Y-Axis at a defined value.
Here's a picture of what I have now :
Line Chart
the javascript code :
(function() {
Chart.types.Line.extend({
name:'UncontinuousLine',
defaults:{scaleBeginAtZero:false},
initialize:function(data) {
Chart.types.Line.prototype.initialize.apply(this,arguments);
},
draw:function() {
Chart.types.Line.prototype.draw.apply(this,arguments);
var ctx=this.chart.ctx;
this.datasets.forEach(function(ds) {
ctx.strokeStyle=ds.strokeColor;
var prevPt={value:2.49};
ds.points.forEach(function(curPt) {
if(parseInt(curPt.value)<=0) {
curPt.value=prevPt.value;
}
if(parseInt(curPt.value)>0&&parseInt(prevPt.value)>0) {
ctx.beginPath();
ctx.moveTo(prevPt.x,prevPt.y);
ctx.lineTo(curPt.x,curPt.y);
ctx.stroke();
}
prevPt=curPt;
});
});
}
});})();
and the php code :
private function _create_uncontinuousline_chart( $data, $opt ){
if ( empty( $data ) ){
return '';
}
$id = self::_get_canvas_id( $this->count );
$sets = self::_parse_data( $data, 3 );
$cd = self::_resort_sets( $sets, true );
$this->js[] = 'new Chart(' . "jQuery('#$id').get(0).getContext('2d')" . ')
.UncontinuousLine(' . AimyChartsContentPluginHelper::phpva_json_encode( $cd ) . ','
. '{' . 'animation: ' . ( $opt[ 'animate' ] ? 'true' : 'false' ) . ','
. 'multiTooltipTemplate: ' . '"<%= value %> (<%= datasetLabel %>)"'
. ',responsive: ' . ( $opt[ 'responsive' ] ? 'true' : 'false' )
. ',datasetStrokeWidth:0.01' . '}' . ');';
return self::_get_canvas( 'UncontinuousLine', $this->count, $opt );
}
I've tried many things but impossible to start my y-axis at 1 for example...
Does someone know how i can do that ?
In your options, use this:
scaleBeginAtZero : false,
scaleOverride: true,
scaleStartValue: 1,
Try this for your php code:
private function _create_uncontinuousline_chart( $data, $opt ){
if ( empty( $data ) ){
return '';
}
$id = self::_get_canvas_id( $this->count );
$sets = self::_parse_data( $data, 3 );
$cd = self::_resort_sets( $sets, true );
$this->js[] = 'new Chart(' . "jQuery('#$id').get(0).getContext('2d')" . ')
.UncontinuousLine(' . AimyChartsContentPluginHelper::phpva_json_encode( $cd ) . ','
. '{' . 'animation: ' . ( $opt[ 'animate' ] ? 'true' : 'false' )
. ',multiTooltipTemplate: ' . '"<%= value %> (<%= datasetLabel %>)"'
. ',responsive: ' . ( $opt[ 'responsive' ] ? 'true' : 'false' )
. ',datasetStrokeWidth:0.01'
. ',scaleBeginAtZero : false'
. ',scaleOverride: true'
. ',scaleStartValue: 1'
. '}' . ');';
return self::_get_canvas( 'UncontinuousLine', $this->count, $opt );

Categories

Resources