-
Notifications
You must be signed in to change notification settings - Fork 573
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
Question: How to subscribe to DataZoom value changes? #314
Comments
Alright, i found how to get data from DataZoom: // Set custom Y axis min-max values as +/- 1% of max/min values on screen candles
private void UpdateYAxisMinMaxValues()
{
var serie = chart.GetSerie(0);
chart.GetDataZoomOfSerie(serie, out DataZoom xDataZoom, out DataZoom yDataZoom);
// Returns timestamp as max value
//SerieHelper.GetMinMaxData(serie, out serieMinValue, out serieMaxValue, xDataZoom);
var serieDataList = serie.GetDataList(xDataZoom);
double serieMinValue = double.MaxValue;
double serieMaxValue = double.MinValue;
for (int i = 0; i < serieDataList.Count; i++)
{
var serieData = serieDataList[i];
var serieDataValues = serieData.data;
// serieDataValues[0] - Timestamp
// serieDataValues[1] - OpenPrice
// serieDataValues[2] - ClosePrice
// serieDataValues[3] - LowPrice
// serieDataValues[4] - HighPrice
var min = serieDataValues[3];
var max = serieDataValues[4];
if (min < serieMinValue) serieMinValue = min;
if (max > serieMaxValue) serieMaxValue = max;
}
var yAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
yAxis.type = Axis.AxisType.Value;
yAxis.minMaxType = Axis.AxisMinMaxType.Custom;
yAxis.ceilRate = (double)ceilRate;
serieMinValue = serieMinValue - (yAxisMinMaxOffsetInPercent / 100 * serieMinValue);
serieMaxValue = serieMaxValue + (yAxisMinMaxOffsetInPercent / 100 * serieMaxValue);
yAxis.min = ChartHelper.GetMinDivisibleValue(serieMinValue, ceilRate);
yAxis.max = ChartHelper.GetMaxDivisibleValue(serieMaxValue, ceilRate);
// Does not set min-max values, because initial values of min max is 0, AdjustMinMaxValue skips them on this line 'if (axis.min != 0 || axis.max != 0)'
//AxisHelper.AdjustMinMaxValue(yAxis, ref serieMinValue, ref serieMaxValue, true, yAxis.ceilRate);
} Now how i should subscribe to OnDataZoomRangeChanged for updates when zoom changes? |
The |
Hi again!
When using DataZoom, how should i get currently displayed candlesticks data?I want to be able to set yAxis min-max values (Min-Max Type: Custom) depending on currently displayed min-max values of candlesticks on screen (from series data), and subscribe to OnDataZoomRangeChanged for further updates.
Tried using Min-Max Type: Auto, but it seems it gets min-max values from all serie data, not currently displayed (on-screen)
The text was updated successfully, but these errors were encountered: