Skip to content

Remove dependencies on Plotly for Choropleth #165

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

Merged
merged 1 commit into from
Jan 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/traces/choropleth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

'use strict';

var Plotly = require('../../plotly');
var Plots = require('../../plots/plots');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plots can stand on its own now so we should change things to directly require it whenever we come across Plotly.Plots.


Plotly.Plots.register(exports, 'choropleth', ['geo', 'noOpacity'], {
Plots.register(exports, 'choropleth', ['geo', 'noOpacity'], {
description: [
'The data that describes the choropleth value-to-color mapping',
'is set in `z`.',
Expand Down
11 changes: 7 additions & 4 deletions src/traces/choropleth/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ var Plotly = require('../../plotly');
var d3 = require('d3');

var Color = require('../../components/color');
var Drawing = require('../../components/drawing');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with Drawing.


var getColorscale = require('../../components/colorscale/get_scale');
var makeScaleFunction = require('../../components/colorscale/make_scale_function');
var getTopojsonFeatures = require('../../lib/topojson_utils').getTopojsonFeatures;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c before l is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly because I initially grouped all the components pieces together, then when I added Drawing next to Color I just left them 😆

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

var locationToFeature = require('../../lib/geo_location_utils').locationToFeature;
var arrayToCalcItem = require('../../lib/array_to_calc_item');
var getColorscale = require('../../components/colorscale/get_scale');
var makeScaleFunction = require('../../components/colorscale/make_scale_function');

var constants = require('../../constants/geo_constants');
var attributes = require('./attributes');

var plotChoropleth = module.exports = {};

Expand Down Expand Up @@ -141,7 +144,7 @@ plotChoropleth.style = function(geo) {
d3.select(this)
.attr('fill', function(d) { return sclFunc(d.z); })
.call(Color.stroke, d.mlc || markerLine.color)
.call(Plotly.Drawing.dashLine, '', d.mlw || markerLine.width);
.call(Drawing.dashLine, '', d.mlw || markerLine.width);
});
});
};
Expand All @@ -157,7 +160,7 @@ function makeCleanHoverLabelsFunc(geo, trace) {
}

var hoverinfoParts = (hoverinfo === 'all') ?
Plotly.Choropleth.attributes.hoverinfo.flags :
attributes.hoverinfo.flags :
hoverinfo.split('+');

var hasName = (hoverinfoParts.indexOf('name') !== -1),
Expand Down
5 changes: 2 additions & 3 deletions src/traces/scatter/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/


var Plotly = require('../../plotly');
var Drawing = require('../../components/drawing');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is a dependency of the choropleth attributes file so it needed to be changed as well.


var PTS_LINESONLY = 20; // TODO put in constants/

Expand Down Expand Up @@ -166,7 +165,7 @@ module.exports = {
marker: {
symbol: {
valType: 'enumerated',
values: Plotly.Drawing.symbolList,
values: Drawing.symbolList,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdtusz does the symbol list generate properly?

To check:

var schema = Plotly.PlotSchema.get();
console.log(schema.traces.scatter.attributes.marker.symbols.values);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like they're all there. For any future readers though, it's

var schema = Plotly.PlotSchema.get();
console.log(schema.traces.scatter.attributes.marker.symbol.values);

Singular symbol 😉

dflt: 'circle',
arrayOk: true,
role: 'style',
Expand Down