Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/axes/radial/linear.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The following options are used to configure the point labels that are shown on t
| Name | Type | Default | Description
| -----| ---- | --------| -----------
| `callback` | `Function` | | Callback function to transform data labels to point labels. The default implementation simply returns the current string.
| `fontColor` | `Color` | `'#666'` | Font color for point labels.
| `fontColor` | `Color/Color[]` | `'#666'` | Font color for point labels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should remove this since it's being added in #5240

| `fontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family to use when rendering labels.
| `fontSize` | `Number` | 10 | font size in pixels
| `fontStyle` | `String` | `'normal'` | Font style to use when rendering point labels.
1 change: 1 addition & 0 deletions docs/charts/radar.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ All point* properties can be specified as an array. If these are set to an array
| `pointHoverBorderColor` | `Color/Color[]` | Point border color when hovered.
| `pointHoverBorderWidth` | `Number/Number[]` | Border width of point when hovered.
| `pointHoverRadius` | `Number/Number[]` | The radius of the point when hovered.
| `spanGaps` | `Boolean` | If true, lines will be drawn between points with no or null data. If false, points with `NaN` data will create a break in the line

### pointStyle
The style of point. Options are:
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = function(Chart) {
// The default behavior of lines is to break at null values, according
// to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
// This option gives lines the ability to span gaps
spanGaps: dataset.spanGaps ? dataset.spanGaps : options.spanGaps,
spanGaps: (dataset.spanGaps !== undefined ? dataset.spanGaps : options.spanGaps),
tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/controller.radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = function(Chart) {
var meta = me.getMeta();
var line = meta.dataset;
var points = meta.data;
var options = me.chart.options;
var custom = line.custom || {};
var dataset = me.getDataset();
var lineElementOptions = me.chart.options.elements.line;
Expand All @@ -50,7 +51,8 @@ module.exports = function(Chart) {
// Model
_model: {
// Appearance
tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
// This option gives lines the ability to span gaps
spanGaps: (dataset.spanGaps !== undefined ? dataset.spanGaps : options.spanGaps),
backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor),
Expand Down
4 changes: 2 additions & 2 deletions src/scales/scale.radialLinear.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ module.exports = function(Chart) {

function drawPointLabels(scale) {
var ctx = scale.ctx;
var valueOrDefault = helpers.valueOrDefault;
var opts = scale.options;
var angleLineOpts = opts.angleLines;
var pointLabelOpts = opts.pointLabels;
Expand Down Expand Up @@ -267,7 +266,8 @@ module.exports = function(Chart) {
var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);

// Keep this in loop since we may support array properties here
var pointLabelFontColor = valueOrDefault(pointLabelOpts.fontColor, globalDefaults.defaultFontColor);
var pointLabelFontColor = helpers.valueAtIndexOrDefault(pointLabelOpts.fontColor, i, globalDefaults.defaultFontColor);

ctx.font = plFont.font;
ctx.fillStyle = pointLabelFontColor;

Expand Down
36 changes: 36 additions & 0 deletions test/fixtures/controller.radar/radar-span-gaps-disable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"config": {
"type": "radar",
"data": {
"labels": ["0", "1", "2", "3", "4", "5", "6", "7"],
"datasets": [{
"backgroundColor": "transparent",
"data": [4, 2, null, 3, 2.5, null, 2, 4],
"spanGaps": false
}]
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scale": {
"display": false
},
"elements": {
"point": {
"radius": 0
},
"line": {
"borderColor": "pink",
"fill": "origin"
}
}
}
},
"options": {
"canvas": {
"height": 256,
"width": 256
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions test/fixtures/controller.radar/radar-span-gaps-enable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"config": {
"type": "radar",
"data": {
"labels": ["0", "1", "2", "3", "4", "5", "6", "7"],
"datasets": [{
"backgroundColor": "transparent",
"data": [4, 2, null, 3, 2.5, null, 2, 4],
"spanGaps": true
}]
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scale": {
"display": false
},
"elements": {
"point": {
"radius": 0
},
"line": {
"borderColor": "pink",
"fill": "origin"
}
}
}
},
"options": {
"canvas": {
"height": 256,
"width": 256
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions test/specs/controller.radar.tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
describe('Chart.controllers.radar', function() {
describe('auto', jasmine.specsFromFixtures('controller.radar'));

it('Should be constructed', function() {
var chart = window.acquireChart({
type: 'radar',
Expand Down Expand Up @@ -480,4 +482,19 @@ describe('Chart.controllers.radar', function() {
expect(meta0.data[0]._model.radius).toBe(10);
expect(meta1.data[0]._model.radius).toBe(20);
});

it('should allow spanGaps to be set to true', function() {
var chart = window.acquireChart({
type: 'radar',
data: {
datasets: [{
data: [10, 15, NaN, 4],
spanGaps: true,
}],
labels: ['label1', 'label2', 'label3', 'label4'],
}
});
var meta = chart.getDatasetMeta(0);
expect(meta.dataset._model.spanGaps).toBe(true);
});
});