I have a question about formatting my axis on highcharts. I want to display the ticks on the Y axis in decimals with 2 decimal places.
The current situation:
0
0.05
0.1
0.15
0.2
I want to display my number like this:
0.00
0.05
0.10
0.15
0.20
Is there an easy way to do this?
-->API
yAxis: {
labels: {
format: '{value:.2f}'
}
}
Related
In my model, I am saving results from numerous Parameter Variation runs in a Histogram Data object.
Here are my Histogram Data settings:
Number of intervals: 7
Value range:
Automatically detected
Initial Interval Size: 10
I then print out these results using the following :
//if final replication, write Histogram Data into Excel
if(getCurrentReplication() == lastReplication){
double intervalWidth = histogramData.getIntervalWidth();
int intervalQty = histogramData.getNumberOfIntervals();
for(int i = 0; i < intervalQty; i++){
traceln(intervalWidth*i + " " + histogramData.getPDF(i));
excelRecords.setCellValue(String.valueOf(intervalWidth*i) + " - " + String.valueOf(intervalWidth*(i+1)), 1, rowIndex, columnIndex);
excelRecords.setCellValue(histogramData.getPDF(i), 1, rowIndex, columnIndex+1);
rowIndex++;
}
}
Example of my intended results:
10 - 80%
20 - 10%
30 - 5%
40 - 2%
50...
60...
Actual results:
0.0 0.0
10.0 0.0
20.0 0.0
30.0 0.998782775272379
40.0 0.0011174522089635631
50.0 9.9772518657461E-5
60.0 0.0
Results after settings initial interval size to 0.1:
0.0 0.9974651710510558
4.0 0.001117719851502934
8.0 9.181270208774101E-4
12.0 2.3951139675062872E-4
16.0 1.5967426450041916E-4
20.0 9.979641531276197E-5
24.0 0.0
How would I go about obtaining my desired results? Am I fundamentally misunderstanding something about the HistogramData object?
Thank you for your help.
The function you are using (getPDF(i)) returns value for the interval in fractions (not in percentages). So, you have to multiply the value by 100 in order to get it as a percentage. As for histogram bars, model analyze the results, specified interval numbers and interval size. After that, it will build the respective number of bars that cover all results. In your case, intervals from 0 to 30 do not provide any results and bars are not presented (PDF here is 0.0).
I need a way to round my decimal in lua.
Sometimes my number looks like this:
When I search for it online, I only find solutions to round it to a whole number, but I don't want to round my variable to 0.00, 1.00, or 2.00, how would I round it to a specific decimal digit?
Code:
health = 1
maxhp = 2
function hp_showcase()
makeLuaText("hpcounter", "HP: "..health.."/"..maxhp.."", 2250, 30, 350)
addLuaText("hpcounter")
end
function opponentNoteHit(id, noteData, noteType, isSustainNote)
hp_showcase();
end
You can define a function that takes in the value to be rounded and the digit position you would like to round to, for this example positions in front of the . are positive and behind are negative so 2 rounds to the nearest 100 and -2 rounds to the nearest 0.01
local value = 0.79200750000001
local function round(number, digit_position)
local precision = math.pow(10, digit_position)
number = number + (precision / 2); -- this causes value #.5 and up to round up
-- and #.4 and lower to round down.
return math.floor(number / precision) * precision
end
print(value)
print(round(value, -2))
print(round(value, -1))
print(round(value, 0))
Results:
0.79200750000001
0.79
0.8
1
Example plunk refereed to below.
I have a line chart where the Y axis is a percentage between 0 and 1. Sometimes my highest percentage is less than 1% sometimes its between 99 and 100%. It never makes sense to have more than 100% displayed on the legend.
The problem is if I set max: 1 and have data that is all below 0.1, the chart looks flat like in the second example. However, If I don't set max and the data is approaching 100%, then y axis will render ticks up to 125%.
How do let the legend autoscale, but cap the max value.
You have this in your y-axis:
yAxis: {
max: 1,
min: 0
}
If you instead go for this, it should be more understandable:
yAxis: {
min: 0,
endOnTick: false
}
To clarify, you had max: 1 and endOnTick: true (default), and according to the API:
If the endOnTick option is true, the max value might be rounded up.
See this updated Plunker for a demonstration.
The same goes for starting at 0%. You could remove min and set startOnTick: false.
I have spline chart, with dateTime xAxis and more than 3k points in each of 2 categories: http://jsfiddle.net/jk171505/dmmhL5ha/7/
Is there a way, other than tickInterval, to prevent overlapping labels on xAxis?
I tried to use tickInterval but this isn't the option, as data points are irregular and amount varies (sometimes it's data for period of 2 weeks, sometimes 2 years):
xAxis: {
type: 'datetime',
categories: ["test1", "test"],
tickInterval: 24 * 3600 * 1000 * 31,
Set tickPixelInterval - bigger than label width, to make sure there is enough space between items JSFiddle.
I need to set the step between the display lines in Highcharts. I mean it -
200
150
100
50
0
In this y-case step = 50. How can i set this in HighCharts?
This found with the yAxis.tickInterval. For example:
yAxis: {
tickInterval: 50
}