-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
I added in my chart two opposite y-axis. They have different ticks, the ticks automatically generated are ok for me, but I need that the zero is aligned for both axis.
Is it possible?
Thanks in advance.
Hi, are you using ZK Charts or another charting component? What type of chart is it?
We have increased your karma. Please provide more information and a screenshot so that we can understand you better and provide suggestions.
Hi all,
thanks in advance for your support. I attach an image. I need that x-axis (the zero level: y=0) is the same for both y-axes. Is it possible?
Regards,
I don't find an option to make the x-axis start from 0 and show negative values at the same time.
But there is an option to make 2 y-axis have the same values like:
public class LinkedYAxisComposer extends SelectorComposer<Component> {
@Wire
Charts chart;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
// Create a predefined implementation category model
CategoryModel model = new DefaultCategoryModel();
// Set value to the model
model.setValue("Tokyo", "Spring", new Integer(11));
model.setValue("Tokyo", "Summer", new Integer(8));
model.setValue("Tokyo", "Fall", new Integer(-2));
model.setValue("Tokyo", "Winter", new Integer(-10));
model.setValue("New York", "Spring", new Integer(30));
model.setValue("New York", "Summer", new Integer(18));
model.setValue("New York", "Fall", new Integer(20));
model.setValue("New York", "Winter", new Integer(22));
// Set model to the chart
chart.setModel(model);
chart.getYAxis().setMin(-10);
//right y-axis
YAxis yAxisRight = chart.getYAxis(1);
//When an axis is linked to a master axis, it will take the same extremes as the master, but as assigned by min or max or by setExtremes. It can be used to show additional info, or to ease reading the chart by duplicating the scales.
yAxisRight.setLinkedTo(0);
yAxisRight.setOpposite(true);
yAxisRight.getLabels().setEnabled(true);
yAxisRight.setTitle("Different Values");
}
}
Asked: 2023-03-21 22:09:16 +0800
Seen: 9 times
Last updated: May 02