How to represent a min and max value of multiple categories in x axis as a candle stick plot in python. need to have unique colours for each category - charts

# Create a list of dictionaries representing each row of the data
data = [
{"Team": "CHENNAI SUPER KINGS", "min": 1525, "max": 1625, "Is_awarded": "Yes"},
{"Team": "LUCKNOW SUPER GIANTS", "min": 700, "max": 1600, "Is_awarded": None},
{"Team": "RAJASTHAN ROYALS", "min": 200, "max": 725, "Is_awarded": None},
{"Team": "ROYAL CHALLENGERS BANGALORE", "min": 220, "max": 650, "Is_awarded": None},
{"Team": "SUNRISERS HYDERABAD", "min": 775, "max": 1475, "Is_awarded": None},
]
# Create the dataframe from the list of dictionaries
df = pd.DataFrame(data)
I want to plot a candle stick chart representing the team name in X axis and corresponding min max value. the colour of the candle stick should be unique with respect to the third column Is_awarded; if 'yes' then red & if 'NA' blue. is there a way?
I have tried plotly but I'm not able to colour code it.

Related

How to parse dynamic json?

I'm new to flutter development, I can't figure out how to parse json correctly, since lists are changeable.
Maybe there are some libraries that allow you to turn json into an object right away?
{
"name": "Nuan",
"key": "wqewewrwerer",
"places": {
"1": {
"place": 1,
"numberPlaces": 4,
"type": "TABLE"
},
"2": {
"place": 2,
"numberPlaces": 4,
"type": "TABLE"
},
"3": {
"place": 3,
"numberPlaces": 4,
"type": "TABLE"
}
},
"menu": {
"categories": [{
"name": "Salads",
"elements": [{
"id": 1,
"name": "Caesar salad",
"img": "cesar.jpg",
"price": 4,
"currency": "USD",
"weight": "222",
"typeWeight": "g",
"time": 3,
"calories": 500,
"description": "The salad\u0027s creation is generally attributed to the restaurateur Caesar Cardini, an Italian immigrant who operated restaurants in Mexico and the United States. His daughter Rosa recounted that her father invented the salad at his Prohibition-era restaurant in Tijuana, Mexico when a Fourth of July rush in 1924 depleted the kitchen\u0027s supplies. (Cardini lived in San Diego but ran the family restaurant in Tijuana to attract American customers seeking to circumvent the restrictions of the Prohibition). Cardini made do with what he had, adding the dramatic flair of the table-side tossing \"by the chef.\" A number of Cardini\u0027s staff have said that they invented the dish.",
"structure": "croutons, romaine, anchovies, parmeasan cheese, olive oil, vinegar and plenty of black pepper."
}, {
"id": 2,
"name": "Greek salad",
"img": "grek.jpg",
"price": 5,
"currency": "USD",
"weight": "220",
"typeWeight": "g",
"time": 3,
"calories": 300,
"description": "Various other salads have also been called \"Greek\" in the English language in the last century, including some with no apparent connection to Greek cuisine. A 1925 Australian newspaper described a Greek salad of boiled squash dressed with sour milk; a 1934 American newspaper described a mayonnaise-dressed lettuce salad with shredded cabbage and carrots",
"structure": "Lettuce, tomatoes, feta, olives, cucumber"
}, {
"id": 3,
"name": "Salmon salad",
"img": "semga.jpg",
"price": 8,
"currency": "USD",
"weight": "250",
"typeWeight": "g",
"time": 3,
"calories": 400
}, {
"id": 4,
"name": "Hunting salad",
"img": "hunting.jpg",
"price": 7,
"currency": "USD",
"weight": "220",
"typeWeight": "g",
"time": 4,
"calories": 390,
"description": "Hunting salad has such a name, since it includes meat of animals caught by hunters. History is silent at what point the game meat was replaced with beef, hunting sausages or even pork, but in our reality it is these meat products that are used for such a salad. The salad turns out to be very satisfying, nutritious and quite dense � ideal for men\u0027s snacks.",
"structure": "sausages, potatoes, greens"
}]
}, {
"name": "soups",
"elements": [{
"id": 5,
"name": "Solyanka soup",
"img": "solyanka.jpg",
"price": 10,
"currency": "USD",
"weight": "300",
"typeWeight": "g",
"time": 15,
"calories": 300,
"description": "There is no consensus on the correctness of the name selyanka in relation to soup. Russian linguist and writer L. I. Skvortsov writes about the traditionality of the name selyanka and the ambiguity of the etymology of the word \"solyanka\", at the same time, Russian historian, researcher and popularizer of cooking V. V. Pokhlebkin writes about the incorrectness and distortion of the name selyanka and claims that the name solyanka is fixed in the \"House-building\" of 1547, while the term selyanka took root only in the XIX century and at the beginning of the XX century was again replaced by the term solyanka. The Dictionary of the Russian Academy (1794) indicated the name solyanka as the main variant, and marked the selyanka variant as \"simple\"",
"structure": "sausage, potato, onion, tomato, pickle"
}, {
"id": 6,
"name": "Borsch soup",
"img": "borsch.jpg",
"price": 8,
"currency": "USD",
"weight": "300",
"typeWeight": "g",
"time": 15,
"calories": 300,
"description": "In the old days, borscht was called soup made from borscht. Later borscht was cooked on beet kvass: it was diluted with water, the mixture was poured into a clay pot or cast iron and brought to a boil. Chopped beets, cabbage, carrots and other vegetables were put in boiling water and put the pot in the oven. The cooked borscht was salted and refilled",
"structure": "meat, carrots, onions, potatoes, beets, white cabbage, beans, tomato paste, vegetable oil, bay leaf, sugar, vinegar"
}, {
"id": 7,
"name": "Mushroom soup",
"img": "mushroom.jpg",
"price": 10,
"currency": "USD",
"weight": "230",
"typeWeight": "g",
"time": 16,
"calories": 320,
"description": "Cream soup with mushrooms has been prepared since about the 17th century, when entrepreneurs already learned how to grow champignons in artificial conditions. It was in France, so this country is considered the birthplace of mushroom soups-puree. But the soup with dried porcini mushrooms is cooked on water and already only one aroma, spreading around the house, can drive even the most refined gourmets crazy.",
"structure": "potatoes, onions, herbs, salt, pepper, vegetable oil, mushrooms, soft processed cheese"
}]
}, {
"elements": [{
"id": 8,
"name": "Crackers",
"img": "crackers.png",
"price": 4,
"currency": "USD",
"weight": "200",
"typeWeight": "g",
"time": 12,
"calories": 600,
"description": "Crackers are second-baked bread, \"dried for the purpose of either storage or further culinary use in various dishes,\" is the definition of the product given by William Pohlebkin (1923-2000), a Russian historian and writer. The main distinguishing feature of crackers from all other bakery products is their reduced humidity, ideally no more than forty-nine percent, more often - up to eight.",
"structure": "bread, garlic, salt, oil"
}, {
"id": 9,
"name": "Croutons",
"img": "croutons.png",
"price": 4,
"currency": "USD",
"weight": "200",
"typeWeight": "g",
"time": 12,
"calories": 580,
"description": "Croutons are made from any bread and are used as a light snack, for example, croutons with garlic for beer, or as an ingredient in soups, broths, salads (\"Caesar\"), cutlets and other dishes. To add to soups (French onion soup), bread is simply fried with salt and/or black pepper.",
"structure": "white bread, garlic, salt, pepper, oil"
}, {
"id": 11,
"name": "Chips",
"img": "chips.png",
"price": 3,
"currency": "USD",
"weight": "100",
"typeWeight": "g",
"time": 3,
"calories": 330,
"structure": "potatoes, salt, pepper, oil"
}]
}]
},
"description": "There are many things in the world, friend Horatio, that our wise men never dreamed of"
}
I've seen standard ways where data is passed to the constructor, but it's not entirely clear how to embed large json there
You can use the json2Dart utility to generate your dart objects and call the fromJson() method on your root object :)

Remove empty space from Streamlit Echarts

I am rendering a gauge component in the following way, within my Streamlit app:
option = {
"series": [
{
"type": "gauge",
"startAngle": 180,
"endAngle": 0,
"min": min_range_val,
"max": max_range_val,
"center": ["40%", "40%"],
"splitNumber": 5,
"axisLine": {
"lineStyle": {
"width": 6,
"color": [
[0.25, "#FF403F"],
[0.5, "#ffa500"],
[0.75, "#FDDD60"],
[1, "#64C88A"],
],
}
},
"pointer": {
"icon": "path://M12.8,0.7l12,40.1H0.7L12.8,0.7z",
"length": "12%",
"width": 30,
"offsetCenter": [0, "-60%"],
"itemStyle": {"color": "auto"},
},
"axisTick": {"length": 10, "lineStyle": {"color": "auto", "width": 2}},
"splitLine": {"length": 15, "lineStyle": {"color": "auto", "width": 5}},
"axisLabel": {
"color": "#464646",
"fontSize": 12,
"distance": -60,
},
"title": {"offsetCenter": [0, "-20%"], "fontSize": 20},
"detail": {
"fontSize": 30,
"offsetCenter": [0, "0%"],
"valueAnimation": True,
"color": "auto",
"formatter": "{value}%",
},
"data": [{"value": value, "name": caption}],
}
]
}
st_echarts(option, width="450px", height="350px", key="gauge")
However, it seems like an additional empty extra white space is added at the bottom of the component (as from the following image).
How can I effectively remove that and keep only a tiny margin all around the gauge?
The following parameters must be added:
radius: '120%',
center: ['50%', '80%']
The latter one should be adjusted according to specific use cases.

Is it possible to change width a row in Grafana?

I wanna change width a row in Grafana v5.4.0.
like this screen ...
I'm trying to change JSON Model...
"collapsed": false,
"gridPos": {
"h": 1,
"w": 18,
"x": 0,
"y": 14
},
"id": 12,
"panels": [],
"title": "row2",
"type": "row"
I modified 'w'value from 24 to 18.
'Save changes' is is Succeed.
But, Actually not changed.
unfortunately the row size cannot be changed. Rows are always 12 units wide.
Check these docs: https://docs.huihoo.com/grafana/2.6/guides/basic_concepts/index.html

how we get uber api results in us dollar currency code with Indian account

I have Indian uber developer account , so its give me results in INR currency _code , but I want results in us dollar , anybody tell me how it is possible.
{
"prices": [
{
"localized_display_name": "uberGO",
"distance": 0,
"display_name": "uberGO",
"product_id": "40269682-90dc-4d18-8c38-5b4035e35296",
"high_estimate": 40,
"surge_multiplier": 1,
"minimum": 40,
"low_estimate": 40,
"duration": 0,
"estimate": "₹ 40",
"currency_code": "INR"
},
{
"localized_display_name": "uberX",
"distance": 0,
"display_name": "uberX",
"product_id": "8e1107eb-82f3-4ed4-9969-e6c7c73d8c86",
"high_estimate": 50,
"surge_multiplier": 1,
"minimum": 50,
"low_estimate": 50,
"duration": 0,
"estimate": "₹ 50",
"currency_code": "INR"
}
]
}
I believe this link should help: https://developer.uber.com/docs/ride-requests/guides/localization
"Currency: Currency is rendered in the local currency of a given latitude & longitude pair. A fare estimate in San Francisco will be given in USD, while a fare estimate in Paris will be displayed in EUR. We also provide the ISO 4217 currency code for your own conversions."
Cheers.

AmCharts set to always display labels on stacked columns

I am trying to make my stacked column amChart always display value labels on the columns. Even if they do not fit.
I am using this code:
var qtrchart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "none",
"legend": {
"autoMargins": false,
"borderAlpha": 0.2,
"equalWidths": false,
"horizontalGap": 10,
"markerSize": 10,
"useGraphSettings": true,
"valueAlign": "left",
"valueWidth": 0
},
"dataProvider": [{
"QTR":"FY14 Q2",
"DSAT":0.032602706911007306,
"Neutral":0.069205892921307938,
"CSAT":0.89819140016768484},
{"QTR":"FY14 Q3",
"DSAT":0.038609212354234618,
"Neutral":0.060273567620017982,
"CSAT":0.90111722002574746},
{"QTR":"FY14 Q4","DSAT":0.038757557172180282,
"Neutral":0.058425780441887579,
"CSAT":0.90281666238593217},
{"QTR":"FY15 Q1",
"DSAT":0.12391774891774893,
"Neutral":0.10355411255411255,
"CSAT":0.77252813852813851}],
"valueAxes": [{
"stackType": "100%",
"axisAlpha": 0,
"gridAlpha": 0,
"labelsEnabled": false,
"position": "left"
}],
"graphs": [{
"balloonText": "[[title]], [[category]]<br><span style='font-size:14px;'>[[percents]]%</span>",
"fillColors": "#87898b",
"lineColor": "#87898b",
"color": "#ffffff",
"fillAlphas": 0.9,
"fontSize": 11,
"labelText": "[[percents]]%",
"lineAlpha": 0.5,
"title": "DSAT",
"type": "column",
"valueField": "DSAT"
}, {
"balloonText": "[[title]], [[category]]<br><span style='font-size:14px;'>[[percents]]%</span>",
"fillColors": "#822980",
"lineColor": "#822980",
"color": "#ffffff",
"fillAlphas": 0.9,
"fontSize": 11,
"labelText": "[[percents]]%",
"lineAlpha": 0.5,
"title": "Neutral",
"type": "column",
"valueField": "Neutral"
}, {
"balloonText": "[[title]], [[category]]<br><span style='font-size:14px;'>[[percents]]%</span>",
"fillColors": "#0096d6",
"lineColor": "#0096d6",
"color": "#ffffff",
"fillAlphas": 0.9,
"fontSize": 11,
"labelText": "[[percents]]%",
"lineAlpha": 0.5,
"title": "CSAT",
"type": "column",
"valueField": "CSAT"
}],
"marginTop": 30,
"marginRight": 0,
"marginLeft": 0,
"marginBottom": 40,
"autoMargins": false,
"categoryField": "QTR",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha": 0,
"gridAlpha": 0
},
"percentPrecision": 1,
"data_labels_always_on": true
});
http://jsfiddle.net/Cww3D/288/
Is there a way to achieve this? I found older versions had a special parameter "data_labels_always_on" that you could set to true. But that does not work.
Any ideas?
I'm using AmChart also, and found this that may help you, that goes on "graph" options:
showAllValueLabels Boolean false If graph's type is column and labelText is set, graph hides labels which do not fit into the column's space. If you don't want these labels to be hidden, set this to true.
Hope this helps you!
I got the labels to display by setting the graphs label position, like this:
"labelPosition": "bottom"
here is the JSFiddle: http://jsfiddle.net/Cww3D/291/
Apparently, this forces the labels to display, while the one you'd expect, "showAllValueLabels": true does not.
Weird!
The text labels are not showing because the font size assigned is larger than the space allowed. Modifying the "fontSize" property in the first two of the three "graphs" objects from 11 to 3 displays the percent values you are looking for. However, the font size is so small it isn't very legible even in the fourth column. It's not a solution, but maybe a starting point for you to investigate further?
No screen cap, sorry, I'm still new here.