jfreechart control OHLC time series range for dynamic display - jfreechart

Using:
java 17
JavaFX 17
JFreeCharts 1.5.3
JFreeCharts FX 2.0.1
I would like to feed dynamic data to an OHLC plot with OHLCSeries
I used the MaxItemCount but this is only good if all your time series has same dimensions
I need to show some trading signals that is not the same size as the OHLC series so the max item count will not work
Is there a way to show the latest 3 days (or the last 100 Hours) on a mixed series chart?
Using OHLCSeriesCollection for mixing OHLC and indicators (moving average) on the same chart. i.e. they don't happen on all the candle signals.
What if I need to add another TImeSeries (with a line&shape renderer) on the same chart but this one will have fewer items?
Can I use the Axis to control the items displayed by time?
DateAxis dateAxis = new DateAxis("Time");
CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot(dateAxis);
and adding data
OHLCSeriesCollection candlestickDataset = new OHLCSeriesCollection();
candlestickDataset.addSeries(new OHLCSeries());
TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
timeSeriesCollection.addSeries(new TImeSereis);
I noticed in old versions there was an option to add the TimeUint in the Series constructor. What is the alternative now?
ComparableObjectSeries doesnt have MaxItemAge?
EDIT:
Problem:
I have data with different occurrences over time
Data is TimeSeries & OHLCseries mix on the same chart (different renderers)
Data is dynamic and I would like to display only the last X points in time (3 days for example) i.e. aged are removed

Related

anychart stock - range selection with mm:ss resolution

i'm using anychart stock 8.1.0. I have a dataset with 24 hours of date with per-second resolution. I would like for only a small 30 seconds subset of that data to be shown/zoomed on load.
I could not find out how to do this so i tried adding a range selector option like below but i couldn't get that working either.
rangeSelector.ranges([{
'text': 'Testing',
'startDate': '2006 May 16 13:00:00',
'endDate': '2006 May 16 13:00:30'
}
If i use the range selector slider i can zoom as i require but how do i define this in code ?
So to recap i'd like
have the chart zoomed on load for a specific time range of type
start-stop in format of dd/MM/yyy mm:ss
have range selector button options for various time ranges of same format as above.
thank you.
Yes, you can define your own custom periods for rangeSelector, but if you want to zoom to specific period on load you have to call selectRange() method after chart drawing.
If you want to show only 30 seconds in the beginning of your series you should put the following line into your code:
chart.selectRange("second", 30, "first-date", true);
You can learn more about this method here
And find a similar example of using it here

Connecting datapoints seperated by empty points in a win form chart

I have two series to be plotted as a line chart with Win Form Charts. The first series has x,y values of
{(datetime1:4),(datetime2:4),(datetime3:4),(datetime4:1),(datetime5:3)}
And the second series has x,y values of
{(datetime1:4),(datetime3:14),(datetime5:6)}
Since the second series has datetime2 and datetime4 missing, I have added DbNull.Value as value for these points. So now the second series will be
{(datetime1:4),(datetime2:DbNull.Value),(datetime3:14),(datetime4:DbNull.Value),(datetime5:6)}
Because of this the second series shows only dots. Could you please suggest me how can I connect these empty points with the average of the two closest data points.
The way to acheive this is
mySeries.EmptyPointStyle.BorderDashStyle = ChartDashStyle.Dash; // select the style you want
mySeries.EmptyPointStyle.Color = Color.Gray; // setting the color might be required
mySeries["EmptyPointValue"] = "Average";

Kendo Chart set skip after load using Angular

Im using Angular Kendo - Im not sure if thats really relevant only to say its not as 'simple' as calling refresh. - I have two scope variables one is the Kendo DataSource the other is the Kendo Chart Options which are assigned like this
$scope.ChartOptions = {
// All The other Chart Stuffs
dataSource : $scope.ChartDataSource
}
<div kendo-chart k-options="ChartOptions" />
This works fine - the issue is that the chart data can vary quite a bit and the area I'm using is small so what happens is the value axis ends up looking okay with values of just 2 or 3 but when you get to 20 or more the labels bunch up is there some way to reset the options after the data is retrieved. Maybe by changing the valueaxis skips etc.
What you are looking for is actually the CategoryAxis Step value. Based upon your data, you need to figure out what the max value is, and then calculate a reasonable step value that will appropriately render out your chart control based upon the space that you have. I can't really give you an example, as this will be entirely dependent upon your data and will likely require a bit of trial and error til you land on a calculation that yields acceptable results.
Documentation for the CategoryAxis step: http://docs.telerik.com/kendo-ui/api/dataviz/chart#configuration-categoryAxis.labels.step
Here is an example for finding the maximum data point:
var data = [1, 3, 4, 9, 10];
var max = Math.max.apply(Math, data);
//code here to do some kind of calculation of step value
Once you know what your appropriate step value should be based upon your data, you can then create your chart and set the CategoryAxis.Labels.Step value to it during grid creation.

Jfreechart DateAxis should show date on the top of first tick unit

can anyone help me how I could display the date alone on top of the first tick unit of DateAxis in Jfreechart Gantt
Like this:
6july|||7july|||8july|||
valueAxis.setTickUnit(new DateTickUnit(DateTickUnit.HOUR,6));
///what needs to be extended here to get the desired format as said above
valueAxis.setDateFormatOverride(new SimpleDateFormat("'|'d,MMM"));
Thank you.
Because a Gantt chart uses a DateAxis for the range, you can invoke setDateFormatOverride(), as shown here. Of course you'll want to use getRangeAxis().
Addendum: Reading more closely, you can use setLowerMargin() and/or setUpperMargin() on the range axis to leave some room for the date over the end ticks.

Can I pass the Array values (not the array collection values) to the Bar charts or column charts using Flex 3.5?

Is there anyway where I can pass the Array values (not the array collection values) to the Bar charts or column charts using Flex 3.5?
Here what I need: I have array values like this,
array1 = [23, 49, 40, 239, 20, 80, 39,49,120, 24, 31,41];
and I want to show these values on the Y-axis and months on X-axis.
I have two questions:
How can I pass this array to Bar chart or column chart?
How do I need to show months on X-axis? I have kept a filters that even if we want to see some months or a particular months or particular span of months. On X-axis it need to change the months dynamically depending on the filters. For example on X-axis the values should be [Jan, Apr, Jun, Oct] if I select the 3 months period filter
I have written a logic to collect the values of those particular months into an array, but I don't understand how to pass this array to Bar chart, because there I don't know what X-field and Y-field to be given.
1) how can I pass this array to Bar
chart or column chart.
The dataProvider property of the charts is an object. So you can send anything you want in there. I would expect it to handle an array just as well as it would handle an ArrayCollection.
That said, I believe you're going to have to send in objects with data properties that represent the xField and yField values. An array of simple values doesn't give the component enough information to know what to do.
2) how do I need to show months on
Xaxis. beacuse I'm asking this
regarding, I have kept a filters that
even if we want to see some months or
a particular months or perticalar span
of months... there on Xaxis it need to
change the months dynamically
depending on the filters..... (for ex,
on Xaxis the values should be (Jan,
Apr, Jun,Oct) if i select the 3 months
period filter....)
I believe if you create objects, as I stated before with the Xfield value being a string representing the month and a y field value representing your data point, the graph should know how to display the values.
If you were using an ArrayCollection you could easily use the collection's filtering abilities to change the dataProvider, which I would expect would change the graph.
More docs on this

Resources