http://66.1.158.202:82/mystocks/CSCO.jpg
For those who want to know, here's how I did it.
My problem: I'm getting daily and intraday data of stock from my sqlserver. When I plotted it using DefaultHighLowDataset, it's showing gaps because of weekends and holidays.
1.0 Created a new class similar to DefaultHighLowDataset
So, I created a class similar to DefaultHighLowDataset. In that class I added another array index[] where I store increasing numbers starting from 2 (why 2, because I need some space on left side, default is 0 and I dont know how to change that YET .. using JFC since last 1 week only .. lot of learning etc etc).
2.0 Created a new class COPY of HorizontalNumberAxis
Copied HorizontalNumberAxis to another class. Tried to extend it but failed in some constructor issues. (I'm a Java lame, started learning java since last 3 weeks only. So if anyone wants to show me, that'll be great).
In this new HorizontalDateTimeLabelAxis class, I left everything as is except the refreshTicks method.
In the refreshTicks method, where it gets currentValue in the for loop, I added a call to my method in my modified defaultHighLowdataset where I return the string I want to print.
....................
String tl = dataset.getDateTimeLabel(1, currentTickValue);
...................
1 is meaningless as the dataset only store 1 series. Since all other getmethods in this are coded like that, so I left it that way.
Now, use this String "tl" to add to the Tick Label.
............................
Rectangle2D tickLabelBounds = tickLabelFont.getStringBounds(tl, g2.getFontRenderContext());
............................
3.0 Created a new method to create candlestickCharts
Except using the new HorizontalDateTimeLabelAxis. Also, we want to deal with integers when trying to access Date[] in the dataset. So, make sure to call setStandardTickUnits(TickUnits.createIntegerTickUnits()) for your horizontalaxis.
I'm also printing x-ticks vertical as its taking up too much space. Also, I may need to fudge with TickUnits so that I see less ticks on the horizontal axis. I see too many of them even when I make the chart small.
-------------------------------------------------------------------
Finally, a great many thanks to David ! Without whom this is not possible !
Hope this helps !!!
Mudit
p.s. : excuse my english and grammer. i code better than i type.
This is how I did Dates on x-axis !
Re: This is how I did Dates on x-axis !
Hi Mudit,
Good perserverance! I'm glad you got it working, and thanks for sharing the info with others.
Regards,
DG.
Good perserverance! I'm glad you got it working, and thanks for sharing the info with others.
Regards,
DG.
Re: This is how I did Dates on x-axis !
David,
I'm trying to create a new class HorizontalDateTimeLabelAxis. I'm able to finally extend HorizontalNumberAxis class to do the job except for one thing in refreshTicks(). Got all the quirks out.
I had comment these lines because selectAutoTickUnit() is private to the method. Is it possible to make it public so that HorizontalNumberAxis can be fully extended.
// if (super.autoTickUnitSelection) {
// super.selectAutoTickUnit(g2, drawArea, plotArea);
// }
Without this, the chart is always stuck at the 1 unit on x-axis.
Thanks
Mudit
I'm trying to create a new class HorizontalDateTimeLabelAxis. I'm able to finally extend HorizontalNumberAxis class to do the job except for one thing in refreshTicks(). Got all the quirks out.
I had comment these lines because selectAutoTickUnit() is private to the method. Is it possible to make it public so that HorizontalNumberAxis can be fully extended.
// if (super.autoTickUnitSelection) {
// super.selectAutoTickUnit(g2, drawArea, plotArea);
// }
Without this, the chart is always stuck at the 1 unit on x-axis.
Thanks
Mudit
Re: This is how I did Dates on x-axis !
David,
Right now I've two constructors and two methods (refreshTicks and selectAutoTickUnit) in this new class. Everything else is inherited.
So, I need to take care of two methods when a new release is announced.
Please see if selectAutoTickUnit() can be made public in future releases.
Thanks
Mudit
Right now I've two constructors and two methods (refreshTicks and selectAutoTickUnit) in this new class. Everything else is inherited.
So, I need to take care of two methods when a new release is announced.
Please see if selectAutoTickUnit() can be made public in future releases.
Thanks
Mudit
Re: This is how I did Dates on x-axis !
Mudit:
I would appreciate it if you can post the code it here.
Thanks
I would appreciate it if you can post the code it here.
Thanks