Package org.pentaho.chart.model

Examples of org.pentaho.chart.model.ChartModel


  public String createChartAsHtml( IPentahoSession userSession, Map<String, Object> parameterMap,
      String serializedChartDataDefinition, String serializedChartModel, int chartWidth, int chartHeight,
      String contentLinkingTemplate ) throws IOException {

    ChartModel chartModel = ChartSerializer.deSerialize( serializedChartModel, ChartSerializationFormat.JSON );

    String html = null;

    if ( chartModel.getChartEngineId() == null ) {
      // Load default value from system setting or take hard coded
      // Hard coded final fall back is Open Flash Chart
      String defaultChartEngine =
          PentahoSystem.getSystemSetting( "chartbeans/chartbeans_config.xml", "default-chart-engine",
              OpenFlashChartPlugin.PLUGIN_ID ); //$NON-NLS-1$ //$NON-NLS-2$
      if ( defaultChartEngine == null ) {
        defaultChartEngine = OpenFlashChartPlugin.PLUGIN_ID;
      }
      chartModel.setChartEngineId( defaultChartEngine );
    }
    // Check for render engine override
    String override = (String) parameterMap.get( "renderEngine" );
    if ( override != null ) {
      chartModel.setChartEngineId( override );
    }

    serializedChartModel = ChartSerializer.serialize( chartModel, ChartSerializationFormat.JSON );

    if ( contentLinkingTemplate == null ) { // use old version
View Full Code Here


  public String createChartAsHtml( IPentahoSession userSession, Map<String, Object> parameterMap,
      String serializedChartDataDefinition, String serializedChartModel, int chartWidth, int chartHeight )
    throws IOException {

    ChartModel chartModel = ChartSerializer.deSerialize( serializedChartModel, ChartSerializationFormat.JSON );

    String html = null;

    if ( chartModel.getChartEngineId() == null ) {
      // Load default value from system setting or take hard coded

      // Hard coded final fall back is Open Flash Chart
      String defaultChartEngine =
          PentahoSystem.getSystemSetting( "chartbeans/chartbeans_config.xml", "default-chart-engine",
              OpenFlashChartPlugin.PLUGIN_ID ); //$NON-NLS-1$ //$NON-NLS-2$

      if ( defaultChartEngine == null ) {
        defaultChartEngine = OpenFlashChartPlugin.PLUGIN_ID;
      }

      chartModel.setChartEngineId( defaultChartEngine );

    }

    // Check for render engine override
    String override = (String) parameterMap.get( "renderEngine" );
    if ( override != null ) {
      chartModel.setChartEngineId( override );
    }

    serializedChartModel = ChartSerializer.serialize( chartModel, ChartSerializationFormat.JSON );

    if ( JFreeChartPlugin.PLUGIN_ID.equals( chartModel.getChartEngineId() ) ) {
      final String SOLUTION_TMP_DIR = "system/tmp/"; //$NON-NLS-1$
      File chartFileOnServer =
          new File( new File( PentahoSystem.getApplicationContext().getFileOutputPath( SOLUTION_TMP_DIR ) ),
              java.util.UUID.randomUUID().toString() );

      BufferedOutputStream bos = null;
      try {
        bos = new BufferedOutputStream( new FileOutputStream( chartFileOnServer ) );
        this.internalCreateChart( userSession, parameterMap, serializedChartDataDefinition, serializedChartModel,
            chartWidth, chartHeight, null, bos );
      } finally {
        IOUtils.closeQuietly( bos );
      }

      IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
      String contextPath = requestContext.getContextPath();
      String url = contextPath + "/"; //$NON-NLS-1$ //$NON-NLS-2$
      final String IMAGE_URL_TEMPLATE = "{0}getImage?image={1}"; //$NON-NLS-1$
      final String imageUrl =
          MessageFormat.format( IMAGE_URL_TEMPLATE, new String[] { url, chartFileOnServer.getName() } );
      html = this.mergeStaticImageHtmlTemplate( imageUrl );

    } else if ( OpenFlashChartPlugin.PLUGIN_ID.equals( chartModel.getChartEngineId() ) ) {

      ByteArrayOutputStream tmpOut = new ByteArrayOutputStream();
      this.internalCreateChart( userSession, parameterMap, serializedChartDataDefinition, serializedChartModel,
          chartWidth, chartHeight, null, tmpOut );
      final String ENCODING = "UTF-8"; //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.pentaho.chart.model.ChartModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.