JavaFX XYChart NumberAxis - javafx

I'm having problems with the y axis on a custom XYChart. The y axis is a NumberAxis, and I set the tick label formatter to a custom formatter. Auto-ranging is off. When I change the upper bound of the chart and request an axis layout, the old labels remain on the chart. With debug logging, I can see that the custom formatter methods are being invoked, and that they return the correct Strings, but the tick labels on the chart do not update. The only ones that do update are the ones that were not on the axis before. For example, if the range of the y axis was 0 to 3, and then I change the upper bound from 3 to 5, new labels with the correct values will show up at indices 4 and 5. However, the labels for 0 through 3 do not update even though the custom formatter now returns different Strings for them.
I tried taking the custom formatter out of the equation and simply changed the tick label fill to another color when I changed the upper bound of the y axis, and I saw the same behavior (labels for pre-existing indices had the old color, and labels for new indices had the new color). I hope I'm missing something obvious. Any help would be greatly appreciated. Otherwise I may need to resort to recreating the chart whenever the y axis labels need to change.

From what I have found, the tick labels themselves are basically immutable. Once a range is set, it only adds and removes ticks, but doesn't update them. What I did to overcome this is to set the upper bound to the lower bound (effectively removing all ticks), and then setting the upper bound back to the range I wanted, so it would re-create the ticks.

Related

PHPExcel Chart X-Axis Between Tick Marks

I'm working on an old script and I've hit a problem for a configuration that does not appear to be documented. I have a dynamically created bar chart. The bars are vertical. Everything is fine except the position of the bars on the X axis. The first and last one are half cut off. I can fix it easily after producing the spreadsheet. I click on the X-axis and switch the position to "Between tick marks" instead of "On tick marks." I cannot find anything in any form of PHPExcel documentation for setting the position of the X axis to "between" instead of "on." Does this setting exist?
PHPExcel has been replaced by PHPSpreadsheet, but there are cases where it is not possible to change from PHPExcel to PHPSpreadsheet.
The option that must be set is "crossBetween" for the X Axis. PHPExcel does not make this a customizable option. It is hard-coded in Charts.php with the value "midCat". That setting places the first bar directly under the Y axis and the last bar hanging off the right side of the chart. Each bar is cut off. To place the bars between the ticks, edit Charts.php and change the entry for "midCat" to "between". You should only find "midCat" once in the file. This will hard-code all charts to be between the ticks. Change it back if you want it back to what it used to be.
The proper fix is to make this an option you can change. That requires editing multiple files. The Axis object needs a cross_between option. Then, a setter is needed to update that option. The writer needs to pull from that option instead of hard-coding the value. Chart lets you get the X Axis, but you can't set it once you update an option. So, you need a setter for the X Axis for the chart. Then, you can create a chart, get the X Axis, change the crossBetween value, and set the updated axis in the chart.

How to set x-axis to start at 0 in a Qt5 QChart

I have a QChart with an y-axis that goes from -25 to 25. Currently my x-axis is set at the bottom (y = -25 in this case). How can I set the x-axis to start at y=0? Thank you.
As far as I know this is not directly possible, to arrange one axis like this. Documentation says: "Multiple axes can be defined for one chart. The axes can be placed down, up, left, or right of the chart. Further, the axes can be of different types. However, mixing axis types that would result in different domains is not supported, such as specifying QValueAxis and QLogValueAxis on the same orientation."
You can emulate an axis in the center by adding a QLineSeries and then drawing the marks yourself.

Show custom values on zgraph

I have plotted a graph using zedgraph library as shown in figure.On x axis zedgraph automatically plotting values between range in our case 1 to 20 its not showing intermediate values i.e. 1,2,3,4....20 I want show point 1,2,3,4,5...20 as well.How can I do that??
MajorStep
Gets or sets the scale step size for this Scale (the increment between labeled axis values).
http://zedgraph.sourceforge.net/documentation/default.html
See Scale Class, scroll down to MajorStep
Or http://www.nudoq.org/#!/Packages/ZedGraph/ZedGraph/Scale/P/MajorStep
.GraphPane.XAxis.Scale.MajorStep = 1;
.GraphPane.XAxis.Scale.MajorStepAuto = false; // Not needed, see documentation.

Can I display a QWT Plot's Z-axis interval on the left side?

I have a colored waterfall display implemented as a QwtPlot with a data container derived from QwtRasterData (m_SpectroPlot below). The values painted correspond to the Z-axis of the data, taken from a color map that is shown on the right side of the plot. The code looks like this:
const QwtInterval zInterval = m_SpectroPlot->data()->interval( Qt::ZAxis );
QwtScaleWidget *zAxis = axisWidget(QwtPlot::yRight);
zAxis->setColorBarEnabled(true);
zAxis->setColorMap( zInterval, new ColorMap());
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
setAxisAutoScale(QwtPlot::yRight);
enableAxis(QwtPlot::yRight);
Everything works fine, but I want to have the color map on the left side and hide the Y-axis values. When I replace yRight with yLeft in the above code, the displayed interval of the color map is locked to the interval of the data's Y-values. How can I maintain the current independent axis intervals while showing the color map on the yLeft axis?
In other words, I want to display the color map for the interval Z0-Z1 on the yLeft axis, while the actual Y-values drawn on the plot are Y0-Y1. It seems like I need to somehow tell the plot to use yRight instead of yLeft to scale the Y axis.
After sifting through some documentation I found the answer. The data needs to be told to attach to the yRight axis instead of the default yLeft.
m_SpectroPlot->setYAxis(QwtPlot::yRight);

ZedGraph - How to force first and last bars have x-axis labels?

Using Zedgraph (asp.net). I have a bar graph based on datetime x points. The first bar does not have a label. The first label is at the y-axis corresponding to a day before my first day point. I am not too concerned about this. However the second label is at the second bar. I need the first bar to have a label. I do have MyPane.XAxis.Scale.IsSkipFirstLabel = false.
How do I force the first bar to have a label? Why is ZedGraph not putting a label there?
Addition:
I want '5/20' to display for the first bar instead of 5/19 under the y-axis. I don't even have an entry for 5/19.
alt text http://i50.tinypic.com/29ogx0n_th.gif
OK, I don't know if that's exactly what you need, but:
First, adjust your scale ranges manually:
zg1.MasterPane[0].XAxis.Scale.Min = (double)new XDate(2010, 05, 19);
zg1.MasterPane[0].XAxis.Scale.Max = (double)new XDate(2010, 05,30);
This will set the ranges of your scale to show one day before and one day after your data (this is needed to have extra space)
then, set the step:
zg1.MasterPane[0].XAxis.Scale.MajorStep = 1;
zg1.MasterPane[0].XAxis.Scale.FontSpec.Angle = 90f;
This will cause you will have one label for each day. In fact, this is the only way to have more or less control over the labels that appear. I've also changed the angle of labels (in normal position it would overlap).
But it would create the labels for first and last extra days too (margins). So we need to disable these two entries (now it would work, because you've set the ranges manually).
zg1.MasterPane[0].XAxis.Scale.IsSkipFirstLabel = true;
zg1.MasterPane[0].XAxis.Scale.IsSkipLastLabel = true;
If you just want to disable this first and last extra label and leave the rest to the ZedGraph, just ommit the second step. But the outcome could be sometimes unpredictable.

Resources