'Html sizing display issue for TradingView widget
This question is focused around HTML and CSS sizing display. Though it the details are TradingView widget focused, I expect the answer to be in just CSS so don't be scared by them. An excellent guide is here: https://github.com/mmmy/css3demos/wiki/Widget-Constructor
The rest of the question is from here: https://github.com/mteam88/justpython/issues/1 I am trying to configure the TradingView widgets (see https://www.tradingview.com/widget/advanced-chart/) to the correct size on my website. It works fine with pixels, but that is built in. I am trying to configure the height to about 45%. The width works fine at 30%, but changing height in the same place does nothing.
It is a Flask app with jinja2
Changing width in index.css
#tradingview_962a1 {
width: 30%;
height: 100%;
};
Renders like this:

Removing the width property makes it render like this:

Here is the code that actually is the source of the widget in flaskr/logic/stockwidget.py:`
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container" style="height:50%;">
<div id="tradingview_962a1"></div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget(
{{
"autosize": true,
"symbol": "{ticker}",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "dark",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"hide_top_toolbar": true,
"save_image": false,
"show_popup_button": true,
"popup_width": "1000",
"popup_height": "650",
"container_id": "tradingview_962a1"
}}
);
</script>
</div>
<!-- TradingView Widget END -->
Solution 1:[1]
Use List<double> in coord
public class Root
{
[JsonProperty("boneID")]
public long BoneId { get; set; }
[JsonProperty("coord")]
public List<double> Coord { get; set; }
}
and deserialize using list
var result = JsonConvert.DeserializeObject<List<Root>>(json);
foreach(var datas in result){
Console.WriteLine(datas.Coord[0]);
}
check your example in this site
Solution 2:[2]
Define boneId as an int and coord as an array of double and deserialze the object into a bone rather than body
public class Bone
{
public int boneID;
public double[] coord;
}
Bone bones;
string path = @"F:\code\python\project\AR_project\data.txt";
using (StreamReader r = new StreamReader(path))
{
string json = r.ReadToEnd();
Console.WriteLine(json);
bones = JsonConvert.DeserializeObject <Bone> (json);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniel |
| Solution 2 | Jesse Favelle |
