highcharts find point with given x value - highcharts

I need to be able to find the points in series with a X value (time in milliseconds) falling in a given Year and Month, say Jan 1984, what is the most efficient way?

You can find a point by x value in this way:
var series = chart.series[0],
index = series.xData.indexOf(1553779800000),
point = series.points[index];
Live demo: https://jsfiddle.net/BlackLabel/h9qye01r/

Related

daterunc missing values tableau

I don't think this problem is solvable but I figured I would ask.
Data:
DateDim table with 1 row for every date. Columns = date
Sales table with 1 row for every sale. Important columns = id, sales_date
tables relate on date = sales_date
Plot:
I am plotting count of sales for each date, with date on the x-axis and count([id]) on the y-axis.
Problem:
I need a dynamic x-axis. If I filter date for less than a month I need days on the X-axis, but if I filter greater than a month I need month-year on the x-axis.
I accomplished this with daterunc function.
If endDate - startDate < 30
then daterunc('day', [date])
else if endDate - startDate >= 30
then daterunc('month', [date])
end
This works nice except for one issue: missing values. If I use the date as the axis, I can right click the date and select "show missing values" which will correctly plot 0 on days with no sales.
But the calculation above does not have a 'show missing values' option. So the plot does not show zeros when I use the calculation.
Is it possible to modify the above calculation to show missing values?

How can I subtract two dates and get a new date converted in minutes?

I need to subtract two dates, date1 and date2(current date), using Linq expressions. I need to verify if the subtraction between these two date isn't above 12 hours. I only want to get the data that has less than 12 hours. The code bellow is the code of my controller (GET), right now I'm subtracting the two dates and converting the result in minutes. I'm not sure if that's the right approach.
var date2 = DateTime.Now;
var model= _context.Model.Where(e => (e.Prop1== "hello world" && (e.date1 - date2).Minutes <= 12 * 60));
Right know it shows all the data that I have on my database.
When you subtract two DateTime the result is a TimeSpan
Use TimeSpan.TotalHours property, which simplifies to
... (e.date1 - date2).TotalHours <= 12) ...
based on the desired behavior

How to show dates in xAxis using Highcharts.js

I'm feeding my Highcharts.js series object with data containing date and a number, for example: ["2017-1-22",262] which shows up correctly when hovering a point, but which is not displayed correctly in the xAxis. Below codes does not do much, probably because the date format is not what Highcharts expects? But what format is expected? Unixtime does not seem to work.
xAxis: {
type: 'datetime'
}
https://jsfiddle.net/80v2k0tv/
Highcharts expects time in the form of milliseconds since 1970.
See for example: https://api.highcharts.com/highcharts/series.line.data.x
The x value of the point. For datetime axes, the X value is the timestamp in milliseconds since 1970.
Unixtime is in seconds, so using unixtime * 1000 will give the correct highcharts time.

I want get the Half year or half month using sqlserver

This is my query
DECLARE #Frequencyvalue DECIMAL(18,2)
DECLARE #Frequencyunits varchar(1)
SET #Frequencyvalue=(SELECT CalibrationFrequencyValue FRO dbo.InstrumentMaster WHERE InstrumentID=#InstrumentID)
SET #Frequencyunits=(SELECT CalibrationFrequencyUnits FROM dbo.InstrumentMaster WHERE InstrumentID=#InstrumentID)
DECLARE #HalfFrequencyvalue DECIMAL(18,2)
SET #HalfFrequencyvalue=#Frequencyvalue/2
Get HALF(Calibration Frequency and calibration Period) from the InstrumentMaster. [If Calibration Frequency is 1 Year, then due date should be calculated for 6 months)
Calculate next calibration date".
Just I need How to get the half Year or half month query
Assuming you want the due date calculated from today, and #Frequencyunits is 'y','m':
RETURN SELECT DATEADD(CASE WHEN #Frequencyunits = 'y' THEN 'yy' ELSE 'm' END,#HalfFrequencyvalue) AS DueDate

highstock Plotbands to mark certain Daytimes on X Axis

Im trying to mark certain Day Times on my Chart - iE: 15:00 - 21:00
The Date information comes in form of a timestamp - "1365362890000" for example.
Is there any convenient way to say start from time X and go until time Y?
Else I would probs need to loop through all the times to find start/end points.
The timeframe can be anything from a day to a month.
(The plotBands themselves are working for me - just looking if there might be a better way then looping through all the data)
Edit: I meant something like you see in my picture here - its working like this and all is fine. Im just wondering if there was a simple way to say - "mark time x to time y with color z" instead of doing "by hand".
Yes, plotBands have a #from and #to property. Just use the #from and #to of the converted datetime (i.e. the unix time * 1000)
$('#container').highcharts('StockChart', {
xAxis: {
plotBands: [
{
from: 1374658200000,
to: 1374681600000,
color: "rgba(68, 170, 213, .2)"
}
]
}
});
In the xAxis you can set min value and tickInterval.
http://api.highcharts.com/highcharts#xAxis.tickInterval
http://api.highcharts.com/highcharts#xAxis.min (should be timestamp too)
Also you can define pointStart for serie: http://api.highcharts.com/highcharts#plotOptions.series.pointStart and pointInterval http://api.highcharts.com/highcharts#plotOptions.series.pointInterval

Resources