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

Bug in GraduatedCircleViz with radius_function_type='match'? #72

Closed
colllin opened this issue Mar 16, 2018 · 3 comments
Closed

Bug in GraduatedCircleViz with radius_function_type='match'? #72

colllin opened this issue Mar 16, 2018 · 3 comments
Labels

Comments

@colllin
Copy link

colllin commented Mar 16, 2018

I believe I'm seeing a bug in GraduatedCircleViz.

Here's the JS console error:

Error: layers.circle.paint.circle-radius[4]: Expected number but found string instead.
emitErrors — validate_style.js:10
addLayer — style.js:531
addLayer — map.js:1125

Here's the paint it is attempting to set on the layer, which is failing validation (I believe this is because my default radius has at some point been converted from a number to a string):

{
    "circle-color": [
        "match", [
            "get",
            "category"
        ],
        "A",
        "rgb(255,0,0)",
        "B",
        "rgb(255,255,0)",
        "C",
        "rgb(0,255,0)",
        "D",
        "rgb(0,255,255)",
        "E",
        "rgb(0,0,255)",
        "gray"
    ],
    "circle-radius": [
        "match", [
            "get",
            "category"
        ],
        "A", 1,
        "B", 2,
        "C", 3,
        "D", 4,
        "E", 5,
        "10"
    ],
    "circle-stroke-color": "grey",
    "circle-stroke-width": [
        "interpolate", [
            "linear"
        ],
        [
            "zoom"
        ], 0, 0.01, 18, 1
    ],
    "circle-opacity": 1
}

Here's my python code:

viz = mapboxgl.viz.GraduatedCircleViz(
    map_geojson, 
    access_token=MAPBOX_ACCESS_TOKEN, 
    # label_property = 'name',
    color_property = 'category',
    color_stops = [
        ['A', 'rgb(255,0,0)'],  
        ['B', 'rgb(255,255,0)'], 
        ['C', 'rgb(0,255,0)'], 
        ['D', 'rgb(0,255,255)'], 
        ['E', 'rgb(0,0,255)'], 
    ],
    color_function_type = 'match',
    color_default = 'gray',
    radius_property = 'category',
    radius_stops = [
        ['A', 1.0],  
        ['B', 2.0], 
        ['C', 3.0], 
        ['D', 4.0], 
        ['E', 5.0]
    ],
    radius_function_type = 'match',
    radius_default = 10,
    center = (-40, 25),
    zoom = 3,
    height='500px'
)
viz.show() 
@colllin colllin changed the title JS bug in GraduatedCircleViz with radius_function_type='match'? Bug in GraduatedCircleViz with radius_function_type='match'? Mar 16, 2018
@ryanbaumann
Copy link
Contributor

ryanbaumann commented Mar 16, 2018

Yes, this seems to be a bug - circle-radius must always be a numeric value. It looks like the radius_defualt is coerced to a string value "10".

I'm not quite sure why this is happening since you're passing a numeric value. It should just be a pass through. https://github.com/mapbox/mapboxgl-jupyter/blob/master/mapboxgl/templates/main.html#L110

Can you confirm what the value of your viz.radius_default value shows up as in Python after creating the viz class @colllin?

@colllin
Copy link
Author

colllin commented Mar 17, 2018

I also thought to check that.

print(viz.radius_default, type(viz.radius_default))
=> 10 <class 'int'>

@ryanbaumann
Copy link
Contributor

Thanks for validating. That narrows this down. Ill make a quick PR to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants