Hi,
When I did some practices with your example app, I found some features does not work as I expected.
Here is CandlestickChartFragment.java and I wrote additional lines on xAxis builder, yAxis builder and surface.chartModifiers,
public class CandlestickChartFragment extends ExampleBaseFragment {
@BindView(R.id.chart)
SciChartSurface surface;
@Override
protected int getLayoutId() {
return R.layout.example_single_chart_fragment;
}
@Override
protected void initExample() {
PriceSeries priceSeries = DataManager.getInstance().getPriceDataIndu(getActivity());
int size = priceSeries.size();
final IAxis xAxis = sciChartBuilder.newCategoryDateAxis()
.withVisibleRange(size - 30, size)
.withGrowBy(0, 0.1)
// Start additional lines
.withAutoFitMarginalLabels(false)
.withTextFormatting("yyyy-MM-dd")
.withCursorTextFormating("MM-dd")
// End additional lines
.build();
final IAxis yAxis = sciChartBuilder.newNumericAxis()
// Start additional lines
.withAutoFitMarginalLabels(false)
.withTextFormatting("$ #.#")
.withCursorTextFormating("#.#")
// End additional lines
.withGrowBy(0d, 0.1d)
.withAutoRangeMode(AutoRange.Always)
.build();
IOhlcDataSeries<Date, Double> dataSeries = new OhlcDataSeries<>(Date.class, Double.class);
dataSeries.append(priceSeries.getDateData(), priceSeries.getOpenData(), priceSeries.getHighData(), priceSeries.getLowData(), priceSeries.getCloseData());
final FastCandlestickRenderableSeries rSeries = sciChartBuilder.newCandlestickSeries()
.withStrokeUp(0xFF00AA00)
.withFillUpColor(0x8800AA00)
.withStrokeDown(0xFFFF0000)
.withFillDownColor(0x88FF0000)
.withDataSeries(dataSeries)
.build();
UpdateSuspender.using(surface, new Runnable() {
@Override
public void run() {
Collections.addAll(surface.getXAxes(), xAxis);
Collections.addAll(surface.getYAxes(), yAxis);
Collections.addAll(surface.getRenderableSeries(), rSeries);
Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers()
// Start additional lines
.withCursorModifier().withShowAxisLabels(true).withShowTooltip(true).build()
// End additional lines
.build());
sciChartBuilder.newAnimator(rSeries).withWaveTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start();
}
});
}
}
The result is below picture. I also attached the same image.
https://imgur.com/a/5Eqo8Gd
Displayed xAxis values are [27 Sep, 04 Oct, 11 Oct, 18 Oct, 25 Oct, 01 Nov].
The problems are
1. xAxis(CategoryDate) tick values should be started with year, even though it does not have enough margin. It looks updated format is not applied.
2. Cursor should be shown on touch event, but it does not be displayed at all.
I ran above code on [Samsung Galaxy S9, API 26] and [Xiaomi Mi A1, API 25] and same problems are happened.
Could I know what I missed?
- Changhee Lee asked 6 years ago
- last edited 6 years ago
- You must login to post comments
Hi Changhee,
-
Well by default CategoryDateAxis uses custom LabelProvider which ignores formatting which is set on axis and selects formatting string based on current VisibleRange from one of predefined formatted strings. If you want you can extend default TradeChartAxisLabelProvider and override its formatCursorLabel() method with desired logic.
class CustomTradeChartAxisLabelFormatter extends TradeChartAxisLabelProvider { @Override public CharSequence formatCursorLabel(Comparable dataValue) { return someCustomCursorLabel; } } xAxis.setLabelProvider(new CustomTradeChartAxisLabelFormatter());
-
This happens because you use newModifierGroupWithDefaultModifiers() which add some default modifiers which intercept handle touch events before they reach CursorModifier. To fix it you need to set ReceiveHandledEvents = true for CursorModifier so it will receive touch events if they were handled by other modifiers:
Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers()
// Start additional lines
.withCursorModifier().withShowAxisLabels(true).withShowTooltip(true).withReceiveHandledEvents(true).build()
// End additional lines
.build());
Best regards,
Yura
- Yura Khariton answered 6 years ago
- You must login to post comments
Please login first to submit.