| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
| [`borderSkipped`](#borderskipped) | `string` | Yes | Yes | `'bottom'`
| [`borderWidth`](#borderwidth) | <code>number|object</code> | Yes | Yes | `0`
+| [`clip`](#general) | <code>number|object</code> | - | - | `undefined`
| [`data`](#data-structure) | `object[]` | - | - | **required**
| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | - | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | - | Yes | `undefined`
| Name | Description
| ---- | ----
+| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
| `label` | The label for the dataset which appears in the legend and tooltips.
| `order` | The drawing order of dataset. Also affects order for stacking, tooltip, and legend.
| `xAxisID` | The ID of the x axis to plot this dataset on.
| `borderColor` | The bar border color.
| [`borderSkipped`](#borderskipped) | The edge to skip when drawing bar.
| [`borderWidth`](#borderwidth) | The bar border width (in pixels).
+| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
All these values, if `undefined`, fallback to the associated [`elements.rectangle.*`](../configuration/elements.md#rectangle-configuration) options.
| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
| [`borderWidth`](#styling) | `number` | Yes | Yes | `3`
+| [`clip`](#general) | <code>number|object</code> | - | - | `undefined`
| [`data`](#data-structure) | `object[]` | - | - | **required**
| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| Name | Description
| ---- | ----
+| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
| `label` | The label for the dataset which appears in the legend and tooltips.
| `order` | The drawing order of dataset.
| [`borderAlign`](#border-alignment) | `string` | Yes | Yes | `'center'`
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'#fff'`
| [`borderWidth`](#styling) | `number` | Yes | Yes | `2`
+| [`clip`](#general) | <code>number|object</code> | - | - | `undefined`
| [`data`](#data-structure) | `number[]` | - | - | **required**
| [`hoverBackgroundColor`](#interations) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `undefined`
| [`weight`](#styling) | `number` | - | - | `1`
+### General
+
+| Name | Description
+| ---- | ----
+| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
+
+
### Styling
The style of each arc can be controlled with the following properties:
| [`borderDashOffset`](#line-styling) | `number` | Yes | - | `0.0`
| [`borderJoinStyle`](#line-styling) | `string` | Yes | - | `'miter'`
| [`borderWidth`](#line-styling) | `number` | Yes | - | `3`
+| [`clip`](#general) | <code>number|object</code> | - | - | `undefined`
| [`cubicInterpolationMode`](#cubicinterpolationmode) | `string` | Yes | - | `'default'`
| [`fill`](#line-styling) | <code>boolean|string</code> | Yes | - | `true`
| [`hoverBackgroundColor`](#line-styling) | [`Color`](../general/colors.md) | Yes | - | `undefined`
| Name | Description
| ---- | ----
+| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
| `label` | The label for the dataset which appears in the legend and tooltips.
| `order` | The drawing order of dataset. Also affects order for stacking, tooltip, and legend.
| `xAxisID` | The ID of the x axis to plot this dataset on.
| [`borderAlign`](#border-alignment) | `string` | Yes | Yes | `'center'`
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'#fff'`
| [`borderWidth`](#styling) | `number` | Yes | Yes | `2`
+| [`clip`](#general) | <code>number|object</code> | - | - | `undefined`
| [`data`](#data-structure) | `number[]` | - | - | **required**
| [`hoverBackgroundColor`](#interations) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `undefined`
+### General
+
+| Name | Description
+| ---- | ----
+| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
+
### Styling
The style of each arc can be controlled with the following properties:
| [`hoverBorderDashOffset`](#line-styling) | `number` | Yes | - | `undefined`
| [`hoverBorderJoinStyle`](#line-styling) | `string` | Yes | - | `undefined`
| [`hoverBorderWidth`](#line-styling) | `number` | Yes | - | `undefined`
+| [`clip`](#general) | <code>number|object</code> | - | - | `undefined`
| [`fill`](#line-styling) | <code>boolean|string</code> | Yes | - | `true`
| [`label`](#general) | `string` | - | - | `''`
| [`order`](#general) | `number` | - | - | `0`
| Name | Description
| ---- | ----
+| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
| `label` | The label for the dataset which appears in the legend and tooltips.
| `order` | The drawing order of dataset.
return parsed;
},
+ /**
+ * @private
+ */
+ _getMaxOverflow: function() {
+ var me = this;
+ var meta = me._cachedMeta;
+ var data = meta.data || [];
+ if (!data.length) {
+ return false;
+ }
+ var firstPoint = data[0].size();
+ var lastPoint = data[data.length - 1].size();
+ return Math.max(firstPoint, lastPoint) / 2;
+ },
+
/**
* @protected
*/
return values;
},
+ /**
+ * @private
+ */
+ _getMaxOverflow: function() {
+ var me = this;
+ var meta = me._cachedMeta;
+ var data = meta.data || [];
+ if (!data.length) {
+ return false;
+ }
+ var border = me._showLine ? meta.dataset._model.borderWidth : 0;
+ var firstPoint = data[0].size();
+ var lastPoint = data[data.length - 1].size();
+ return Math.max(border, firstPoint, lastPoint) / 2;
+ },
+
updateBezierControlPoints: function() {
var me = this;
var chart = me.chart;
var area = chart.chartArea;
var i = 0;
var ilen = points.length;
- var halfBorderWidth;
if (me._showLine) {
- halfBorderWidth = (meta.dataset._model.borderWidth || 0) / 2;
-
- helpers.canvas.clipArea(chart.ctx, {
- left: area.left - halfBorderWidth,
- right: area.right + halfBorderWidth,
- top: area.top - halfBorderWidth,
- bottom: area.bottom + halfBorderWidth
- });
meta.dataset.draw();
-
- helpers.canvas.unclipArea(chart.ctx);
}
// Draw the points
*/
drawDataset: function(meta, easingValue) {
var me = this;
+ var ctx = me.ctx;
+ var clip = meta._clip;
+ var canvas = me.canvas;
+ var area = me.chartArea;
var args = {
meta: meta,
index: meta.index,
return;
}
+ helpers.canvas.clipArea(ctx, {
+ left: clip.left === false ? 0 : area.left - clip.left,
+ right: clip.right === false ? canvas.width : area.right + clip.right,
+ top: clip.top === false ? 0 : area.top - clip.top,
+ bottom: clip.bottom === false ? canvas.height : area.bottom + clip.bottom
+ });
+
meta.controller.draw(easingValue);
+ helpers.canvas.unclipArea(ctx);
+
plugins.notify(me, 'afterDatasetDraw', [args]);
},
});
}
+
+function scaleClip(scale, allowedOverflow) {
+ var tickOpts = scale && scale.options.ticks || {};
+ var reverse = tickOpts.reverse;
+ var min = tickOpts.min === undefined ? allowedOverflow : 0;
+ var max = tickOpts.max === undefined ? allowedOverflow : 0;
+ return {
+ start: reverse ? max : min,
+ end: reverse ? min : max
+ };
+}
+
+function defaultClip(xScale, yScale, allowedOverflow) {
+ if (allowedOverflow === false) {
+ return false;
+ }
+ var x = scaleClip(xScale, allowedOverflow);
+ var y = scaleClip(yScale, allowedOverflow);
+
+ return {
+ top: y.end,
+ right: x.end,
+ bottom: y.start,
+ left: x.start
+ };
+}
+
+function toClip(value) {
+ var t, r, b, l;
+
+ if (helpers.isObject(value)) {
+ t = value.top;
+ r = value.right;
+ b = value.bottom;
+ l = value.left;
+ } else {
+ t = r = b = l = value;
+ }
+
+ return {
+ top: t,
+ right: r,
+ bottom: b,
+ left: l
+ };
+}
+
/**
* Removes the given array event listener and cleanup extra attached properties (such as
* the _chartjs stub and overridden methods) if array doesn't have any more listeners.
return applyStack(stack, value, meta.index);
},
+ /**
+ * @private
+ */
_getMinMax: function(scale, canStack) {
var chart = this.chart;
var meta = this._cachedMeta;
};
},
+ /**
+ * @private
+ */
_getAllParsedValues: function(scale) {
var meta = this._cachedMeta;
var metaData = meta.data;
return values;
},
+ /**
+ * @private
+ */
_cacheScaleStackStatus: function() {
var me = this;
var indexScale = me._getIndexScale();
}
},
+ /**
+ * @private
+ */
_scaleCheck: function() {
var me = this;
var indexScale = me._getIndexScale();
cache[valueScale.id] !== valueScale.options.stacked;
},
+ /**
+ * @private
+ */
+ _getMaxOverflow: function() {
+ return false;
+ },
+
_update: function(reset) {
var me = this;
me._configure();
me._cachedDataOpts = null;
me.update(reset);
+ me._cachedMeta._clip = toClip(helpers.valueOrDefault(me._config.clip, defaultClip(me._xScale, me._yScale, me._getMaxOverflow())));
me._cacheScaleStackStatus();
},
};
}
+ size() {
+ var vm = this._view;
+ var radius = vm.radius || 0;
+ var borderWidth = vm.borderWidth || 0;
+ return (radius + borderWidth) * 2;
+ }
+
tooltipPosition() {
var vm = this._view;
return {
--- /dev/null
+module.exports = {
+ config: {
+ type: 'line',
+ data: {
+ labels: [0, 5, 10, 15, 20, 25, 30, 50, 55, 60],
+ datasets: [{
+ data: [6, 11, 10, 10, 3, 22, 7, 24],
+ type: 'bubble',
+ label: 'test',
+ borderColor: '#3e95cd',
+ fill: false
+ }]
+ },
+ options: {
+ legend: false,
+ scales: {
+ xAxes: [{ticks: {display: false}}],
+ yAxes: [{
+ ticks: {
+ display: false,
+ min: 8,
+ max: 25,
+ beginAtZero: true
+ }
+ }]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 256
+ }
+ }
+};
{"x": 9, "y": 2}
],
"backgroundColor": "transparent",
- "borderColor": "0000ff",
+ "borderColor": "#0000ff",
"borderWidth": 0,
"pointStyle": [
"circle",
--- /dev/null
+{
+ "config": {
+ "type": "scatter",
+ "data": {
+ "datasets": [{
+ "borderColor": "red",
+ "data": [{"x":-5,"y":5},{"x":-4,"y":6},{"x":-3,"y":7},{"x":-2,"y":6},{"x":-1,"y":5},{"x":0,"y":4},{"x":1,"y":3},{"x":2,"y":2},{"x":3,"y":5},{"x":4,"y":7},{"x":5,"y":9}],
+ "fill": false,
+ "showLine": true,
+ "borderWidth": 20,
+ "pointRadius": 0
+ }]
+ },
+ "options": {
+ "responsive": false,
+ "legend": false,
+ "title": false,
+ "scales": {
+ "xAxes": [{
+ "ticks": {
+ "max": 3,
+ "display": false
+ }
+ }],
+ "yAxes": [{"ticks": {"display": false}}]
+ },
+ "layout": {
+ "padding": 24
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}
--- /dev/null
+{
+ "config": {
+ "type": "scatter",
+ "data": {
+ "datasets": [{
+ "borderColor": "red",
+ "data": [{"x":-5,"y":5},{"x":-4,"y":6},{"x":-3,"y":7},{"x":-2,"y":6},{"x":-1,"y":5},{"x":0,"y":4},{"x":1,"y":3},{"x":2,"y":2},{"x":3,"y":5},{"x":4,"y":7},{"x":5,"y":9}],
+ "fill": false,
+ "showLine": true,
+ "borderWidth": 20,
+ "pointRadius": 0
+ }]
+ },
+ "options": {
+ "responsive": false,
+ "legend": false,
+ "title": false,
+ "scales": {
+ "xAxes": [{
+ "ticks": {
+ "min": -2,
+ "display": false
+ }
+ }],
+ "yAxes": [{"ticks": {"display": false}}]
+ },
+ "layout": {
+ "padding": 24
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}
--- /dev/null
+{
+ "config": {
+ "type": "scatter",
+ "data": {
+ "datasets": [{
+ "borderColor": "red",
+ "data": [{"x":-5,"y":5},{"x":-4,"y":6},{"x":-3,"y":7},{"x":-2,"y":6},{"x":-1,"y":5},{"x":0,"y":4},{"x":1,"y":3},{"x":2,"y":2},{"x":3,"y":5},{"x":4,"y":7},{"x":5,"y":9}],
+ "fill": false,
+ "showLine": true,
+ "borderWidth": 20,
+ "pointRadius": 0
+ }]
+ },
+ "options": {
+ "responsive": false,
+ "legend": false,
+ "title": false,
+ "scales": {
+ "xAxes": [{
+ "ticks": {
+ "min": -2,
+ "max": 3,
+ "display": false
+ }
+ }],
+ "yAxes": [{"ticks": {"display": false}}]
+ },
+ "layout": {
+ "padding": 24
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}
--- /dev/null
+{
+ "config": {
+ "type": "scatter",
+ "data": {
+ "datasets": [{
+ "borderColor": "red",
+ "data": [{"x":-5,"y":5},{"x":-4,"y":6},{"x":-3,"y":7},{"x":-2,"y":6},{"x":-1,"y":5},{"x":0,"y":4},{"x":1,"y":3},{"x":2,"y":2},{"x":3,"y":5},{"x":4,"y":7},{"x":5,"y":9}],
+ "fill": false,
+ "showLine": true,
+ "borderWidth": 20,
+ "pointRadius": 0
+ }]
+ },
+ "options": {
+ "responsive": false,
+ "legend": false,
+ "title": false,
+ "scales": {
+ "xAxes": [{"ticks": {"display": false}}],
+ "yAxes": [{
+ "ticks": {
+ "max": 6,
+ "display": false
+ }
+ }]
+ },
+ "layout": {
+ "padding": 24
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}
--- /dev/null
+{
+ "config": {
+ "type": "scatter",
+ "data": {
+ "datasets": [{
+ "borderColor": "red",
+ "data": [{"x":-5,"y":5},{"x":-4,"y":6},{"x":-3,"y":7},{"x":-2,"y":6},{"x":-1,"y":5},{"x":0,"y":4},{"x":1,"y":3},{"x":2,"y":2},{"x":3,"y":5},{"x":4,"y":7},{"x":5,"y":9}],
+ "fill": false,
+ "showLine": true,
+ "borderWidth": 20,
+ "pointRadius": 0
+ }]
+ },
+ "options": {
+ "responsive": false,
+ "legend": false,
+ "title": false,
+ "scales": {
+ "xAxes": [{"ticks": {"display": false}}],
+ "yAxes": [{
+ "ticks": {
+ "min": 2,
+ "display": false
+ }
+ }]
+ },
+ "layout": {
+ "padding": 24
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}
--- /dev/null
+{
+ "config": {
+ "type": "scatter",
+ "data": {
+ "datasets": [{
+ "borderColor": "red",
+ "data": [{"x":-5,"y":5},{"x":-4,"y":6},{"x":-3,"y":7},{"x":-2,"y":6},{"x":-1,"y":5},{"x":0,"y":4},{"x":1,"y":3},{"x":2,"y":2},{"x":3,"y":5},{"x":4,"y":7},{"x":5,"y":9}],
+ "fill": false,
+ "showLine": true,
+ "borderWidth": 20,
+ "pointRadius": 0
+ }]
+ },
+ "options": {
+ "responsive": false,
+ "legend": false,
+ "title": false,
+ "scales": {
+ "xAxes": [{"ticks": {"display": false}}],
+ "yAxes": [{
+ "ticks": {
+ "min": 2,
+ "max": 6,
+ "display": false
+ }
+ }]
+ },
+ "layout": {
+ "padding": 24
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}
--- /dev/null
+{
+ "config": {
+ "type": "scatter",
+ "data": {
+ "datasets": [
+ {
+ "showLine": true,
+ "borderColor": "red",
+ "data": [{"x":-4,"y":-4},{"x":4,"y":4}],
+ "clip": false
+ },
+ {
+ "showLine": true,
+ "borderColor": "green",
+ "data": [{"x":-4,"y":-5},{"x":4,"y":3}],
+ "clip": 5
+ },
+ {
+ "showLine": true,
+ "borderColor": "blue",
+ "data": [{"x":-4,"y":-3},{"x":4,"y":5}],
+ "clip": -5
+ },
+ {
+ "showLine": true,
+ "borderColor": "brown",
+ "data": [{"x":-3,"y":-3},{"x":-1,"y":3},{"x":1,"y":-2},{"x":2,"y":3}],
+ "clip": {
+ "top": 8,
+ "left": false,
+ "right": -20,
+ "bottom": -20
+ }
+ }
+ ]
+ },
+ "options": {
+ "responsive": false,
+ "legend": false,
+ "title": false,
+ "scales": {
+ "xAxes": [{
+ "ticks": {
+ "min": -2,
+ "max": 2,
+ "display": false
+ }
+ }],
+ "yAxes": [{
+ "ticks": {
+ "min": -2,
+ "max": 2,
+ "display": false
+ }
+ }]
+ },
+ "layout": {
+ "padding": 24
+ },
+ "elements": {
+ "line": {
+ "fill": false,
+ "borderWidth": 20
+ },
+ "point": {
+ "radius": 0
+ }
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}