Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dchart-bar-acute-angle

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dchart-bar-acute-angle - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

89

index.js

@@ -1,2 +0,1 @@

require('./default.css');
//var Bar = require('../../barCustom');

@@ -9,9 +8,16 @@ var Bar = require('dchart-core/bar/barCustom');

var opt = {
xaxis : {
type : 'category',
xaxis: {
type: 'category',
dy: 10,
key: 'x'
},
yaxis : {}
yaxis: {
key: 'y'
},
background: {
show: true,
color: '#444'
}
};
_.deepMerge(opt, options);
opt = _.deepMerge(opt, options);
Bar.call(this, container, opt);

@@ -21,3 +27,41 @@ }

barAcuteAngle = Bar.extend(barAcuteAngle, {
beforeRender : function () {
afterCore: function () {
//背景部分
var opt = this.options,
xAxis = this.getComs('axis', 'xaxis'),
yAxis = this.getComs('axis', 'yaxis'),
xAxisScale = xAxis.getX(),
yAxisScale = yAxis.getX(),
xKey = opt.xaxis.key,
yKey = opt.yaxis.key,
maxLength = _.maxBy(this._data, function (item) {
return item[yKey].length
})[yKey].length,
xAxisRangeBandsScale = xAxis.calGroupStep(opt.groupLabel || maxLength); // c -> 最多的数据列
var bars = this.series.selectAll('.series-group').selectAll(".serie-single");
bars.each(function (data, i) {
var that = d3.select(this);
var bg = that.select('.serie-bg')[0][0] && that.select('.serie-bg') || that.insert('rect', '.serie').attr('class', 'serie-bg');
bg.attr({
'x' : function (d) {
return xAxisScale(data[xKey]) + xAxisRangeBandsScale(i);
},
'y' : 0,
'width' : xAxisRangeBandsScale.rangeBand(),
'height' : maxLength < 3 ? yAxisScale(data[yKey]) : opt.innerHeight
}).style({
fill: opt.background.color || '#000',
display: opt.background.show && 'block' || 'none'
})
});
},
afterRender : function () {
Bar.prototype.afterRender.call(this);
this.afterCore();
},
updateAfterRender : function () {
Bar.prototype.updateAfterRender.call(this);
this.afterCore();
},
beforeRender: function () {
Bar.prototype.beforeRender.call(this);

@@ -27,20 +71,21 @@ var opt = this.options;

var ykey = opt.yaxis.key;
var data = this.data();
var maxLength = _.maxBy(data, function (item) {
return item[ykey].length
})[ykey].length;
opt.customPos = function (pos, i, type) {
if (type === 0) {
var x = pos[0][xkey];
var y = pos[3][ykey];
pos[0] = {
x: x,
y: y - (opt && opt.slope || 10)
};
} else if (type === 1) {
var x = pos[2][xkey];
var y = pos[0][ykey];
pos[3] = {
x: x,
y: y - (opt && opt.slope || 10)
};
if(maxLength === 2) {
var slope = (opt && (typeof opt.slope != 'undefined' && (opt.slope >= 0 ? opt.slope : 0)) || 10);
// 条形的高度
var barHeight = Math.abs(pos[1][ykey] - pos[0][ykey]);
// 如果条形高度小于底部三角高度,则三角高度为条形高度
if (barHeight < slope) {
slope = barHeight;
}
if (type === 0) {
pos[0][ykey] -= slope;
} else if (type === this._data[i].y.length - 1) {
pos[3][ykey] -= slope;
}
}
pos[1][ykey] -= (opt && opt.slope || 10)
pos[2][ykey] -= (opt && opt.slope || 10)
return pos;

@@ -47,0 +92,0 @@ }

{
"name": "dchart-bar-acute-angle",
"version": "0.1.2",
"version": "0.1.3",
"main" : "index.js",

@@ -12,4 +12,4 @@ "author": {

"d3": "~3.5.6",
"dchart-core": "1.4.3"
"dchart-core": "2.0.36"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc