-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support/v4x mouse details on legend click - ticket 3005 (#578)
* Charts add-on modifications for adding MouseEventDetails to legend click events to server-side logic * Added TB Tests for Legend click MouseEventDetails
- Loading branch information
1 parent
8290f21
commit f279440
Showing
8 changed files
with
286 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ples/src/main/java/com/vaadin/addon/charts/examples/pie/PieWithLegendAndMouseDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.vaadin.addon.charts.examples.pie; | ||
|
||
import com.vaadin.addon.charts.Chart; | ||
import com.vaadin.addon.charts.LegendItemClickEvent; | ||
import com.vaadin.addon.charts.LegendItemClickListener; | ||
import com.vaadin.addon.charts.examples.SkipFromDemo; | ||
import com.vaadin.addon.charts.shared.MouseEventDetails; | ||
import com.vaadin.ui.Component; | ||
import com.vaadin.ui.Label; | ||
|
||
@SkipFromDemo | ||
public class PieWithLegendAndMouseDetails extends PieWithLegend { | ||
|
||
public static final String MOUSE_DETAILS = "mouse-details"; | ||
private Label mouseDetails = new Label(); | ||
|
||
@Override | ||
protected Component getChart() { | ||
|
||
Chart chart = (Chart) super.getChart(); | ||
chart.addLegendItemClickListener(new LegendItemClickListener() { | ||
|
||
@Override | ||
public void onClick(LegendItemClickEvent event) { | ||
updateMouseEventDetailsForLegendClick( | ||
event.getMouseEventDetails()); | ||
|
||
} | ||
}); | ||
return chart; | ||
} | ||
|
||
@Override | ||
protected void setup() { | ||
super.setup(); | ||
addComponent(mouseDetails); | ||
mouseDetails.setId(MOUSE_DETAILS); | ||
} | ||
|
||
protected void updateMouseEventDetailsForLegendClick( | ||
MouseEventDetails mouseEventDetails) { | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
|
||
sb.append("AbsX: " + mouseEventDetails.getAbsoluteX()); | ||
sb.append(" ").append("AbsY: " + mouseEventDetails.getAbsoluteY()); | ||
sb.append(" ").append("RelX: " + mouseEventDetails.getxValue()); | ||
sb.append(" ").append("RelY: " + mouseEventDetails.getyValue()); | ||
sb.append(" ").append("Bttn: " + mouseEventDetails.getButtonName()); | ||
sb.append(" ").append("Alt: " + mouseEventDetails.isAltKey()); | ||
sb.append(" ").append("Ctrl: " + mouseEventDetails.isCtrlKey()); | ||
sb.append(" ").append("Meta: " + mouseEventDetails.isMetaKey()); | ||
sb.append(" ").append("Shift: " + mouseEventDetails.isShiftKey()); | ||
|
||
mouseDetails.setValue(sb.toString()); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.