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

Added final changes to scales.h and testing for scales.h #337

Merged
merged 52 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
19ca52d
added SequentialOrDivergingScale class, cleaned up tests
Oliver-BE Jun 25, 2020
a0e2a0e
added getters, organized new scales
Oliver-BE Jun 25, 2020
4bd40fa
Merge branch 'd3-wrapper' into d3-wrapper-dev-oliver
Oliver-BE Jun 29, 2020
8250ac4
added push_map_to_javascript functionality
Oliver-BE Jun 29, 2020
ba9c6ae
made base class constructors protected
Oliver-BE Jun 29, 2020
3d69467
added template specialization to ApplyScale
Oliver-BE Jun 30, 2020
f6b7290
fixes to pass_map_to_javascript
Oliver-BE Jun 30, 2020
832bc23
Merge branch 'd3-wrapper' into d3-wrapper-dev-oliver
Oliver-BE Jul 1, 2020
88f41a6
cleaned up pass_map_to_javascript
Oliver-BE Jul 1, 2020
2750f87
fixed apply scale date
Oliver-BE Jul 2, 2020
a4d0df5
fixed ApplyScale for Date input
Oliver-BE Jul 7, 2020
6e6106b
Merge branch 'd3-wrapper' into d3-wrapper-dev-oliver
Oliver-BE Jul 7, 2020
8864f62
created working scale tests and started testing linear scale
Oliver-BE Jul 7, 2020
ebc36ed
added working tests for linear and pow scale
Oliver-BE Jul 8, 2020
603eeae
added passing tests for sqrt, log, and symlog scales
Oliver-BE Jul 9, 2020
fb45fd4
added passing tests for identity scale and time scale. cleaned up som…
Oliver-BE Jul 10, 2020
bbfe82c
Add Dockerfile
mmore500 Jul 11, 2020
9dbe79a
Advertise Docker container on README.md
mmore500 Jul 11, 2020
335644c
Entrypoint should be path to script
mmore500 Jul 11, 2020
49da5b8
Fixup formatting
mmore500 Jul 11, 2020
ae4a9cf
Initialize git submodules for DockerHub
mmore500 Jul 11, 2020
9911efa
Try separating submodule init and update
mmore500 Jul 11, 2020
1bdd295
Try nuking and then reininitializing submodules
mmore500 Jul 11, 2020
712ac43
Escape #'s in scripts
mmore500 Jul 11, 2020
a036443
Separate submodule init, install test deps
mmore500 Jul 11, 2020
b22fb33
More selectively remove cached files
mmore500 Jul 11, 2020
9be97c4
Try a better way to clear submodules
mmore500 Jul 11, 2020
675028d
Try adding -f flag to update
mmore500 Jul 11, 2020
097cc95
Re-fix shebangs
mmore500 Jul 11, 2020
4356305
Remove mysterious set -e line
mmore500 Jul 11, 2020
3654f76
Add -f flag to submodule deinit
mmore500 Jul 11, 2020
7cdb2d4
Revert "Remove mysterious set -e line"
mmore500 Jul 11, 2020
7cf8c3b
Remove default command
mmore500 Jul 11, 2020
6142620
Fixup entrypoint
mmore500 Jul 11, 2020
d2070d7
Merge pull request #331 from devosoft/docker
mmore500 Jul 13, 2020
06249e2
Merge branch 'd3-wrapper' into d3-wrapper-dev-oliver
Oliver-BE Jul 13, 2020
40f3e4f
Merge branch 'master' into d3-wrapper-dev-oliver
Oliver-BE Jul 14, 2020
afe156e
Switch from ssh to https ref to origin
mmore500 Jul 14, 2020
1fbdfde
Fixup Dockerfile
mmore500 Jul 14, 2020
47e8875
added file that demonstrates core functionality of writing emscripten…
Oliver-BE Jul 14, 2020
cb29bcd
Merge pull request #332 from devosoft/mmore500-patch-docker
mmore500 Jul 14, 2020
81d5993
Install karma-firefox-launcher
mmore500 Jul 15, 2020
490f73e
Merge pull request #333 from devosoft/mmore500-dockerfile-windows
mmore500 Jul 15, 2020
2781fa7
Merge branch 'd3-wrapper' into d3-wrapper-dev-oliver
Oliver-BE Jul 15, 2020
de11e53
added blogpost rough draft file
Oliver-BE Jul 15, 2020
7f062b4
added remaining tests, fixed small bugs in scales.h
Oliver-BE Jul 21, 2020
e6f0de0
Merge branch 'master' into d3-wrapper-dev-oliver
Oliver-BE Jul 21, 2020
6be9019
fixed comments and spacing
Oliver-BE Jul 21, 2020
8b24450
removing file
Oliver-BE Jul 21, 2020
8d64538
removing enrichment.cc
Oliver-BE Jul 21, 2020
b6a48a0
Merge branch 'd3-wrapper' into d3-wrapper-dev-oliver
Oliver-BE Jul 21, 2020
98e7075
removing test_scales.cc
Oliver-BE Jul 21, 2020
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
Next Next commit
added SequentialOrDivergingScale class, cleaned up tests
  • Loading branch information
Oliver-BE committed Jun 25, 2020
commit 19ca52ded5431b59657d50c5c21b9bb96624a3fd
163 changes: 92 additions & 71 deletions source/web/d3/scales.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ namespace D3 {
ContinuousScale & SetInterpolate(const std::string & interpolatorName) = delete;
};

// This functionality is included in the newest version of d3-scale, but not the newest version of base d3
// scaleRadial
// class RadialScale : public ContinuousScale {
// protected:
Expand Down Expand Up @@ -490,29 +491,23 @@ namespace D3 {
}
};

// scaleSequential
// is used for mapping continuous values to an output range
// determined by a preset (or custom) interpolator
// the input domain and output range of a sequential scale always has exactly two elements,
// and the output range is typically specified as an interpolator rather than an array of values
class SequentialScale : public ContinuousScale {
// class for sequential or diverging scale to inherent, should never be called alone
// sets up base functionality
class SequentialOrDivergingScale : public ContinuousScale {
protected:
SequentialScale(bool derived) : ContinuousScale(true) { ; }
SequentialOrDivergingScale(bool derived) : ContinuousScale(true) { ; }

public:
SequentialScale() : ContinuousScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequential(); }, this->id);
}
SequentialOrDivergingScale() : ContinuousScale(true) {;}

// get rid of functions that shouldn't be called:
// Identity scales do not support invert or interpolate
template <typename T>
double Invert(T y) = delete;
ContinuousScale & SetInterpolate(const std::string & interpolatorName) = delete;


// .interpolator
SequentialScale & SetInterpolator(const std::string & interpolatorName) {
SequentialOrDivergingScale & SetInterpolator(const std::string & interpolatorName) {
// note: this doesn't allow you to specify arguments to a d3.interpolator function
EM_ASM({
const id = $0;
Expand All @@ -525,140 +520,166 @@ namespace D3 {
}
};

// scaleSequential
// is used for mapping continuous values to an output range
// determined by a preset (or custom) interpolator
// the input domain and output range of a sequential scale always has exactly two elements,
// and the output range is typically specified as an interpolator rather than an array of values
class SequentialScale : public SequentialOrDivergingScale {
protected:
SequentialScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
SequentialScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequential(); }, this->id);
}
};


// scaleSequentialLog
class SequentialLogScale : public SequentialScale {
class SequentialLogScale : public SequentialOrDivergingScale {
protected:
SequentialLogScale(bool derived) : SequentialScale(true) { ; }
SequentialLogScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
SequentialLogScale() : SequentialScale(true) {
SequentialLogScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequentialLog(); }, this->id);
}
};

// scaleSequentialPow
class SequentialPowScale : public SequentialScale {
class SequentialPowScale : public SequentialOrDivergingScale {
protected:
SequentialPowScale(bool derived) : SequentialScale(true) { ; }
SequentialPowScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
SequentialPowScale() : SequentialScale(true) {
SequentialPowScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequentialPow(); }, this->id);
}
};

// scaleSequentialSqrt
class SequentialSqrtScale : public SequentialScale {
class SequentialSqrtScale : public SequentialOrDivergingScale {
protected:
SequentialSqrtScale(bool derived) : SequentialScale(true) { ; }
SequentialSqrtScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
SequentialSqrtScale() : SequentialScale(true) {
SequentialSqrtScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequentialSqrt(); }, this->id);
}
};

// scaleSequentialSymlog
class SequentialSymlogScale : public SequentialScale {
class SequentialSymlogScale : public SequentialOrDivergingScale {
protected:
SequentialSymlogScale(bool derived) : SequentialScale(true) { ; }
SequentialSymlogScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
SequentialSymlogScale() : SequentialScale(true) {
SequentialSymlogScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequentialSymlog(); }, this->id);
}
};

// scaleSequentialQuantile
class SequentialQuantileScale : public SequentialScale {
class SequentialQuantileScale : public SequentialOrDivergingScale {
protected:
SequentialQuantileScale(bool derived) : SequentialScale(true) { ; }
SequentialQuantileScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
SequentialQuantileScale() : SequentialScale(true) {
SequentialQuantileScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequentialQuantile(); }, this->id);
}

// This functionality is included in the newest version of d3-scale, but not base d3
// .quantiles
// Returns an array of n + 1 quantiles. For example, if n = 4, returns an array of five numbers:
// the minimum value, the first quartile, the median, the third quartile, and the maximum.
emp::vector<double> GetQuantiles(const int n) {
EM_ASM({
emp_i.__outgoing_array = emp_d3.objects[$0].quantiles($1);
}, this->id, n);
// access JS array
emp::vector<double> quantile_vector;
emp::pass_vector_to_cpp(quantile_vector);
return quantile_vector;
}
// emp::vector<double> GetQuantiles(const int n) {
// EM_ASM({
// emp_i.__outgoing_array = emp_d3.objects[$0].quantiles($1);
// }, this->id, n);
// // access JS array
// emp::vector<double> quantile_vector;
// emp::pass_vector_to_cpp(quantile_vector);
// return quantile_vector;
// }
};


// scaleDiverging
// map a continuous, numeric input domain to a continuous output range.
// However, unlike continuous scales, the input domain and output range of a diverging scale always has exactly three elements,
// and the output range is typically specified as an interpolator rather than an array of values
class DivergingScale : public ContinuousScale {
protected:
DivergingScale(bool derived) : ContinuousScale(true) { ; }
// class DivergingScale : public ContinuousScale {
// protected:
// DivergingScale(bool derived) : ContinuousScale(true) { ; }

public:
DivergingScale() : ContinuousScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleSequential(); }, this->id);
}
// public:
// DivergingScale() : ContinuousScale(true) {
// EM_ASM({ emp_d3.objects[$0] = d3.scaleDiverging(); }, this->id);
// }

// get rid of functions that shouldn't be called:
// Identity scales do not support invert or interpolate
template <typename T>
double Invert(T y) = delete;
ContinuousScale & SetInterpolate(const std::string & interpolatorName) = delete;
// // get rid of functions that shouldn't be called:
// // Identity scales do not support invert or interpolate
// template <typename T>
// double Invert(T y) = delete;
// ContinuousScale & SetInterpolate(const std::string & interpolatorName) = delete;


// .interpolator
DivergingScale & SetInterpolator(const std::string & interpolatorName) {
// note: this doesn't allow you to specify arguments to a d3.interpolator function
EM_ASM({
const id = $0;
const interpolator_str = UTF8ToString($1);
var sel = emp_d3.find_function(interpolator_str);
emp_d3.objects[id].interpolator(sel);
}, this->id, interpolatorName.c_str());
// // .interpolator
// DivergingScale & SetInterpolator(const std::string & interpolatorName) {
// // note: this doesn't allow you to specify arguments to a d3.interpolator function
// EM_ASM({
// const id = $0;
// const interpolator_str = UTF8ToString($1);
// var sel = emp_d3.find_function(interpolator_str);
// emp_d3.objects[id].interpolator(sel);
// }, this->id, interpolatorName.c_str());

// return *this;
// }
// };

return *this;
// scaleDiverging
class DivergingScale : public SequentialOrDivergingScale {
protected:
DivergingScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
DivergingScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleDiverging(); }, this->id);
}
};

// scaleDivergingLog
class DivergingLogScale : public DivergingScale {
class DivergingLogScale : public SequentialOrDivergingScale {
protected:
DivergingLogScale(bool derived) : DivergingScale(true) { ; }
DivergingLogScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
DivergingLogScale() : DivergingScale(true) {
DivergingLogScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleDivergingLog(); }, this->id);
}
};

// scaleDivergingPow
class DivergingPowScale : public DivergingScale {
class DivergingPowScale : public SequentialOrDivergingScale {
protected:
DivergingPowScale(bool derived) : DivergingScale(true) { ; }
DivergingPowScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
DivergingPowScale() : DivergingScale(true) {
DivergingPowScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleDivergingPow(); }, this->id);
}
};

// scaleDivergingSqrt
class DivergingSqrtScale : public DivergingScale {
class DivergingSqrtScale : public SequentialOrDivergingScale {
protected:
DivergingSqrtScale(bool derived) : DivergingScale(true) { ; }
DivergingSqrtScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
DivergingSqrtScale() : DivergingScale(true) {
DivergingSqrtScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleDivergingSqrt(); }, this->id);
}
};

// scaleDivergingSymlog
class DivergingSymlogScale : public DivergingScale {
class DivergingSymlogScale : public SequentialOrDivergingScale {
protected:
DivergingSymlogScale(bool derived) : DivergingScale(true) { ; }
DivergingSymlogScale(bool derived) : SequentialOrDivergingScale(true) { ; }
public:
DivergingSymlogScale() : DivergingScale(true) {
DivergingSymlogScale() : SequentialOrDivergingScale(true) {
EM_ASM({ emp_d3.objects[$0] = d3.scaleDivergingSymlog(); }, this->id);
}
};
Expand Down Expand Up @@ -757,7 +778,7 @@ namespace D3 {
EM_ASM({
emp_d3.objects[$0] = d3.scaleOrdinal()
}, this->id);
}
}
};

// scaleBand
Expand Down
Loading