{"action":"created","issue":{"url":"https://api.github.com/repos/pyecharts/pyecharts/issues/425","repository_url":"https://api.github.com/repos/pyecharts/pyecharts","labels_url":"https://api.github.com/repos/pyecharts/pyecharts/issues/425/labels{/name}","comments_url":"https://api.github.com/repos/pyecharts/pyecharts/issues/425/comments","events_url":"https://api.github.com/repos/pyecharts/pyecharts/issues/425/events","html_url":"https://github.com/pyecharts/pyecharts/issues/425","id":302063213,"number":425,"title":"为 visualMap 新增 pieces 参数","user":{"login":"chenjiandongx","id":19553554,"avatar_url":"https://avatars2.githubusercontent.com/u/19553554?v=4","gravatar_id":"","url":"https://api.github.com/users/chenjiandongx","html_url":"https://github.com/chenjiandongx","followers_url":"https://api.github.com/users/chenjiandongx/followers","following_url":"https://api.github.com/users/chenjiandongx/following{/other_user}","gists_url":"https://api.github.com/users/chenjiandongx/gists{/gist_id}","starred_url":"https://api.github.com/users/chenjiandongx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenjiandongx/subscriptions","organizations_url":"https://api.github.com/users/chenjiandongx/orgs","repos_url":"https://api.github.com/users/chenjiandongx/repos","events_url":"https://api.github.com/users/chenjiandongx/events{/privacy}","received_events_url":"https://api.github.com/users/chenjiandongx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-04T07:03:31Z","updated_at":"2018-03-04T07:24:12Z","closed_at":null,"author_association":"COLLABORATOR","body":"为 visualMap 组件新增了 pieces 参数，该参数仅在 is_piecewise 为 True 时生效。适用于所有支持 visualMap 组件的图形种类，\r\n\r\n```\r\n:param pieces:\r\n        自定义『分段式视觉映射组件（visualMapPiecewise）』的每一段的范围，\r\n        以及每一段的文字，以及每一段的特别的样式。例如：\r\n        pieces: [\r\n            {min: 1500}, // 不指定 max，表示 max 为无限大（Infinity）。\r\n            {min: 900, max: 1500},\r\n            {min: 310, max: 1000},\r\n            {min: 200, max: 300},\r\n            {min: 10, max: 200, label: '10 到 200（自定义label）'},\r\n            // 表示 value 等于 123 的情况。\r\n            {value: 123, label: '123（自定义特殊颜色）', color: 'grey'},\r\n            {max: 5}     // 不指定 min，表示 min 为无限大（-Infinity）。\r\n        ]\r\n```\r\n以 Map 为例\r\n\r\n代码\r\n```python\r\ndef test_visualmap_pieces():\r\n    value = [155, 10, 66, 78]\r\n    attr = [\"福建\", \"山东\", \"北京\", \"上海\"]\r\n    map = Map(\"全国地图示例\", width=1200, height=600)\r\n    map.add(\"\", attr, value, maptype='china',\r\n            is_visualmap=True, is_piecewise=True,\r\n            visual_text_color=\"#000\",\r\n            visual_range_text=[\"\", \"\"],\r\n            pieces=[\r\n                {\r\n                    \"max\": 160,\r\n                    \"min\": 70,\r\n                    \"label\": \"高数值\"\r\n                },\r\n                {\r\n                    \"max\": 69,\r\n                    \"min\": 0,\r\n                    \"label\": \"低数值\"\r\n                },\r\n            ])\r\n    map.render()\r\n```\r\n\r\n效果图\r\n\r\n![image](https://user-images.githubusercontent.com/19553554/36943053-22748c70-1fbd-11e8-86dc-ac3d48f5c4e3.png)\r\n\r\n可以看到，VisualMap 的标签已经被自定义了\r\n\r\nGeo\r\n\r\n代码\r\n```python\r\ndef test_geo_visualmap_pieces():\r\n    data = [\r\n        (\"海门\", 9), (\"鄂尔多斯\", 12), (\"招远\", 12),\r\n        (\"舟山\", 12), (\"齐齐哈尔\", 14), (\"盐城\", 15)\r\n    ]\r\n    geo = Geo(\"全国主要城市空气质量\", \"data from pm2.5\", **style.init_style)\r\n    attr, value = geo.cast(data)\r\n    geo.add(\"\", attr, value, type=\"effectScatter\", is_random=True,\r\n            is_visualmap=True, is_piecewise=True,\r\n            visual_text_color=\"#fff\",\r\n            pieces=[\r\n                {\"min\": 0, \"max\": 13, \"label\": \"0 < x < 13\"},\r\n                {\"min\": 14, \"max\": 16, \"label\": \"14 < x < 16\"},\r\n            ],\r\n            effect_scale=5)\r\n    geo.render()\r\n```\r\n\r\n效果图\r\n\r\n![image](https://user-images.githubusercontent.com/19553554/36943214-f0133fd0-1fbf-11e8-97c6-573a8fb25395.png)\r\n"},"comment":{"url":"https://api.github.com/repos/pyecharts/pyecharts/issues/comments/370207903","html_url":"https://github.com/pyecharts/pyecharts/issues/425#issuecomment-370207903","issue_url":"https://api.github.com/repos/pyecharts/pyecharts/issues/425","id":370207903,"user":{"login":"chenjiandongx","id":19553554,"avatar_url":"https://avatars2.githubusercontent.com/u/19553554?v=4","gravatar_id":"","url":"https://api.github.com/users/chenjiandongx","html_url":"https://github.com/chenjiandongx","followers_url":"https://api.github.com/users/chenjiandongx/followers","following_url":"https://api.github.com/users/chenjiandongx/following{/other_user}","gists_url":"https://api.github.com/users/chenjiandongx/gists{/gist_id}","starred_url":"https://api.github.com/users/chenjiandongx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenjiandongx/subscriptions","organizations_url":"https://api.github.com/users/chenjiandongx/orgs","repos_url":"https://api.github.com/users/chenjiandongx/repos","events_url":"https://api.github.com/users/chenjiandongx/events{/privacy}","received_events_url":"https://api.github.com/users/chenjiandongx/received_events","type":"User","site_admin":false},"created_at":"2018-03-04T07:24:12Z","updated_at":"2018-03-04T07:24:12Z","author_association":"COLLABORATOR","body":"@chfw 这才是正确的效果"}}
{"actor":{"display_login":"chenjiandongx"}}