Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
3D Bar Chart and Hiding Series Lables
cgswtsu78
Does anyone know how to hide the series labels (each bar's label) that appear by default on a 3D bar chart along the x axis?
public Chart createChart(BaseChart chartSpec, ResourceBundle bundle) throws Exception
{
ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
cwaBar.setDimension( ChartDimension.THREE_DIMENSIONAL_LITERAL );
cwaBar.setType( "Bar Chart" ); //$NON-NLS-1$
cwaBar.setSubType( "Side-by-side" ); //$NON-NLS-1$
// Plot
cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
cwaBar.getBlock( ).getOutline( ).setVisible( true );
// Title
cwaBar.getTitle().getLabel().getCaption().setValue(chartSpec.getChartTitle() +
ChartUtils.getDateAsString(ChartConstants.DATE_FORMAT_YYYYMMDD, (String)chartSpec.getWhereClauseStmts().get("fromDate")) + " - " +
ChartUtils.getDateAsString(ChartConstants.DATE_FORMAT_YYYYMMDD, (String)chartSpec.getWhereClauseStmts().get("toDate")));
// Legend
cwaBar.getLegend( ).setItemType( LegendItemType.CATEGORIES_LITERAL );
// X-Axis
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];
xAxisPrimary.setType(AxisType.TEXT_LITERAL);
xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL);
xAxisPrimary.getLabel().getCaption().getFont().setRotation(90);
if(chartSpec.getxAxisTitle() != null)
{
xAxisPrimary.getTitle().setVisible(true);
xAxisPrimary.getTitle().getCaption().setValue(chartSpec.getxAxisTitle());
}
// Y-Axis
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(xAxisPrimary);
yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
if(chartSpec.getyAxisTitle() != null)
{
yAxisPrimary.getTitle().setVisible(true);
yAxisPrimary.getTitle().getCaption().setValue(chartSpec.getyAxisTitle());
}
//yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 90 );
// Z-Axis
Axis zAxis = AxisImpl.create(Axis.ANCILLARY_BASE);
zAxis.setType(AxisType.TEXT_LITERAL);
zAxis.setLabelPosition(Position.BELOW_LITERAL);
zAxis.setTitlePosition(Position.BELOW_LITERAL);
zAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
zAxis.setOrientation(Orientation.HORIZONTAL_LITERAL);
xAxisPrimary.getAncillaryAxes().add(zAxis);
// Data Set
TextDataSet categoryValues = TextDataSetImpl.create(chartSpec.getxAxis());
NumberDataSet orthoValues1 = NumberDataSetImpl.create(chartSpec.getyAxis());
// X-Series
Series seCategory = SeriesImpl.create();
seCategory.setDataSet(categoryValues);
SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().shift(0, 10);
xAxisPrimary.getSeriesDefinitions().add(sdX);
sdX.getSeries().add(seCategory);
// Y-Series (1)
BarSeries bs1 = (BarSeries) BarSeriesImpl.create();
bs1.setDataSet(orthoValues1);
bs1.getLabel().setVisible(true);
bs1.setLabelPosition(Position.OUTSIDE_LITERAL);
bs1.setTranslucent(false);
SeriesDefinition sdY = SeriesDefinitionImpl.create();
yAxisPrimary.getSeriesDefinitions().add(sdY);
sdY.getSeries().add(bs1);
// Z-Series
SeriesDefinition sdZ = SeriesDefinitionImpl.create();
zAxis.getSeriesDefinitions().add(sdZ);
// Rotate the chart
cwaBar.setRotation(Rotation3DImpl.create(new Angle3D[]{
Angle3DImpl.create(-10, 25, 0)} ) );
return cwaBar;
}
Find more posts tagged with
Comments
Virgil Dodson
I think you can use the setVisible() method on your Label as described here:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/documentation/BIRT_220/ChartJavadoc/chart/api/org/eclipse/birt/chart/model/component/Label.html'>Label
(BIRT Chart Engine API)</a><br />
<br />
maybe something like: <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
xAxisPrimary.getLabel().setVisible(false);
</pre>
<br />
However I noticed you are rotating these labels already so maybe you are talking about different labels?
cgswtsu78
I tried your suggestion but the label on the axis still shows on both sides of the chart (on the y axis). Somehow it's getting duplicated by morphing the chart into 3d...I'm stumped.
public Chart createChart(BaseChart chartSpec, ResourceBundle bundle) throws Exception
{
ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
cwaBar.setDimension( ChartDimension.THREE_DIMENSIONAL_LITERAL );
cwaBar.setType( "Bar Chart" ); //$NON-NLS-1$
cwaBar.setSubType( "Side-by-side" ); //$NON-NLS-1$
// Plot
cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
cwaBar.getBlock( ).getOutline( ).setVisible( true );
// Title
cwaBar.getTitle().getLabel().getCaption().setValue(chartSpec.getChartTitle() +
ChartUtils.getDateAsString(ChartConstants.DATE_FORMAT_YYYYMMDD, (String)chartSpec.getWhereClauseStmts().get("fromDate")) + " - " +
ChartUtils.getDateAsString(ChartConstants.DATE_FORMAT_YYYYMMDD, (String)chartSpec.getWhereClauseStmts().get("toDate")));
// Legend
cwaBar.getLegend( ).setItemType( LegendItemType.CATEGORIES_LITERAL );
// X-Axis
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];
xAxisPrimary.setType(AxisType.TEXT_LITERAL);
xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL);
xAxisPrimary.getLabel().getCaption().getFont().setRotation(90);
if(chartSpec.getxAxisTitle() != null)
{
xAxisPrimary.getTitle().setVisible(true);
xAxisPrimary.getTitle().getCaption().setValue(chartSpec.getxAxisTitle());
}
// Y-Axis
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(xAxisPrimary);
yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
if(chartSpec.getyAxisTitle() != null)
{
yAxisPrimary.getTitle().setVisible(true);
yAxisPrimary.getTitle().getCaption().setValue(chartSpec.getyAxisTitle());
}
//yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 90 );
// Z-Axis
Axis zAxis = AxisImpl.create(Axis.ANCILLARY_BASE);
zAxis.setType(AxisType.TEXT_LITERAL);
zAxis.setLabelPosition(Position.BELOW_LITERAL);
zAxis.setTitlePosition(Position.BELOW_LITERAL);
zAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
zAxis.setOrientation(Orientation.HORIZONTAL_LITERAL);
xAxisPrimary.getAncillaryAxes().add(zAxis);
// Data Set
TextDataSet categoryValues = TextDataSetImpl.create(chartSpec.getxAxis());
NumberDataSet orthoValues1 = NumberDataSetImpl.create(chartSpec.getyAxis());
// X-Series
Series seCategory = SeriesImpl.create();
seCategory.setDataSet(categoryValues);
SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().shift(0, 10);
xAxisPrimary.getSeriesDefinitions().add(sdX);
sdX.getSeries().add(seCategory);
// Y-Series (1)
BarSeries bs1 = (BarSeries) BarSeriesImpl.create();
bs1.setDataSet(orthoValues1);
bs1.getLabel().setVisible(true);
bs1.setLabelPosition(Position.OUTSIDE_LITERAL);
bs1.setTranslucent(false);
SeriesDefinition sdY = SeriesDefinitionImpl.create();
yAxisPrimary.getSeriesDefinitions().add(sdY);
sdY.getSeries().add(bs1);
// Z-Series
SeriesDefinition sdZ = SeriesDefinitionImpl.create();
zAxis.getSeriesDefinitions().add(sdZ);
// Rotate the chart
cwaBar.setRotation(Rotation3DImpl.create(new Angle3D[]{
Angle3DImpl.create(-10, 25, 0)} ) );
return cwaBar;
}
Virgil Dodson
Are you talking about the duplicated y-axis (along the sides) in the enclosed picture?