|
|
Re: Chart Engine and zooming [message #367751 is a reply to message #367729] |
Mon, 06 April 2009 18:51 |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Marius,
The SVG viewer comes with Zoom capabilites but this does not change the
dataset. I assume you want to alter the grouping unit/min max and step
an re-render the chart?
If this is what, David posted some code that modifies the model. You
should be able to changes these values and just rebuild the chart.
public Chart zoom(Chart cm, String zoomValue){
ChartWithAxes chart = (ChartWithAxes)cm;
Axis xAxis = (Axis) chart.getAxes( ).get( 0 );
Scale xScale = xAxis.getScale( );
SeriesDefinition xSeriesDef =
(SeriesDefinition)xAxis.getSeriesDefinitions( ).get( 0 );
SeriesGrouping xGrouping = xSeriesDef.getGrouping( );
Calendar today = Calendar.getInstance( );
today.setTimeZone( TimeZone.getTimeZone( "GMT+2" ) );
today.set( Calendar.MONTH, Calendar.AUGUST );
today.set( Calendar.DATE, 6 );
today.set (Calendar.HOUR, 16);
today.set( Calendar.MINUTE, 0 );
today.set( Calendar.SECOND, 0 );
xScale.setMax( DateTimeDataElementImpl.create( today ) );
Calendar start = (Calendar)today.clone( );
start.set( Calendar.HOUR, 9 );
start.set( Calendar.MINUTE, 30 );
start.set( Calendar.SECOND, 0 );
int groupingInterval = 1;
GroupingUnitType groupingUnit = GroupingUnitType.DAYS_LITERAL;
ScaleUnitType scaleUnit = ScaleUnitType.DAYS_LITERAL ;
double step = 1;
if ( zoomValue.equals( "1d" ) )
{
groupingInterval = 2;
groupingUnit = GroupingUnitType.MINUTES_LITERAL ;
scaleUnit = ScaleUnitType.HOURS_LITERAL ;
step = 2;
}
else if ( zoomValue.equals( "5d" ) )
{
start.add( Calendar.DATE, -5 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.HOURS_LITERAL ;
scaleUnit = ScaleUnitType.DAYS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "1m" ) )
{
start.add( Calendar.MONTH, -1 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.HOURS_LITERAL ;
scaleUnit = ScaleUnitType.DAYS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "3m" ) )
{
start.add( Calendar.MONTH, -3 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.DAYS_LITERAL ;
scaleUnit = ScaleUnitType.WEEKS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "6m" ) )
{
start.add( Calendar.MONTH, -6 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.DAYS_LITERAL ;
scaleUnit = ScaleUnitType.MONTHS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "YTD" ) )
{
start.set( Calendar.MONTH, 0 );
groupingInterval = 2;
groupingUnit = GroupingUnitType.DAYS_LITERAL ;
scaleUnit = ScaleUnitType.MONTHS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "1y" ) )
{
start.add( Calendar.YEAR, -1 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.WEEKS_LITERAL ;
scaleUnit = ScaleUnitType.MONTHS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "5y" ) )
{
start.add( Calendar.YEAR, -5 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.MONTHS_LITERAL ;
scaleUnit = ScaleUnitType.YEARS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "10y" ) )
{
start.add( Calendar.YEAR, -10 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.MONTHS_LITERAL ;
scaleUnit = ScaleUnitType.YEARS_LITERAL ;
step = 1;
}
else if ( zoomValue.equals( "All" ) )
{
start.add( Calendar.YEAR, -10 );
groupingInterval = 1;
groupingUnit = GroupingUnitType.MONTHS_LITERAL ;
scaleUnit = ScaleUnitType.YEARS_LITERAL ;
step = 1;
}
xGrouping.setGroupingInterval( groupingInterval );
xGrouping.setGroupingUnit( groupingUnit );
xScale.setUnit( scaleUnit );
xScale.setStep( step );
xScale.setMin( DateTimeDataElementImpl.create( start ) );
xScale.setShowOutside( false );
return cm;
}
Jason
Marius Cetateanu wrote:
> Anyone?
>
> I don't need a full example, just a hint or someone to point me in the
> right direction (where in the charts engine sources should i look?). Is
> it even possible to zoom in/zoom out (or drill through)?
>
> Thanks
>
|
|
|
|
Re: Chart Engine and zooming [message #502850 is a reply to message #502772] |
Wed, 09 December 2009 22:47 |
|
Samir,
In this same thread is an example David posted that modifies a chart
model. Will that example not work for you or are you wanting something
in JavaScript?
Jason
samir wrote:
> Hi, I have the same problem; but I need more details about zoom In/zoom
> out of selected area in the chart ! Could you give me a complete java
> class to complete my works ! I'm completely bloqued ... It's too urgent
> please ! :?
> Thanks a lot
|
|
|
Powered by
FUDForum. Page generated in 0.03395 seconds