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

Color legend widget #731

Merged
merged 21 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
918efa1
initial proof of concept
matthewma7 Aug 15, 2017
921ea7e
initial functional implementation
matthewma7 Aug 16, 2017
f6f4466
Reverts some unintential changes;
matthewma7 Aug 16, 2017
84a8d93
Initial implementation of mouseover popup; Other improvements;
matthewma7 Aug 17, 2017
d45d2f1
Limits number of axis ticks for all type of legend; Adds legend name;…
matthewma7 Aug 17, 2017
ced0ec2
Supports pass in categories in beginning; precision display improveme…
matthewma7 Aug 17, 2017
c903e4a
Adds support for quantile scale
matthewma7 Aug 17, 2017
3931db6
Improves popup positioning;
matthewma7 Aug 18, 2017
c21553d
Fixes eslint errors;
matthewma7 Aug 18, 2017
fd4b166
Rename from legend2DWidget to colorLegendWidget; add methods for addi…
matthewma7 Aug 18, 2017
1d78b45
Adds legend tick limit to ordinal scale as well.
matthewma7 Aug 21, 2017
1fec30d
Adds unit test
matthewma7 Aug 25, 2017
5b1811f
Adds JSDocs
matthewma7 Aug 28, 2017
488118a
Merge branch 'master' into 2d_legend
matthewma7 Aug 29, 2017
8e9e5b8
Updates jsdocs; refactors codes based on review.
matthewma7 Sep 4, 2017
dba0a88
Further jsdocs changes
matthewma7 Sep 7, 2017
d0e663b
Merge branch 'master' into 2d_legend
matthewma7 Sep 18, 2017
03cb58e
Conforms with latest example framework
matthewma7 Sep 18, 2017
b8f5c71
Updates test to support all three test browsers
matthewma7 Sep 18, 2017
8bbf1d7
continously tries to make the test pass;
matthewma7 Sep 18, 2017
74759cd
Some minor fixes based on review
matthewma7 Sep 19, 2017
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
8 changes: 8 additions & 0 deletions examples/color-legend/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"title": "Color legends",
"exampleJs": ["main.js"],
"about": {
"text": "This example shows how to create a discrete or continous color legends."
},
"disabled": true
}
98 changes: 98 additions & 0 deletions examples/color-legend/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
var colorbrewer = colorbrewer;

// Run after the DOM loads
$(function () {
'use strict';

// Create a map object
var map = geo.map({
node: '#map',
zoom: 3
});

// Add the default osm layer
map.createLayer('osm');

// Create a ui layer
var ui = map.createLayer('ui');

// Create a legend widget
var legend = ui.createWidget('colorLegend', {
position: {
right: 20,
top: 10
}
});

// Add rows to the legend
//
// The categories are displayed in the order passed as
// a row on the legend. The category objects should
// contain the following properties:
//
// * name: (string) The name/description
// * style: (object) The feature style object
// * type: (string) The feature type ('point', 'line', 'other')
//
legend.categories([
{
name: 'Discrete ordinal',
type: 'discrete',
scale: 'ordinal',
domain: ['beijing', 'new york', 'london', 'paris'],
colors: ['red', 'green', 'blue', 'orange']
},
{
name: 'Discrete linear',
type: 'discrete',
scale: 'linear',
domain: [100, 1000],
colors: colorbrewer.YlGnBu['9']
},
{
name: 'Discrete sqrt',
type: 'discrete',
scale: 'sqrt',
domain: [10000, 1000000],
colors: colorbrewer.PRGn['11']
},
{
name: 'Discrete quantile',
type: 'discrete',
scale: 'quantile',
domain: [96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200],
colors: colorbrewer.Greens['8']
},
{
name: 'Discrete linear 2',
type: 'discrete',
scale: 'linear',
domain: [0.1, 0.001],
colors: colorbrewer.RdBu['8']
},
{
name: 'Continuous pow',
type: 'continuous',
scale: 'pow',
exponent: 1.1,
domain: [100, 10000],
colors: ['red', 'blue']
},
{
name: 'Continuous sqrt',
type: 'continuous',
scale: 'sqrt',
domain: [100, 1000],
colors: ['purple', 'orange']
},
{
name: 'Continuous log',
type: 'continuous',
scale: 'log',
base: Math.E,
domain: [100, 10000],
colors: ['blue', 'olive']
}
]);

});
Binary file added examples/color-legend/thumb.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading