From 47b25d1c6db94c509f7bbfc170d1727c9fbc77ad Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 14:16:01 -0400 Subject: [PATCH] Move linearRadial default config to be a property of the scale. --- src/charts/chart.polarArea.js | 39 +------------------- src/charts/chart.radar.js | 58 ----------------------------- src/charts/chart.scatter.js | 2 + src/core/core.js | 5 ++- src/scales/scale.radialLinear.js | 63 +++++++++++++++++++++++++++++++- 5 files changed, 69 insertions(+), 98 deletions(-) diff --git a/src/charts/chart.polarArea.js b/src/charts/chart.polarArea.js index 4131e6bc0..b1f6a0f8f 100644 --- a/src/charts/chart.polarArea.js +++ b/src/charts/chart.polarArea.js @@ -10,44 +10,7 @@ scale: { type: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - - lineArc: true, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, - - // scale numbers - beginAtZero: true, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - } + lineArc: true, // so that lines are circular }, //Boolean - Whether to animate the rotation of the chart diff --git a/src/charts/chart.radar.js b/src/charts/chart.radar.js index 3d911070f..bff30df90 100644 --- a/src/charts/chart.radar.js +++ b/src/charts/chart.radar.js @@ -13,64 +13,6 @@ scale: { type: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - - lineArc: false, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, - - angleLines: { - show: true, - color: "rgba(0,0,0,.1)", - lineWidth: 1 - }, - - // scale numbers - beginAtZero: true, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - }, - - pointLabels: { - //String - Point label font declaration - fontFamily: "'Arial'", - - //String - Point label font weight - fontStyle: "normal", - - //Number - Point label font size in pixels - fontSize: 10, - - //String - Point label font colour - fontColor: "#666", - }, }, elements: { diff --git a/src/charts/chart.scatter.js b/src/charts/chart.scatter.js index 6711dfbaa..fb2f101fe 100644 --- a/src/charts/chart.scatter.js +++ b/src/charts/chart.scatter.js @@ -18,6 +18,8 @@ }], yAxes: [{ type: "linear", + position: "left", + id: "y-axis-1", }], }, diff --git a/src/core/core.js b/src/core/core.js index 1cb6fafc7..28eef831d 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -145,7 +145,10 @@ // Scale config merging is complex. Add out own function here for that base[key] = helpers.scaleMerge(base.hasOwnProperty(key) ? base[key] : {}, value); - } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { + } else if (key === 'scale') { + // Used in polar area & radar charts since there is only one scale + base[key] = helpers.configMerge(base.hasOwnProperty(key) ? base[key] : {}, Chart.scaleService.getScaleDefaults(value.type), value); + }else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { // In this case we have an array of objects replacing another array. Rather than doing a strict replace, // merge. This allows easy scale option merging var baseArray = base[key]; diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 9d8e30eff..b15c487a3 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -5,6 +5,67 @@ Chart = root.Chart, helpers = Chart.helpers; + var defaultConfig = { + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate: false, + + lineArc: false, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + }, + + angleLines: { + show: true, + color: "rgba(0,0,0, 0.1)", + lineWidth: 1 + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, + + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + }, + + pointLabels: { + //String - Point label font declaration + fontFamily: "'Arial'", + + //String - Point label font weight + fontStyle: "normal", + + //Number - Point label font size in pixels + fontSize: 10, + + //String - Point label font colour + fontColor: "#666", + }, + }; + var LinearRadialScale = Chart.Element.extend({ initialize: function() { this.size = helpers.min([this.height, this.width]); @@ -374,7 +435,7 @@ } } }); - Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale); + Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale, defaultConfig); }).call(this); -- 2.47.3