Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Charts module #143

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Hex plot: add edge drawing & changing colour opts
  • Loading branch information
tlwr committed May 30, 2017
commit dc642be1f53b270f8107b09405f79e5ecd012ef2
15 changes: 15 additions & 0 deletions src/core/config/OperationConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3430,6 +3430,21 @@ const OperationConfig = {
type: "string",
value: "",
},
{
name: "Draw hexagon edges",
type: "boolean",
value: false,
},
{
name: "Min colour value",
type: "string",
value: Charts.COLOURS.min,
},
{
name: "Max colour value",
type: "string",
value: Charts.COLOURS.max,
},
]
}
};
Expand Down
22 changes: 20 additions & 2 deletions src/core/operations/Charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ const Charts = {
},


/**
* Default from colour
*
* @constant
* @default
*/
COLOURS: {
min: "white",
max: "black",
},



/**
* Hex Bin chart operation.
*
Expand All @@ -81,6 +94,9 @@ const Charts = {
packRadius = args[2],
drawRadius = args[3],
columnHeadingsAreIncluded = args[4],
drawEdges = args[7],
minColour = args[8],
maxColour = args[9],
dimension = 500;

let xLabel = args[5],
Expand Down Expand Up @@ -135,7 +151,7 @@ const Charts = {
.domain(yExtent)
.range([height, 0]);

let color = d3.scaleSequential(d3.interpolateLab("white", "steelblue"))
let colour = d3.scaleSequential(d3.interpolateLab(minColour, maxColour))
.domain([0, maxCount]);

marginedSpace.append("clipPath")
Expand All @@ -154,7 +170,9 @@ const Charts = {
.attr("d", d => {
return `M${xAxis(d.x)},${yAxis(d.y)} ${hexbin.hexagon(drawRadius)}`;
})
.attr("fill", (d) => color(d.length))
.attr("fill", (d) => colour(d.length))
.attr("stroke", drawEdges ? "black" : "none")
.attr("stroke-width", drawEdges ? "0.5" : "none")
.append("title")
.text(d => {
let count = d.length,
Expand Down