Skip to content

Commit

Permalink
add color fill to scatterplot
Browse files Browse the repository at this point in the history
  • Loading branch information
NickQiZhu committed Oct 15, 2013
1 parent f24bee8 commit a597c2f
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 17 deletions.
1 change: 0 additions & 1 deletion dc.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,5 @@ div.dc-chart {
}

.dc-chart .symbol{
fill: steelblue;
stroke: none;
}
5 changes: 3 additions & 2 deletions dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ dc.colorChart = function(_chart) {

/**
#### .colorDomain([domain])
Set or get the current domain for the color mapping function. The domain must be supplied as an arrary.
Set or get the current domain for the color mapping function. The domain must be supplied as an array.
Note: previously this method accepted a callback function. Instead you may use a custom scale set by `.colors`.
Expand All @@ -2552,7 +2552,7 @@ dc.colorChart = function(_chart) {

/**
#### .getColor(d [, i])
Get the color for the datum d and counter i. This is used internaly by charts to retreive a color.
Get the color for the datum d and counter i. This is used internaly by charts to retrieve a color.
**/
_chart.getColor = function(d, i){
Expand Down Expand Up @@ -5545,6 +5545,7 @@ dc.scatterPlot = function (parent, chartGroup) {
.enter()
.append("circle")
.attr("class", "symbol")
.attr("fill", _chart.getColor(0))
.attr("transform", _locator);

dc.transition(symbols, _chart.transitionDuration())
Expand Down
2 changes: 1 addition & 1 deletion dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/color-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dc.colorChart = function(_chart) {

/**
#### .colorDomain([domain])
Set or get the current domain for the color mapping function. The domain must be supplied as an arrary.
Set or get the current domain for the color mapping function. The domain must be supplied as an array.
Note: previously this method accepted a callback function. Instead you may use a custom scale set by `.colors`.
Expand All @@ -103,7 +103,7 @@ dc.colorChart = function(_chart) {

/**
#### .getColor(d [, i])
Get the color for the datum d and counter i. This is used internaly by charts to retreive a color.
Get the color for the datum d and counter i. This is used internaly by charts to retrieve a color.
**/
_chart.getColor = function(d, i){
Expand Down
1 change: 1 addition & 0 deletions src/scatter-plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dc.scatterPlot = function (parent, chartGroup) {
.enter()
.append("circle")
.attr("class", "symbol")
.attr("fill", _chart.getColor(0))
.attr("transform", _locator);

dc.transition(symbols, _chart.transitionDuration())
Expand Down
12 changes: 9 additions & 3 deletions test/scatterplot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ suite.addBatch({
},

'should correctly place symbols': function (chart) {
assert.equal("translate(166.8013698630137,140)", symbol_by_index(chart, 0).attr("transform"));
assert.equal("translate(209.37671232876713,114)", symbol_by_index(chart, 3).attr("transform"));
assert.equal("translate(255.40410958904107,44)", symbol_by_index(chart, 5).attr("transform"));
assert.equal(symbol_by_index(chart, 0).attr("transform"), "translate(166.8013698630137,140)");
assert.equal(symbol_by_index(chart, 3).attr("transform"), "translate(209.37671232876713,114)");
assert.equal(symbol_by_index(chart, 5).attr("transform"), "translate(255.40410958904107,44)");
},

'should generate color fill for symbols': function(chart){
assert.equal(symbol_by_index(chart, 0).attr("fill"), '#1f77b4');
assert.equal(symbol_by_index(chart, 3).attr("fill"), '#1f77b4');
assert.equal(symbol_by_index(chart, 5).attr("fill"), '#1f77b4');
}
},

Expand Down
1 change: 0 additions & 1 deletion web/css/dc.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,5 @@ div.dc-chart {
}

.dc-chart .symbol{
fill: steelblue;
stroke: none;
}
4 changes: 2 additions & 2 deletions web/docs/api-1.7.0-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,15 @@ the index of a group.
```
#### .colorDomain([domain])
Set or get the current domain for the color mapping function. The domain must be supplied as an arrary.
Set or get the current domain for the color mapping function. The domain must be supplied as an array.
Note: previously this method accepted a callback function. Instead you may use a custom scale set by `.colors`.
#### .calculateColorDomain()
Set the domain by determining the min and max values as retrived by `.colorAccessor` over the chart's dataset.
#### .getColor(d [, i])
Get the color for the datum d and counter i. This is used internaly by charts to retreive a color.
Get the color for the datum d and counter i. This is used internaly by charts to retrieve a color.
## <a name="stackable-chart" href="#stackable-chart">#</a> Stackable Chart [Abstract]
Stackable chart is an abstract chart introduced to provide cross-chart support of stackability. Concrete implementation of
Expand Down
4 changes: 2 additions & 2 deletions web/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,12 @@ <h4>.colorAccessor([colorAccessorFunction])</h4>
<span class="comment">// color accessor for a multi-value crossfilter reduction</span>
<span class="variable">.colorAccessor</span>(function(d){<span class="keyword">return</span> d<span class="variable">.value</span><span class="variable">.absGain</span>;})</code></pre>
<h4>.colorDomain([domain])</h4>
<p>Set or get the current domain for the color mapping function. The domain must be supplied as an arrary.</p>
<p>Set or get the current domain for the color mapping function. The domain must be supplied as an array.</p>
<p>Note: previously this method accepted a callback function. Instead you may use a custom scale set by <code>.colors</code>.</p>
<h4>.calculateColorDomain()</h4>
<p>Set the domain by determining the min and max values as retrived by <code>.colorAccessor</code> over the chart&#39;s dataset.</p>
<h4>.getColor(d [, i])</h4>
<p>Get the color for the datum d and counter i. This is used internaly by charts to retreive a color.</p>
<p>Get the color for the datum d and counter i. This is used internaly by charts to retrieve a color.</p>
<h2><a name="stackable-chart" href="#stackable-chart">#</a> Stackable Chart [Abstract]</h2>
<p>Stackable chart is an abstract chart introduced to provide cross-chart support of stackability. Concrete implementation of
charts can then selectively mix-in this capability.</p>
Expand Down
5 changes: 3 additions & 2 deletions web/js/dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ dc.colorChart = function(_chart) {

/**
#### .colorDomain([domain])
Set or get the current domain for the color mapping function. The domain must be supplied as an arrary.
Set or get the current domain for the color mapping function. The domain must be supplied as an array.
Note: previously this method accepted a callback function. Instead you may use a custom scale set by `.colors`.
Expand All @@ -2552,7 +2552,7 @@ dc.colorChart = function(_chart) {

/**
#### .getColor(d [, i])
Get the color for the datum d and counter i. This is used internaly by charts to retreive a color.
Get the color for the datum d and counter i. This is used internaly by charts to retrieve a color.
**/
_chart.getColor = function(d, i){
Expand Down Expand Up @@ -5545,6 +5545,7 @@ dc.scatterPlot = function (parent, chartGroup) {
.enter()
.append("circle")
.attr("class", "symbol")
.attr("fill", _chart.getColor(0))
.attr("transform", _locator);

dc.transition(symbols, _chart.transitionDuration())
Expand Down

0 comments on commit a597c2f

Please sign in to comment.