All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pingunaut.wicket.chartjs.core.DataSetChartPanel Maven / Gradle / Ivy

Go to download

chart.js for wicket projects. simple but nice looking charts with html5/css/js

There is a newer version: 7.0.1
Show newest version
/*******************************************************************************
 * Copyright 2013 Martin Spielmann
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.pingunaut.wicket.chartjs.core;

import org.apache.wicket.model.IModel;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.pingunaut.wicket.chartjs.chart.IDataSetChart;
import com.pingunaut.wicket.chartjs.core.panel.BarChartPanel;
import com.pingunaut.wicket.chartjs.core.panel.LineChartPanel;
import com.pingunaut.wicket.chartjs.core.panel.RadarChartPanel;
import com.pingunaut.wicket.chartjs.data.AbstractChartData;
import com.pingunaut.wicket.chartjs.data.sets.AbstractBaseDataSet;
import com.pingunaut.wicket.chartjs.options.AbstractChartOptions;

/**
 * The Class DataSetChartPanel is a prototype for
 * 
    *
  • {@link BarChartPanel}
  • *
  • {@link LineChartPanel}
  • *
  • {@link RadarChartPanel}
  • *
* * @param * the generic type of the corresponding chart * @param * the generic type of the data displayed by the chart * @param * the generic type of the chart's options * @param * the generic type of the data's dataset */ public abstract class DataSetChartPanel, D extends AbstractChartData, O extends AbstractChartOptions, S extends AbstractBaseDataSet> extends AbstractChartPanel { private static final long serialVersionUID = -7183004710065804456L; /** * Instantiates a new data set chart panel. * * @param id * the markup id * @param c * the IModel of a {@link IDataSetChart} */ public DataSetChartPanel(String id, IModel c) { super(id, c); } /** * Instantiates a new data set chart panel. * * @param id * the markup id * @param c * the IModel of a {@link IDataSetChart} * @param width * the width * @param height * the height */ public DataSetChartPanel(String id, IModel c, int width, int height) { super(id, c, width, height); } /* * (non-Javadoc) * * @see com.pingunaut.wicket.chartjs.core.AbstractChartPanel#generateChart() */ @Override public String generateChart() { String dataString = null; String optionString = null; try { dataString = getChart().getMapper().writeValueAsString(getChart().getData()); optionString = getChart().getMapper().writeValueAsString(getChart().getOptions()); } catch (JsonProcessingException e) { e.printStackTrace(); } return "WicketCharts['" + getChartCanvas().getMarkupId() + "']." + getChart().getClass().getSimpleName() + "(" + dataString + ", " + optionString + ");"; } }