how to use Datetime Axisx in lightningchartV2.2.1? - lightningchart

I noticed the answer in Custom DateTime in X axis in Lightningchart JS, but it report error "AxisTickStrategies.DateTime is not a function" in lightningchartV2.2.1.
also, since AxisTickStrategies.DateTime is not a function, how can i show a full date axisx label for a series using a DateTime axis ?

Please have a look at official LCJS Interactive Examples, and search for "datetime"
For example,
https://www.arction.com/lightningchart-js-interactive-examples/examples/lcjs-example-0020-dateTimeAxis.html
This is the bare minimum required code - please refer to the examples for extended modification.
chart.getDefaultAxisX()
.setTickStrategy(
// Use DateTime TickStrategy for this Axis
AxisTickStrategies.DateTime,
)

Related

Dimension value_format callback not working properly

This is a new question related to a previous question I asked:
holoviews can't find flexx when using a Dimension value_format callback
Thanks to downgrading my version of flexx, I am no longer getting the warning message. However, the callback function is not working. Here is the code:
%%output size=200
%%opts Curve [width=600 height=250] {+framewise}
%%opts Curve.Load.Ticket (color='red')
def xformat(x):
# update the default tick label to append an 'a'
new = x + 'a'
return(new)
kdims=hv.Dimension('Day Section', label='Week Day and Hour', value_format=xformat)
tload = hv.Curve(simple_pd,vdims=[('Max Ticket Load', 'Maxiumum Ticket Load')],kdims=kdims,group='Load',label='Ticket')
tload
When I run with the above code, I expect to see the same amount of x axis tick labels, however, each label should have an 'a' appended to the end. However, what I am seeing is no rendering of the element at all in my notebook. I have tried a number of variations of modifying the value, and the same thing happens.
Strangely, the issue appears to be the use of the variable name new in the xformat function. If I change the name of the variable it works fine. It doesn't appear as though new is a reserved work in python though, so I am not sure why its causing a problem.
Note that using the matplotlib extension does not have the same problem, only Bokeh.

How to use FORMATTED_VALUE in a cumulated graph?

At first, from the Data Render panel in icCube report, I used context.cumulativeCol(); in the Value field in order to create my cumulated graph.
Now, since the format of my data is not well suited for my application (I have values such as '4.547473508864641e-13' which I want to be formatted to 0.00), I tried to add parameters to the function :
var col = context.getColumnIndex();
var measure = context.getMeasures();
var property = "FORMATTED_VALUE";
return context.cumulativeCol(col, measure, property);
But I cannot get a proper output.
How should I do it?
You cannot use FORMATTED_VALUE to format numbers calculated on the client side, it's available on for data that comes directly from the server. So in your case you need to implement your own client-side formatting. You could use mathJS that bundled to the reporting i.e.:
return math.format(context.cumulativeCol(col), {notation: "fixed", precision: 2})
Or use any other JS formatting method like .toFixed(2)

What does moment(testDate, "x") do?

I have the following piece of code before me:
var testDate = 1481103000000;
var enterTime = moment(testDate, "x");
console.log(enterTime);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.js"></script>
The variable enterTime results in a momentjs object with an additional _f property set to "x" and a _pf property of type object (see the console log) compared to a normal moment(testDate) object.
I couldn't find information on the _f or _pf properties anywhere.
Can anyone tell me what the "x" stands for and for what reason it is being used?
Thanks in advance.
With moment(testDate, "x"); you are creating a moment object using moment(String, String); function specifying x as format (Unix ms timestamp).
When you do moment(testDate), you are creating a moment object using moment(Number);.
All moment properties starting with _ are for internal use, _f stands for format, while _pf stand for Parsing Flags.
You can have a look to moment code to get more details about _f and _pf.
x denotes Unix ms timestamp
Please note that this parameter is case-sensitive:
X Output: 1410715640.579 Unix timestamp
x Output: 1410715640579 Unix ms timestamp
Refer here for all the options.

QwtPlot showing the wrong date/time

I'm using QwtDateScaleDraw in Qt to plot a QDateTime at the X-axis of a graph.
I use this command to convert the QDateTime to a QwtDate::Double:
tempData->append( QPointF( QwtDate::toDouble( date.at(var) ), data.at(var) ) );
The first date/time that I have is
01/08/2014 00:00:52
but when I place the data in the graph, the first date is
31/07/2014 21:04:52.
I don't know why this is happening.
I managed to solve this using:
scaleDraw->setTimeSpec(Qt::UTC);

QTimeZone::QTimeZone(int offsetSeconds)

I am using Qt 5.4.1 and getting issue during calling QTimeZone::QTimeZone(int offsetSeconds) method. My code is :
QTimeZone zone = QTimeZone(+19800); // +19800 is offsetFromUtc in seconds for India country
qDebug()<<QLocale::countryToString(zone.country());
The above qDebug prints "Default" each time but when I am using QTimeZone(const QByteArray & ianaId) method for example :
QTimeZone zone = QTimeZone("Asia/Calcutta");
qDebug()<<QLocale::countryToString(zone.country());
The above qDebug prints "India" which is correct. But at the same time QTimeZone(int offsetSeconds) method is not working properly.....could anybody help me what I am doing wrong ?
There is no way to convert a timezone offset into a country. The relationship is 1:n from locality to offset: if you know the region/country, and current UTC, you can know the timezone offset. But there is a lot of different locales that have the same offset. And the offset it not necessarily constant over time for any given location.

Resources