Skip to content
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

For Zoomer, how to get actual start index and end index of data in the range #686

Closed
yezhengli-Mr9 opened this issue Jan 8, 2025 · 1 comment

Comments

@yezhengli-Mr9
Copy link

Describe the bug
A clear and concise description of what the bug is. Please use the issue feature only for actual bugs. If you have usage questions or are unsure if/how a certain functionality is supported in chart-fx please use the q&a secton in the discussions feature or our gitter channel.

For Zoomer, how to get actual starting index and end index of data in the range? For example, start and end index of a list of bars.
To Reproduce
Steps to reproduce the behavior. Ideally the problem can be reproduced in the samples provided with chart-fx or by adapting them slightly. Alternatively provide a minimal working example.

protected Chart getDefaultFinancialTestChart(final FinancialTheme theme) {
// load datasets
DefaultDataSet indiSet = null;
if (resource.startsWith("REALTIME")) {
try {
Interval<Calendar> timeRangeInt = CalendarUtils.createByDateTimeInterval(timeRange);
Interval<Calendar> ttInt = CalendarUtils.createByTimeInterval(tt);
Calendar replayFromCal = CalendarUtils.createByDateTime(replayFrom);
ohlcvDataSet = new SimpleOhlcvReplayDataSet(
DataInput.valueOf(resource.substring("REALTIME-".length())),
period,
timeRangeInt,
ttInt,
replayFromCal,
consolidationAddons);
} catch (ParseException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
} else {
ohlcvDataSet = new OhlcvDataSet(resource);
indiSet = new DefaultDataSet("MA(24)");
try {
loadTestData(resource, ohlcvDataSet, indiSet);
} catch (IOException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
// prepare axis
final DefaultNumericAxis xAxis1 = new DefaultNumericAxis("time", "iso");
xAxis1.setOverlapPolicy(AxisLabelOverlapPolicy.SKIP_ALT);
xAxis1.setAutoRangeRounding(false);
xAxis1.setTimeAxis(true);
// set localised time offset
if (xAxis1.isTimeAxis() && xAxis1.getAxisLabelFormatter() instanceof DefaultTimeFormatter) {
final DefaultTimeFormatter axisFormatter = (DefaultTimeFormatter) xAxis1.getAxisLabelFormatter();
axisFormatter.setTimeZoneOffset(ZoneOffset.ofHoursMinutes(2, 0));
}
// category axis support tests
// final CategoryAxis xAxis = new CategoryAxis("time [iso]");
// xAxis.setTickLabelRotation(90);
// xAxis.setOverlapPolicy(AxisLabelOverlapPolicy.SKIP_ALT);
final DefaultNumericAxis yAxis1 = new DefaultNumericAxis("price", "points");
// prepare chart structure
final XYChart chart = new XYChart(xAxis1, yAxis1);
chart.setTitle(theme.name());
chart.setLegendVisible(true);
chart.setPrefSize(prefChartWidth, prefChartHeight);
// set them false to make the plot faster
chart.setAnimated(false);
// prepare plugins
chart.getPlugins().add(new Zoomer(AxisMode.X));

dataSet.recomputeLimits(DIM_X); // please use markdown code formatting for logs and code snippets

Environment:

  • OS: [e.g. Ubuntu 20.04]
  • Java version:
  • JavaFx version:
  • ChartFx version: [master, 11.2.2, ...]
@yezhengli-Mr9
Copy link
Author

yezhengli-Mr9 commented Jan 8, 2025

Replaced by #687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant