8000 Add title feature to legend and support legend option for various traces by archmoj · Pull Request #4386 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Add title feature to legend and support legend option for various traces #4386

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 7 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

< 10000 strong class="js-conversation-menu-button">Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add new legend mocks
  • Loading branch information
archmoj committed Nov 25, 2019
commit 264044f36fa13ed603c998d910f8ed7373b1c641
Binary file added test/image/baselines/geo_choropleth-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/gl3d_traces-with-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/heatmap_legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/histogram2d_legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/mapbox_density0-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions test/image/mocks/geo_choropleth-legend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"data": [
{
"type": "choropleth",
"name": "Canada",
"locations": ["CAN"],
"z": [1],
"colorscale": [[0, "blue"], [1, "blue"]],
Copy link
Contributor

Choose a reason for hiding this comment

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

cc #3468 and #1747

"showscale": false,
"showlegend": true
},
{
"type": "choropleth",
"name": "USA",
"locations": ["USA"],
"z": [1],
"colorscale": [[0, "orange"], [1, "orange"]],
"showscale": false,
"showlegend": true
},
{
"type": "choropleth",
"name": "Brazil",
"locations": ["BRA"],
"z": [1],
"colorscale": [[0, "green"], [1, "green"]],
"showscale": false,
"showlegend": true
},
{
"type": "choropleth",
"name": "China",
"locations": ["CHN"],
"z": [1],
"colorscale": [[0, "red"], [1, "red"]],
"showscale": false,
"showlegend": true
}
],
"layout": {
"title": {
"text": "choropleth with legends and legend title"
},
"legend": {
"borderwidth": 5,
"bordercolor": "gray",
"bgcolor": "yellow",
"orientation": "h",
"title": {
"text": "<b>World</b> <i>Countries</i>",
"font": {
"size": 15,
"family": "Times New Roman"
}
}
},
"paper_bgcolor": "lightblue",
"width": 500,
"height": 350,
"margin": {
"t": 50,
"b": 0,
"l": 0,
"r": 0
}
}
}
194 changes: 194 additions & 0 deletions test/image/mocks/geo_choropleth-usa_legend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
{
"data": [
{
"autocolorscale": false,
"showlegend": true,
"showscale": false,
"colorscale": "Portland",
"text": [
"Alabama<br>--<br>Beef: 34.4<br>Pork: 10.6<br>Poultry: 481.0<br>Dairy: 4.06<br>--<br>Fruits: 25.11<br>Veggies: 14.33<br>--<br>Wheat: 70.0<br>Corn: 34.9<br>Cotton: 317.61",
"Alaska<br>--<br>Beef: 0.2<br>Pork: 0.1<br>Poultry: 0.0<br>Dairy: 0.19<br>--<br>Fruits: 0.0<br>Veggies: 1.56<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"Arizona<br>--<br>Beef: 71.3<br>Pork: 17.9<br>Poultry: 0.0<br>Dairy: 105.48<br>--<br>Fruits: 60.27<br>Veggies: 386.91<br>--<br>Wheat: 48.7<br>Corn: 7.3<br>Cotton: 423.95",
"Arkansas<br>--<br>Beef: 53.2<br>Pork: 29.4<br>Poultry: 562.9<br>Dairy: 3.53<br>--<br>Fruits: 6.88<br>Veggies: 11.45<br>--<br>Wheat: 114.5<br>Corn: 69.5<br>Cotton: 665.44",
" California<br>--<br>Beef: 228.7<br>Pork: 11.1<br>Poultry: 225.4<br>Dairy: 929.95<br>--<br>Fruits: 8736.4<br>Veggies: 2106.79<br>--<br>Wheat: 249.3<br>Corn: 34.6<br>Cotton: 1064.95",
"Colorado<br>--<br>Beef: 261.4<br>Pork: 66.0<br>Poultry: 14.0<br>Dairy: 71.94<br>--<br>Fruits: 17.99<br>Veggies: 118.27<br>--<br>Wheat: 400.5<br>Corn: 183.2<br>Cotton: 0.0",
"Connecticut<br>--<br>Beef: 1.1<br>Pork: 0.1<br>Poultry: 6.9<br>Dairy: 9.49<br>--<br>Fruits: 13.1<br>Veggies: 11.16<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"Delaware<br>--<br>Beef: 0.4<br>Pork: 0.6<br>Poultry: 114.7<br>Dairy: 2.3<br>--<br>Fruits: 1.53<br>Veggies: 20.03<br>--<br>Wheat: 22.9<br>Corn: 26.9<br>Cotton: 0.0",
"Florida<br>--<br>Beef: 42.6<br>Pork: 0.9<br>Poultry: 56.9<br>Dairy: 66.31<br>--<br>Fruits: 1371.36<br>Veggies: 450.86<br>--<br>Wheat: 1.8<br>Corn: 3.5<br>Cotton: 78.24",
"Georgia<br>--<br>Beef: 31.0<br>Pork: 18.9<br>Poultry: 630.4<br>Dairy: 38.38<br>--<br>Fruits: 233.51<br>Veggies: 154.77<br>--<br>Wheat: 65.4<br>Corn: 57.8<br>Cotton: 1154.07",
"Hawaii<br>--<br>Beef: 4.0<br>Pork: 0.7<br>Poultry: 1.3<br>Dairy: 1.16<br>--<br>Fruits: 55.51<br>Veggies: 24.83<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"Idaho<br>--<br>Beef: 119.8<br>Pork: 0.0<br>Poultry: 2.4<br>Dairy: 294.6<br>--<br>Fruits: 21.64<br>Veggies: 319.19<br>--<br>Wheat: 568.2<br>Corn: 24.0<br>Cotton: 0.0",
"Illinois<br>--<br>Beef: 53.7<br>Pork: 394.0<br>Poultry: 14.0<br>Dairy: 45.82<br>--<br>Fruits: 12.53<br>Veggies: 39.95<br>--<br>Wheat: 223.8<br>Corn: 2228.5<br>Cotton: 0.0",
"Indiana<br>--<br>Beef: 21.9<br>Pork: 341.9<br>Poultry: 165.6<br>Dairy: 89.7<br>--<br>Fruits: 12.98<br>Veggies: 37.89<br>--<br>Wheat: 114.0<br>Corn: 1123.2<br>Cotton: 0.0",
"Iowa<br>--<br>Beef: 289.8<br>Pork: 1895.6<br>Poultry: 155.6<br>Dairy: 107.0<br>--<br>Fruits: 3.24<br>Veggies: 7.1<br>--<br>Wheat: 3.1<br>Corn: 2529.8<br>Cotton: 0.0",
"Kansas<br>--<br>Beef: 659.3<br>Pork: 179.4<br>Poultry: 6.4<br>Dairy: 65.45<br>--<br>Fruits: 3.11<br>Veggies: 9.32<br>--<br>Wheat: 1426.5<br>Corn: 457.3<br>Cotton: 43.98",
"Kentucky<br>--<br>Beef: 54.8<br>Pork: 34.2<br>Poultry: 151.3<br>Dairy: 28.27<br>--<br>Fruits: 6.6<br>Veggies: 0.0<br>--<br>Wheat: 149.3<br>Corn: 179.1<br>Cotton: 0.0",
"Louisiana<br>--<br>Beef: 19.8<br>Pork: 0.8<br>Poultry: 77.2<br>Dairy: 6.02<br>--<br>Fruits: 17.83<br>Veggies: 17.25<br>--<br>Wheat: 78.7<br>Corn: 91.4<br>Cotton: 280.42",
"Maine<br>--<br>Beef: 1.4<br>Pork: 0.5<br>Poultry: 10.4<br>Dairy: 16.18<br>--<br>Fruits: 52.01<br>Veggies: 62.9<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"Maryland<br>--<br>Beef: 5.6<br>Pork: 3.1<br>Poultry: 127.0<br>Dairy: 24.81<br>--<br>Fruits: 12.9<br>Veggies: 20.43<br>--<br>Wheat: 55.8<br>Corn: 54.1<br>Cotton: 0.0",
"Massachusetts<br>--<br>Beef: 0.6<br>Pork: 0.5<br>Poultry: 0.6<br>Dairy: 5.81<br>--<br>Fruits: 80.83<br>Veggies: 21.13<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"Michigan<br>--<br>Beef: 37.7<br>Pork: 118.1<br>Poultry: 32.6<br>Dairy: 214.82<br>--<br>Fruits: 257.69<br>Veggies: 189.96<br>--<br>Wheat: 247.0<br>Corn: 381.5<br>Cotton: 0.0",
"Minnesota<br>--<br>Beef: 112.3<br>Pork: 740.4<br>Poultry: 189.2<br>Dairy: 218.05<br>--<br>Fruits: 7.91<br>Veggies: 120.37<br>--<br>Wheat: 538.1<br>Corn: 1264.3<br>Cotton: 0.0",
"Mississippi<br>--<br>Beef: 12.8<br>Pork: 30.4<br>Poultry: 370.8<br>Dairy: 5.45<br>--<br>Fruits: 17.04<br>Veggies: 27.87<br>--<br>Wheat: 102.2<br>Corn: 110.0<br>Cotton: 494.75",
"Missouri<br>--<br>Beef: 137.2<br>Pork: 277.3<br>Poultry: 196.1<br>Dairy: 34.26<br>--<br>Fruits: 13.18<br>Veggies: 17.9<br>--<br>Wheat: 161.7<br>Corn: 428.8<br>Cotton: 345.29",
"Montana<br>--<br>Beef: 105.0<br>Pork: 16.7<br>Poultry: 1.7<br>Dairy: 6.82<br>--<br>Fruits: 3.3<br>Veggies: 45.27<br>--<br>Wheat: 1198.1<br>Corn: 5.4<br>Cotton: 0.0",
"Nebraska<br>--<br>Beef: 762.2<br>Pork: 262.5<br>Poultry: 31.4<br>Dairy: 30.07<br>--<br>Fruits: 2.16<br>Veggies: 53.5<br>--<br>Wheat: 292.3<br>Corn: 1735.9<br>Cotton: 0.0",
"Nevada<br>--<br>Beef: 21.8<br>Pork: 0.2<br>Poultry: 0.0<br>Dairy: 16.57<br>--<br>Fruits: 1.19<br>Veggies: 27.93<br>--<br>Wheat: 5.4<br>Corn: 0.0<br>Cotton: 0.0",
"New Hampshire<br>--<br>Beef: 0.6<br>Pork: 0.2<br>Poultry: 0.8<br>Dairy: 7.46<br>--<br>Fruits: 7.98<br>Veggies: 4.5<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"New Jersey<br>--<br>Beef: 0.8<br>Pork: 0.4<br>Poultry: 4.6<br>Dairy: 3.37<br>--<br>Fruits: 109.45<br>Veggies: 56.54<br>--<br>Wheat: 6.7<br>Corn: 10.1<br>Cotton: 0.0",
"New Mexico<br>--<br>Beef: 117.2<br>Pork: 0.1<br>Poultry: 0.3<br>Dairy: 191.01<br>--<br>Fruits: 101.9<br>Veggies: 43.88<br>--<br>Wheat: 13.9<br>Corn: 11.2<br>Cotton: 72.62",
"New York<br>--<br>Beef: 22.2<br>Pork: 5.8<br>Poultry: 17.7<br>Dairy: 331.8<br>--<br>Fruits: 202.56<br>Veggies: 143.37<br>--<br>Wheat: 29.9<br>Corn: 106.1<br>Cotton: 0.0",
"North Carolina<br>--<br>Beef: 24.8<br>Pork: 702.8<br>Poultry: 598.4<br>Dairy: 24.9<br>--<br>Fruits: 74.47<br>Veggies: 150.45<br>--<br>Wheat: 200.3<br>Corn: 92.2<br>Cotton: 470.86",
"North Dakota<br>--<br>Beef: 78.5<br>Pork: 16.1<br>Poultry: 0.5<br>Dairy: 8.14<br>--<br>Fruits: 0.25<br>Veggies: 130.79<br>--<br>Wheat: 1664.5<br>Corn: 236.1<br>Cotton: 0.0",
"Ohio<br>--<br>Beef: 36.2<br>Pork: 199.1<br>Poultry: 129.9<br>Dairy: 134.57<br>--<br>Fruits: 27.21<br>Veggies: 53.53<br>--<br>Wheat: 207.4<br>Corn: 535.1<br>Cotton: 0.0",
"Oklahoma<br>--<br>Beef: 337.6<br>Pork: 265.3<br>Poultry: 131.1<br>Dairy: 24.35<br>--<br>Fruits: 9.24<br>Veggies: 8.9<br>--<br>Wheat: 324.8<br>Corn: 27.5<br>Cotton: 110.54",
"Oregon<br>--<br>Beef: 58.8<br>Pork: 1.4<br>Poultry: 14.2<br>Dairy: 63.66<br>--<br>Fruits: 315.04<br>Veggies: 126.5<br>--<br>Wheat: 320.3<br>Corn: 11.7<br>Cotton: 0.0",
"Pennsylvania<br>--<br>Beef: 50.9<br>Pork: 91.3<br>Poultry: 169.8<br>Dairy: 280.87<br>--<br>Fruits: 89.48<br>Veggies: 38.26<br>--<br>Wheat: 41.0<br>Corn: 112.1<br>Cotton: 0.0",
"Rhode Island<br>--<br>Beef: 0.1<br>Pork: 0.1<br>Poultry: 0.2<br>Dairy: 0.52<br>--<br>Fruits: 2.83<br>Veggies: 3.02<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"South Carolina<br>--<br>Beef: 15.2<br>Pork: 10.9<br>Poultry: 186.5<br>Dairy: 7.62<br>--<br>Fruits: 53.45<br>Veggies: 42.66<br>--<br>Wheat: 55.3<br>Corn: 32.1<br>Cotton: 206.1",
"South Dakota<br>--<br>Beef: 193.5<br>Pork: 160.2<br>Poultry: 29.3<br>Dairy: 46.77<br>--<br>Fruits: 0.8<br>Veggies: 4.06<br>--<br>Wheat: 704.5<br>Corn: 643.6<br>Cotton: 0.0",
"Tennessee<br>--<br>Beef: 51.1<br>Pork: 17.6<br>Poultry: 82.4<br>Dairy: 21.18<br>--<br>Fruits: 6.23<br>Veggies: 24.67<br>--<br>Wheat: 100.0<br>Corn: 88.8<br>Cotton: 363.83",
"Texas<br>--<br>Beef: 961.0<br>Pork: 42.7<br>Poultry: 339.2<br>Dairy: 240.55<br>--<br>Fruits: 99.9<br>Veggies: 115.23<br>--<br>Wheat: 309.7<br>Corn: 167.2<br>Cotton: 2308.76",
"Utah<br>--<br>Beef: 27.9<br>Pork: 59.0<br>Poultry: 23.1<br>Dairy: 48.6<br>--<br>Fruits: 12.34<br>Veggies: 6.6<br>--<br>Wheat: 42.8<br>Corn: 5.3<br>Cotton: 0.0",
"Vermont<br>--<br>Beef: 6.2<br>Pork: 0.2<br>Poultry: 0.9<br>Dairy: 65.98<br>--<br>Fruits: 8.01<br>Veggies: 4.05<br>--<br>Wheat: 0.0<br>Corn: 0.0<br>Cotton: 0.0",
"Virginia<br>--<br>Beef: 39.5<br>Pork: 16.9<br>Poultry: 164.7<br>Dairy: 47.85<br>--<br>Fruits: 36.48<br>Veggies: 27.25<br>--<br>Wheat: 77.5<br>Corn: 39.5<br>Cotton: 64.84",
"Washington<br>--<br>Beef: 59.2<br>Pork: 0.0<br>Poultry: 35.6<br>Dairy: 154.18<br>--<br>Fruits: 1738.57<br>Veggies: 363.79<br>--<br>Wheat: 786.3<br>Corn: 29.5<br>Cotton: 0.0",
"West Virginia<br>--<br>Beef: 12.0<br>Pork: 0.3<br>Poultry: 45.4<br>Dairy: 3.9<br>--<br>Fruits: 11.54<br>Veggies: 0.0<br>--<br>Wheat: 1.6<br>Corn: 3.5<br>Cotton: 0.0",
"Wisconsin<br>--<br>Beef: 107.3<br>Pork: 38.6<br>Poultry: 34.5<br>Dairy: 633.6<br>--<br>Fruits: 133.8<br>Veggies: 148.99<br>--<br>Wheat: 96.7<br>Corn: 460.5<br>Cotton: 0.0",
"Wyoming<br>--<br>Beef: 75.1<br>Pork: 33.2<br>Poultry: 0.1<br>Dairy: 2.89<br>--<br>Fruits: 0.17<br>Veggies: 10.23<br>--<br>Wheat: 20.7<br>Corn: 9.0<br>Cotton: 0.0"
],
"locations": [
"AL",
"AK",
"AZ",
"AR",
"CA",
"CO",
"CT",
"DE",
"FL",
"GA",
"HI",
"ID",
"IL",
"IN",
"IA",
"KS",
"KY",
"LA",
"ME",
"MD",
"MA",
"MI",
"MN",
"MS",
"MO",
"MT",
"NE",
"NV",
"NH",
"NJ",
"NM",
"NY",
"NC",
"ND",
"OH",
"OK",
"OR",
"PA",
"RI",
"SC",
"SD",
"TN",
"TX",
"UT",
"VT",
"VA",
"WA",
"WV",
"WI",
"WY"
],
"colorbar": {
"title": "Millions USD"
},
"type": "choropleth",
"z": [
1390.63,
13.31,
1463.17,
3586.02,
16472.88,
1851.33,
259.62,
282.19,
3764.09,
2860.84,
401.84,
2078.89,
8709.48,
5050.23,
11273.76,
4589.01,
1889.15,
1914.23,
278.37,
692.75,
248.65,
3164.16,
7192.33,
2170.8,
3933.42,
1718,
7114.13,
139.89,
73.06,
500.4,
751.58,
1488.9,
3806.05,
3761.96,
3979.79,
1646.41,
1794.57,
1969.87,
31.59,
929.93,
3770.19,
1535.13,
6648.22,
453.39,
180.14,
1146.48,
3894.81,
138.89,
3090.23,
349.69
],
"locationmode": "USA-states",
"name": "Exports"
}
],
"layout": {
"autosize": true,
"title": {
"text": "2011 US Agriculture Exports by State"
},
"height": 250,
"width": 450,
"margin": {
"t": 50,
"b": 0,
"l": 0,
"r": 0
},
"geo": {
"showlakes": true,
"scope": "usa",
"projection": {
"type": "albers usa"
},
"lakecolor": "rgb(255, 255, 255)"
}
}
}
Loading
0