|
My x-label is gone after zoom in |
Posted by bravephs88 on Aug-29-2014 19:38 |
|
If i zoom in some x-labels gone...
here code
======================================================
c.yAxis().setLabelFormat("{value}");
c.xAxis().setLabels(labels3);
c.xAxis().setLabelFormat("~");
StepLineLayer layer0 = c.addStepLineLayer();
layer0.setLineWidth(2);
layer0.addDataSet(dataY0, 0xff0000, "Quantum Computer").setDataSymbol(
Chart.CircleSymbol, 9);
======================================================
and labels3
String[] labels3 = { "5", "605", "1105", "1405", "2205", "2405",
"16405", "20405", "21305", "22005", "24005", "25505",
"26305", "27805", "29305", "29805", "35805", "39305",
"47305", "52305", "82305", "86305", "94305", "94355",
"134355", "284355", "284405", "296905", "297605", "307605" };
I must format x-labels is String
Beacuse each x-labels value unique
What should I do?
|
Re: My x-label is gone after zoom in |
Posted by Peter Kwan on Aug-30-2014 04:35 |
|
Hi bravephs88,
It is probably because the x-axis is treated as a "linear axis" (using
syncLinearAxisWithViewPort), as opposed to a label based x-axis.
For your case, instead of using Axis.setLabels or syncLinearAxisWithViewPort, please use
the following code to control the x-axis:
// Set the axis to the view port range, but without labels
viewer.setFullRange("x", labels3.length - 1);
double leftX = viewer.getValueAtViewPort("x", viewer.getViewPortLeft());
double rightX = viewer.getValueAtViewPort("x", viewer.getViewPortLeft() +
viewer.getViewPortWidth());
c.xAxis().setLinearScale(leftX, rightX, Chart.NoValue);
// Add custom labels to the axis
for (int i = (int)(leftX + 0.9999); i < rightX; ++i)
c.xAxis().addLabel(i, labels3[i]);
Hope this can help.
Regards
Peter Kwan |
Re: My x-label is gone after zoom in |
Posted by bravephs88 on Aug-30-2014 12:33 |
|
Thank you very much Peter Kwan!!! |
|