NotCoffee418 / TradingView.Blazor

Simple component for basic TradingView chart in Blazor supporting OHLC candle, volume and markers.
Apache License 2.0
36 stars 11 forks source link

Any way to specify time scale on the chart? #7

Closed cyberyaga closed 2 years ago

cyberyaga commented 2 years ago

First of all... Thank you for this component... It's a simple component that serves a good purpose.

I am using it in my web page. But I am running into the issue of my candles being one sided on the chart when it loads.

Here is an example: image

I know that in the TradingView API reference there is a way to provide the time scale of the chart. Or even to resize the chart with the candle data that it has.

But this is not available on your component. Would that be something that it could be made available?

I would try to take a swing at it, but I'm horrible with JS and the way Blazor interacts with it.

Also, another thing... I've noticed that when the price data is very small (over 3 decimal places) the price doesn't reflect in the price scale. Very small numbers are common in markets like crypto. Is that also something that can be addressed.

Thanks again for the work you've done.

NotCoffee418 commented 2 years ago

It's been a while since I touched this library but I'll take some time and see what i can do for you.

NotCoffee418 commented 2 years ago

Both issues have been addressed. You can upgrade to v1.0.5 to take advantage of them.

To change the decimal precision in the price chart you can set the new chart option RightPriceScaleDecimalPrecision to the amount of decimals you want.

The empty space will automatically no longer occur, as the chart will auto fit immidiately after creation.

Additionally, you can pass in your own arguments directly into the js library with the following new properties in ChartOptions:

// -- Custom definitions
/// <summary>
/// Options defined here will be added to the chart when calling createChart()
/// Example usage:
/// options.CustomChartDefinitions["height"] = 500;
/// </summary>
public Dictionary<string, dynamic> CustomChartDefinitions { get; set; } = new();

/// <summary>
/// Options defined here will be added to the chart when calling addCandlestickSeries()
/// Example usage:
/// options.CustomCandleSeriesDefinitions["borderVisible"] = false;
/// </summary>
public Dictionary<string, dynamic> CustomCandleSeriesDefinitions { get; set; } = new();

/// <summary>
/// Options defined here will be added to the chart when calling addHistogramSeries()
/// Example usage:
/// options.CustomVolumeSeriesDefinitions["color"] = "#26a69a";
/// </summary>
public Dictionary<string, dynamic> CustomVolumeSeriesDefinitions { get; set; } = new();
cyberyaga commented 2 years ago

Both issues have been addressed. You can upgrade to v1.0.5 to take advantage of them.

To change the decimal precision in the price chart you can set the new chart option RightPriceScaleDecimalPrecision to the amount of decimals you want.

The empty space will automatically no longer occur, as the chart will auto fit immidiately after creation.

Additionally, you can pass in your own arguments directly into the js library with the following new properties in ChartOptions:

// -- Custom definitions
/// <summary>
/// Options defined here will be added to the chart when calling createChart()
/// Example usage:
/// options.CustomChartDefinitions["height"] = 500;
/// </summary>
public Dictionary<string, dynamic> CustomChartDefinitions { get; set; } = new();

/// <summary>
/// Options defined here will be added to the chart when calling addCandlestickSeries()
/// Example usage:
/// options.CustomCandleSeriesDefinitions["borderVisible"] = false;
/// </summary>
public Dictionary<string, dynamic> CustomCandleSeriesDefinitions { get; set; } = new();

/// <summary>
/// Options defined here will be added to the chart when calling addHistogramSeries()
/// Example usage:
/// options.CustomVolumeSeriesDefinitions["color"] = "#26a69a";
/// </summary>
public Dictionary<string, dynamic> CustomVolumeSeriesDefinitions { get; set; } = new();

Wow... Thanks a million... Really appreciate this.