Skip to content

Commit 2a5cd39

Browse files
Merge pull request #148 from ignoreintuition/development
Development
2 parents 84b4174 + 9d68f92 commit 2a5cd39

18 files changed

+94
-52
lines changed

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link rel=stylesheet href=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css integrity=sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm crossorigin=anonymous><title>v-chart-plugin</title><link href=/v-chart-plugin-demo/static/css/app.f304e2ab4d8ba945cb52a7708d244e45.css rel=stylesheet></head><body bgcolor=yellow><div id=app></div><script type=text/javascript src=/v-chart-plugin-demo/static/js/manifest.c423efaf7696a83d1404.js></script><script type=text/javascript src=/v-chart-plugin-demo/static/js/vendor.ea0c2a26400e96edf6cc.js></script><script type=text/javascript src=/v-chart-plugin-demo/static/js/app.de77d3a1edc539760483.js></script></body><script src=https://code.jquery.com/jquery-3.2.1.slim.min.js integrity=sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN crossorigin=anonymous></script><script src=https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js integrity=sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q crossorigin=anonymous></script><script src=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js integrity=sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl crossorigin=anonymous></script></html>
1+
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link rel=stylesheet href=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css integrity=sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm crossorigin=anonymous><title>v-chart-plugin</title><link href=/v-chart-plugin-demo/static/css/app.54d64245c93f07f8de1551bc966830b4.css rel=stylesheet></head><body bgcolor=yellow><div id=app></div><script type=text/javascript src=/v-chart-plugin-demo/static/js/manifest.c423efaf7696a83d1404.js></script><script type=text/javascript src=/v-chart-plugin-demo/static/js/vendor.ea0c2a26400e96edf6cc.js></script><script type=text/javascript src=/v-chart-plugin-demo/static/js/app.2a515c02f246ccee676f.js></script></body><script src=https://code.jquery.com/jquery-3.2.1.slim.min.js integrity=sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN crossorigin=anonymous></script><script src=https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js integrity=sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q crossorigin=anonymous></script><script src=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js integrity=sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl crossorigin=anonymous></script></html>

dist/module/import/bubbleChart.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _Object$assign from 'babel-runtime/core-js/object/assign';
22
/**
3-
* @fileOverview Line Graph component definition
3+
* @fileOverview Bubble Chart component definition
44
*
55
* @author Brian Greig
66
*
@@ -9,11 +9,11 @@ import _Object$assign from 'babel-runtime/core-js/object/assign';
99
*/
1010
var d3 = _Object$assign({}, require('d3-selection'), require('d3-scale'), require('d3-axis'), require('d3-shape'));
1111
/**
12-
* Builds a Line Graph.
13-
* @module lineGraph
12+
* Builds a Bubble Chart.
13+
* @module bubbleChart
1414
*/
1515

16-
var lineGraph = function chart(mode) {
16+
var bubbleChart = function chart(mode) {
1717
var _this = this;
1818

1919
/**
@@ -92,8 +92,8 @@ var lineGraph = function chart(mode) {
9292
* @function
9393
*/
9494
var buildScales = function buildScales(cs) {
95-
cs.y.scale = d3.scaleLinear().domain([_this.minTriplet.v1, _this.maxTriplet.v1]).range([_this.displayHeight - cs.x.axisHeight, _this.header]);
96-
cs.x.scale = d3.scaleLinear().domain([_this.minTriplet.v2, _this.maxTriplet.v2]).range([0, _this.width]);
95+
cs.y.scale = d3.scaleLinear().domain([_this.minTriplet.v2, _this.maxTriplet.v2]).range([_this.displayHeight - cs.x.axisHeight, _this.header]);
96+
cs.x.scale = d3.scaleLinear().domain([_this.minTriplet.v1, _this.maxTriplet.v1]).range([0, _this.width]);
9797
cs.r.scale = d3.scaleLinear().domain([_this.minTriplet.v3, _this.maxTriplet.v3]).range([0, 20]);
9898
};
9999
/**
@@ -125,4 +125,4 @@ var lineGraph = function chart(mode) {
125125
return cs;
126126
};
127127

128-
export default lineGraph;
128+
export default bubbleChart;

dist/module/import/scatterPlot.js

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ var scatterPlot = function chart() {
2828
* @member cs
2929
*/
3030
var cs = {
31+
palette: {
32+
pointFill: '#005792',
33+
pointStroke: '#d1f4fa'
34+
},
3135
x: {
3236
domain: [],
3337
range: [],
@@ -36,87 +40,81 @@ var scatterPlot = function chart() {
3640
y: {
3741
axisWidth: 30,
3842
ticks: 5
43+
},
44+
r: {
45+
width: 5
3946
}
4047
};
41-
var points = svgContainer.selectAll('circle').data(this.ds);
48+
4249
/**
4350
* Runs when a new element is added to the dataset
4451
* @member enter
4552
* @function
46-
* @param {Object} p (svg element)
53+
* @param {Object} points (svg element)
4754
*/
48-
var enter = function enter(p) {
49-
p.enter().append('circle').attr('class', _this.selector).attr('r', 2).on('mouseover', function (d) {
50-
_this.addTooltip(d, window.event);
51-
}).on('mouseout', function (d) {
52-
_this.removeTooltip(d);
53-
}).attr('cx', function (d) {
54-
return cs.x.scale(d.dim) + cs.y.axisWidth + 5;
55+
var enter = function enter(points) {
56+
points.enter().append('circle').attr('class', _this.selector).attr('r', cs.r.width).attr('cx', function (d) {
57+
return cs.x.scale(d.metric[0]) + cs.y.axisWidth + 5;
5558
}).attr('cy', function (d) {
56-
return cs.y.scale(d.metric);
59+
return cs.y.scale(d.metric[1]);
5760
});
5861
return points;
5962
};
6063
/**
6164
* Runs when a value of an element in dataset is changed
6265
* @member transition
6366
* @function
64-
* @param {Object} p (svg element)
67+
* @param {Object} points (svg element)
6568
*/
66-
var transition = function transition(p) {
67-
p.transition().attr('cx', function (d) {
68-
return cs.x.scale(d.dim) + cs.y.axisWidth + 5;
69+
var transition = function transition(points) {
70+
points.transition().attr('r', cs.r.width).attr('cx', function (d) {
71+
return cs.x.scale(d.metric[0]) + cs.y.axisWidth + 5;
6972
}).attr('cy', function (d) {
70-
return cs.y.scale(d.metric);
71-
}).attr('cx', function (d) {
72-
return cs.x.scale(d.dim) + cs.y.axisWidth + 5;
73-
}).attr('cy', function (d) {
74-
return cs.y.scale(d.metric);
73+
return cs.y.scale(d.metric[1]);
7574
});
7675
return points;
7776
};
77+
7878
/**
7979
* Runs when an element is removed from the dataset
8080
* @member exit
8181
* @function
82-
* @param {Object} rect (svg element)
82+
* @param {Object} points (svg element)
8383
*/
84-
var exit = function exit() {
84+
var exit = function exit(points) {
8585
points.exit().remove();
8686
return points;
8787
};
88+
8889
/**
8990
* Builds the scales for the x and y axes
9091
* @member buildScales
9192
* @function
9293
*/
93-
var buildScales = function buildScales() {
94-
cs.y.scale = d3.scaleLinear().domain([_this.min, _this.max]).range([_this.displayHeight - cs.x.axisHeight, _this.header]);
95-
cs.y.axis = d3.axisLeft().ticks(cs.y.ticks, 's').scale(cs.y.scale);
96-
_this.ds.forEach(function (t) {
97-
return cs.x.domain.push(t.dim);
98-
});
99-
_this.ds.forEach(function (t, i) {
100-
return cs.x.range.push((_this.width * i - _this.header) / _this.ds.length);
101-
});
102-
cs.x.scale = d3.scaleOrdinal().domain(cs.x.domain).range(cs.x.range);
94+
var buildScales = function buildScales(cs) {
95+
cs.y.scale = d3.scaleLinear().domain([_this.minTriplet.v2, _this.maxTriplet.v2]).range([_this.displayHeight - cs.x.axisHeight, _this.header]);
96+
cs.x.scale = d3.scaleLinear().domain([_this.minTriplet.v1, _this.maxTriplet.v1]).range([0, _this.width]);
10397
};
10498
/**
10599
* Draws the x and y axes on the svg
106100
* @member drawAxis
107101
* @function
108102
*/
109-
var drawAxis = function drawAxis() {
103+
var drawAxis = function drawAxis(cs) {
110104
cs.x.axis = d3.axisBottom().scale(cs.x.scale);
111105
cs.x.xOffset = cs.y.axisWidth + 5;
112-
cs.x.yOffset = _this.height - cs.x.axisHeight;
106+
cs.x.yOffset = _this.displayHeight - cs.x.axisHeight;
107+
cs.y.axis = d3.axisLeft().ticks(cs.y.ticks, 's').scale(cs.y.scale);
113108
cs.y.xOffset = cs.y.axisWidth;
114109
cs.y.yOffset = 0;
115110
svgContainer.append('g').attr('class', 'axis').attr('transform', 'translate(' + cs.x.xOffset + ', ' + cs.x.yOffset + ')').call(cs.x.axis);
116111
svgContainer.append('g').attr('class', 'axis').attr('transform', 'translate(' + cs.y.xOffset + ',' + cs.y.yOffset + ')').call(cs.y.axis);
117112
};
118113

114+
var points = svgContainer.selectAll('circle').data(this.ds);
115+
119116
cs = this.setOverrides(cs, this.chartData.overrides);
117+
120118
buildScales(cs);
121119
drawAxis(cs);
122120
enter(points);

dist/module/v-chart-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ var Chart = {
9090
* @param {Object} e event x and y coordinates
9191
*/
9292
addTooltip: function addTooltip(d, e) {
93-
d3.select('#' + this.chartData.selector).append('rect').attr('x', e.layerX - 5 - 50).attr('y', e.layerY - 13 - 25).attr('height', '16px').attr('width', '80px').attr('class', 'tt').attr('fill', 'white');
93+
d3.select('#' + this.chartData.selector).append('rect').attr('x', e.offsetX - 5 - 50).attr('y', e.offsetY - 13 - 25).attr('height', '16px').attr('width', '80px').attr('class', 'tt').attr('fill', 'white');
9494

95-
d3.select('#' + this.chartData.selector).append('text').attr('x', e.layerX - 50).attr('y', e.layerY - 25).attr('class', 'tt').attr('font-size', '10px').text(d.dim + ':' + d.metric);
95+
d3.select('#' + this.chartData.selector).append('text').attr('x', e.offsetX - 50).attr('y', e.offsetY - 25).attr('class', 'tt').attr('font-size', '10px').text(d.dim + ':' + d.metric);
9696
},
9797

9898
/**

dist/static/css/app.f304e2ab4d8ba945cb52a7708d244e45.css renamed to dist/static/css/app.54d64245c93f07f8de1551bc966830b4.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/css/app.f304e2ab4d8ba945cb52a7708d244e45.css.map renamed to dist/static/css/app.54d64245c93f07f8de1551bc966830b4.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/app.2a515c02f246ccee676f.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/app.2a515c02f246ccee676f.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/static/js/app.de77d3a1edc539760483.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/static/js/app.de77d3a1edc539760483.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)