Set time string on tick labels - slider

This is not working for me in JavaFX. I would like to use time format on tick labels for Slider and LineChart, none is working.
Slider slider;
String sliderMin = "12:30:22";
String sliderMax = "13:20:43";
double sliderDoubleMin = Double.parseDouble(sliderMin);
double sliderDoubleMax = Double.parseDouble(sliderMax);
slider.setMin(sliderDoubleMin);
slider.setMax(sliderDoubleMax);
How can I get this to work?
It can handle numbers like "400" but not in time format. Thanks

Related

Oxyplot - LineAnnotion text display horizontally

I use C# and Oxyplot.
I have a LineAnnotation to which I want to add a text.
So I have set Text Property for the LineAnnotation, but the text is vertical aligned.
How could I add a text (1..3 lines) to a LineAnnotation and that texts shows horizontally, so that users can read it ?
Not good :
What I would like:
LineAnnotation Markerline = new LineAnnotation();
Markerline.Color = OxyColors.Blue;
Markerline.LineStyle = LineStyle.Solid;
Markerline.StrokeThickness = 5;
Markerline.Type = LineAnnotationType.Vertical;
Markerline.XAxisKey = "x1";
Markerline.YAxisKey = yAxisKey;
Markerline.Tag = "Marker";
Markerline.Text = "Hello World"; //how to display on top of Markerline horizontally ?
Just set the LineAnnotationType:
Markerline.Type = LineAnnotationType.Horizontal;
You need to LineAnnotation.TextOrientation property. For example,
Markerline.TextOrientation = AnnotationTextOrientation.Horizontal;
In addition, you could also set the LineAnnotation.TextHorizontalAlingment Property to dictate on the position of Text with respect to the Line Annotation.
Markerline.TextHorizontalAlignment = HorizontalAlignment.Left;

How to print double value in DecimalFormat

I have a code.
Double value = 6.589715E7;
DecimalFormatSymbols symbol = new DecimalFormatSymbols(Locale.GERMANY);
symbol.setGroupingSeparator(',');
final DecimalFormat doris = new DecimalFormat("#,###000",symbol );
System.out.println(changedValue);
which displays the value like this rite now.
65,897150
is there any way out this can be displayed as.
65,9 (also rounding off to one decimal place)
This example rounds up 2 but you get the point, try this
inputValue = Math.Round(inputValue, 2);
Here I put answer in string format. you can also convert into double format.
Double value = 6.589715E7;
DecimalFormatSymbols symbol = new DecimalFormatSymbols(Locale.GERMANY);
symbol.setGroupingSeparator(',');
final DecimalFormat doris = new DecimalFormat("##,###000",symbol );
String str = String.valueOf(doris.format(value));
String formated=str.replace(".", ",").substring(0,str.indexOf(",")+2);
Log.e("Log","d result="+formated);

How can I make OxyPlot adjust zoom when calling PlotView.Invalidate?

I have a problem with OxyPlot which is as follows:
I create a new PlotView and attach a PlotModel with some axes when my program starts.
In my program, the user can open a file, which is interpreted and plotted in the PlotView control.
To display the new Series, I do
myPlotView.Invalidate(true);
This will display the data on in the plot, however OxyPlot does not perform any zooming. How can I pan and zoom automatically, such that the plot covers the whole PlotView?
I tried to set
myPlotView.Model.Axes[0].DataMinimum = someValue1
myPlotView.Model.Axes[1].DataMinimum = someValue2
myPlotView.Model.Axes[0].DataMaximum = someValue3
myPlotView.Model.Axes[1].DataMaximum = someValue4
but nothing happens.
Axes calculates the ViewMinimum and ViewMaxium (the real thing you are watching) only if Minimum and Maximum are not specified, you can set them to Double.NaN before resetting, so the ViewMinimum and ViewMaximum will be calculated based on DataMinimum and DataMaximum
foreach (var ax in _plotModel.Axes)
ax.Maximum = ax.Minimum = Double.NaN;
PlotView.ResetAllAxes();
Also if you changed the data points, you must call to Plot.InvalidatePlot() so the DataMinimum and DataMaximum gets updated too.
Do a Axis reset and update the Minimum/Maximum of each Axis.
e.g.
PlotView.ActualModel.Axes[0].Reset();
PlotView.ActualModel.Axes[1].Reset();
PlotView.ActualModel.Axes[0].Minimum = 50;
PlotView.ActualModel.Axes[0].Maximum = 250;
PlotView.ActualModel.Axes[1].Minimum = 50;
PlotView.ActualModel.Axes[1].Maximum = 250;
PlotView.InvalidatePlot(true);
you should of course use the min/max value from your data.

VB 2010: How to index textbox (making it like slots)?

If the title isn't clear; I want to be able to select any character from textbox without making some complex loops-dependent code (I can do that one). For example, let's consider this text is entered in a textbox:
hello user!
I want some syntax when I tell to get me the index 1's value, it gives me "h", for index 5 = "o"... etc
So, anyone knows what's the right syntax, please help!
string can be directly indexed without any special code.
//from metadata
public sealed class String : IComparable, ICloneable, IConvertible, IComparable<string>, IEnumerable<char>, IEnumerable, IEquatable<string>
{
....
// Summary:
// Gets the character at a specified character position in the current System.String
// object.
//
// Parameters:
// index:
// A character position in the current string.
//
// Returns:
// A Unicode character.
//
// Exceptions:
// System.IndexOutOfRangeException:
// index is greater than or equal to the length of this object or less than
// zero.
public char this[int index] { get; }
....
}
dim str = "hello";
dim hchar = str(0);
dim echar = str(1);
dim lchar = str(2);
ect
Dim x As String = "Hello"
Console.Write(x.IndexOf("e")) 'Would return the position
Console.Write(x(x.IndexOf("e"))) 'Would return the character based upon the position
Console.Write(x(1)) 'Returns the character based at position 1 of the string
You can remove the Console.Write if you are using a WinForm.
TextBox1.Text = x(x.IndexOf("e"))
This should work.
Dim orig = "hello user!"
Dim res = Enumerable.Range(0,orig.Length).[Select](Function(i) orig.Substring(i,1))
So then you can do:
Dim x = res(0) 'x = "h"

How to add a text on top of a column with ZedGraph?

How can I add some text on top of a bar in a chart.
This is the code I have to add the bar:
var color = ColorTranslator.FromHtml(row.Colour);
var barItem = graphPane.AddBar(row.Propensity.ToString(), null, Ys.ToArray(), color);
Thank you
Here is a quick example using TextObj to simply add labels to each bar.
GraphPane myPane = zedGraphControl1.GraphPane;
double[] y = { 100, 50, 75, 125 };
BarItem myBar = myPane.AddBar("Data", null, y, Color.Red);
for (int i = 0; i < myBar.Points.Count; i++)
{
TextObj barLabel = new TextObj(myBar.Points[i].Y.ToString(), myBar.Points[i].X, myBar.Points[i].Y + 5);
barLabel.FontSpec.Border.IsVisible = false;
myPane.GraphObjList.Add(barLabel);
}
myBar.Label.IsVisible = true;
zedGraphControl1.AxisChange();
zedGraphControl1.Invalidate();
Of course this just uses the value of the data as the label. If you wanted to use custom labels, you could create a string array or list and use that inside the loop.
Here are some ZedGraph references:
Introduction and examples: http://www.codeproject.com/KB/graphics/zedgraph.aspx
Source code documentation: http://zedgraph.sourceforge.net/documentation/default.html
You need to define AlignH and AlignV in your text object:
TextObj textLabel = new TextObj(value.ToString(), positionX, value, CoordType.AxisXYScale, AlignH.Center, AlignV.Top);
AlignV define the position of your value on the bar.
Providing you want the label text to match the value of each bar, then you can do it with a single line of code:
BarItem.CreateBarLabels(graphPane, false, "F0");
Note that the 3rd parameter is a double.ToString format. e.g. "F0" = 12, "F2" = 12.34
However, if you want any flexibity with it then this solution is not ideal. It also doesn't work very well if you have a stacked bar chart, because having any 0 value data will cause labels to overlap and look horrific