dominus77/yii2-svg-widget
Composer 安装命令:
composer require dominus77/yii2-svg-widget
包简介
The lightweight library for manipulating and animating SVG for Yii2
关键字:
README 文档
README
The lightweight library for manipulating and animating SVG for Yii2.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist dominus77/yii2-svg-widget "*"
or add
"dominus77/yii2-svg-widget": "*"
to the require section of your composer.json file.
Usage
Once the extension is installed, simply use it in your code by:
<div id="drawing"></div>
<?php \dominus77\svg\SvgWidget::widget([
'elementId' => 'drawing',
'clientScript' => new \yii\web\JsExpression("
draw.rect(100, 100).move(100, 50).fill('#f06');
"),
]); ?>
Example:
Get demo data
<?php
$fileName = 'russia'; // russia or world
$file = Yii::getAlias('@dominus77/svg/example') . "/" . $fileName . ".json";
$data = file_get_contents($file);
?>
Render map
<div id="svg_map_russia"></div>
<?php \dominus77\svg\SvgWidget::widget([
'elementId' => 'svg_map_russia',
'clientScript' => new \yii\web\JsExpression("
var data = {$data};
var mapDraw = draw.size(1000, 550);
// draw individual data
for(var i = 0, il = data.length; i < il; i++){
mapDraw.path(data[i]['d'])
.fill('none')
.stroke({color: data[i]['stroke'], width: data[i]['stroke-width']});
}
"),
]); ?>
Render interactive map
<div style="position: absolute" id="info"></div>
<div style="border:1px solid #ccc; width:502px;" id="svg_interactive_map_russia"></div>
<?php \dominus77\svg\SvgWidget::widget([
'elementId' => 'svg_interactive_map_russia',
'panZoom' => true, // on svg.panzoom.js plugin
'clientScript' => new \yii\web\JsExpression("
var data = {$data};
var info = document.getElementById('info');
// color region
var colorOut = '#fff';
var colorOver = '#ccc';
// create draw
var mapDraw = draw.size(500, 300).viewbox(0, 0, 1000, 550);
// svg.panzoom.js plugin
mapDraw.panZoom({zoomMin: 0.5, zoomMax: 20});
mapDraw.zoom(0.5)
.animate()
.zoom(2, {x:50, y:280});
// draw individual data
for(var i = 0, il = data.length; i < il; i++) {
var region = mapDraw.path(data[i]['d'])
.id(data[i]['id'])
.fill(colorOut)
.style('cursor', 'pointer')
.stroke({color: data[i]['stroke'], width: data[i]['stroke-width']});
// add attribute title in path
var title = data[i]['title'];
region.attr({title: title});
region.mouseover(function(e) {
var elem = document.getElementById(e.target.id);
var title = elem.getAttribute('title');
info.innerHTML = e.target.id + ' - ' + title;
this.fill({color: colorOver});
});
region.mouseout(function(e) {
this.fill({color: colorOut});
info.innerHTML = '';
});
region.click(function(e) {
var elem = document.getElementById(e.target.id);
var title = elem.getAttribute('title');
console.log(e.target.id + ' - ' + title);
});
}
"),
]); ?>
More Information
Please, check the SVG.js
License
The BSD License (BSD). Please see License File for more information.
dominus77/yii2-svg-widget 适用场景与选型建议
dominus77/yii2-svg-widget 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「widget」 「svg」 「yii2」 「Dominus77」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dominus77/yii2-svg-widget 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dominus77/yii2-svg-widget 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dominus77/yii2-svg-widget 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
PHP class to add Font Awesome 5+'s SVG icons inline without Javascript.
Utility functions to inline SVGs in PHP Projects
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 52
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-12-16