Skip to content

Commit

Permalink
Merge pull request #2 from hatemalimam/v0.6
Browse files Browse the repository at this point in the history
V0.6
  • Loading branch information
hatemalimam committed Oct 22, 2015
2 parents e2dc2b4 + f3947af commit dc78e5a
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ ChartistJSF can be downloaded manually or via maven.

Version | Binary | Source
------------ | ------------- | -------------
0.5| [Download](https://oss.sonatype.org/content/repositories/releases/org/chartistjsf/ChartistJSF/0.5/ChartistJSF-0.5.jar) | [Download](https://oss.sonatype.org/content/repositories/releases/org/chartistjsf/ChartistJSF/0.5/ChartistJSF-0.5-sources.jar)
0.6| [Download](https://oss.sonatype.org/content/repositories/releases/org/chartistjsf/ChartistJSF/0.6/ChartistJSF-0.6.jar) | [Download](https://oss.sonatype.org/content/repositories/releases/org/chartistjsf/ChartistJSF/0.6/ChartistJSF-0.6-sources.jar)

##### Maven

```xml
<dependency>
<groupId>org.chartistjsf</groupId>
<artifactId>chartistjsf</artifactId>
<version>0.5</version>
<version>0.6</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<groupId>org.chartistjsf</groupId>
<artifactId>ChartistJSF</artifactId>
<packaging>jar</packaging>
<version>0.5</version>
<version>0.6</version>
<name>ChartistJSF</name>
<description>Highly Customizable Responsive Charts for JSF based on PrimeFaces</description>
<url>http://www.chartistjsf.org</url>
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/chartistjsf/model/chart/Axis.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public abstract class Axis implements Serializable {
private static final long serialVersionUID = 6059542550827836357L;

private int offset = 30;
private AxisPosition axisPosition;
private int xLabelOffset = 0;
private int yLabelOffset = 0;
private boolean showLabel = true;
Expand All @@ -56,6 +57,24 @@ public int getOffset() {
public void setOffset(int offset) {
this.offset = offset;
}

/**
* Position where labels are placed.
* Can be set to AxisPosition.START or AxisPosition.END where `start` is equivalent to left or top on vertical axis and `end` is equivalent to right or bottom on horizontal axis.
* @return the axisPosition
*/
public AxisPosition getAxisPosition() {
return axisPosition;
}

/**
* Position where labels are placed.
* Can be set to AxisPosition.START or AxisPosition.END where `start` is equivalent to left or top on vertical axis and `end` is equivalent to right or bottom on horizontal axis.
* @param axisPosition the axisPosition to set
*/
public void setAxisPosition(AxisPosition axisPosition) {
this.axisPosition = axisPosition;
}

/**
* Allows to correct label positioning on this axis by positive or negative
Expand Down Expand Up @@ -134,6 +153,8 @@ public boolean getShowGrid() {
public void setShowGrid(boolean showGrid) {
this.showGrid = showGrid;
}



/**
* Interpolation function that allows you to intercept the value from the
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/org/chartistjsf/model/chart/AxisPosition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2015 ChartistJSF.
*
* 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 org.chartistjsf.model.chart;

/**
* @author Hatem Alimam
* @since 0.1
*/
public enum AxisPosition {
START("start"), END("end");

private String type;

AxisPosition(String type) {
this.type = type;
}

@Override
public String toString() {
return this.type;
}
}
4 changes: 4 additions & 0 deletions src/main/java/org/chartistjsf/model/chart/LinearAxis.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void render(ResponseWriter writer, AxisType axisType) throws IOException
writer.write(", showLabel: " + this.getShowLabel());
writer.write(", showGrid: " + this.getShowGrid());

if (this.getAxisPosition() != null) {
writer.write(", position: '" + this.getAxisPosition() + "'");
}

if (getLabelInterpolationFnc() != null && !getLabelInterpolationFnc().equals(""))
writer.write(", labelInterpolationFnc: " + getLabelInterpolationFnc());

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions src/main/resources/META-INF/resources/chartistjsf/chartistjsf.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ChartistJSF.widget.Chart = PrimeFaces.widget.BaseWidget.extend({
var $toolTip = $chart.append('<div class="ct-tooltip"></div>').find('.ct-tooltip').hide();
var chartType = this.type;

$chart.on('mouseenter', '.ct-point, .ct-bar, .ct-slice', function() {
$chart.on('mouseenter', '.ct-point, .ct-bar, .ct-slice-pie, .ct-slice-donut', function() {
var $point = $(this), value = $point.attr('ct:value'), seriesName = $point.parent().attr('ct:series-name');
var tooltipText = value;
if (chartType !== 'Pie') {
Expand All @@ -114,7 +114,7 @@ ChartistJSF.widget.Chart = PrimeFaces.widget.BaseWidget.extend({
$toolTip.html(tooltipText).show();
});

$chart.on('mouseleave', '.ct-point, .ct-bar, .ct-slice', function() {
$chart.on('mouseleave', '.ct-point, .ct-bar, .ct-slice-pie, .ct-slice-donut', function() {
$toolTip.hide();
});

Expand Down Expand Up @@ -195,8 +195,7 @@ ChartistJSF.widget.Chart = PrimeFaces.widget.BaseWidget.extend({
seq++;
if (data.type === 'line') {
// If the drawn element is a line we do a simple opacity fade
// in.
// This could also be achieved using CSS3 animations.
// in. This could also be achieved using CSS3 animations.
data.element.animate({
opacity : {
// The delay when we like to start the animation
Expand All @@ -209,7 +208,6 @@ ChartistJSF.widget.Chart = PrimeFaces.widget.BaseWidget.extend({
to : 1
}
});

} else if (data.type === 'bar') {

if (chart.options.horizontalBars) {
Expand Down Expand Up @@ -294,27 +292,26 @@ ChartistJSF.widget.Chart = PrimeFaces.widget.BaseWidget.extend({
});
} else if (data.type === 'grid') {
// Using data.axis we get x or y which we can use to construct
// our
// animation definition objects
// our animation definition objects
var pos1Animation = {
begin : seq * delays,
dur : durations,
from : data[data.axis + '1'] - 30,
to : data[data.axis + '1'],
from : data[data.axis.units.pos + '1'] - 30,
to : data[data.axis.units.pos + '1'],
easing : 'easeOutQuart'
};

var pos2Animation = {
begin : seq * delays,
dur : durations,
from : data[data.axis + '2'] - 100,
to : data[data.axis + '2'],
from : data[data.axis.units.pos + '2'] - 100,
to : data[data.axis.units.pos + '2'],
easing : 'easeOutQuart'
};

var animations = {};
animations[data.axis + '1'] = pos1Animation;
animations[data.axis + '2'] = pos2Animation;
animations[data.axis.units.pos + '1'] = pos1Animation;
animations[data.axis.units.pos + '2'] = pos2Animation;
animations['opacity'] = {
begin : seq * delays,
dur : durations,
Expand Down

0 comments on commit dc78e5a

Please sign in to comment.