I am writing an application that uses Jfreechart to plot a simple bar chart, this chart needs to respond to mouse clicks from the user. I would like to change the color of the bar that is clicked on by the user. I know that the event will be a ChartMouseEvent that will be handled by the ChartMouseListener but I am a little confused about how to change the color of the ChartEntity once I have received it from the event.
Any help would be much appreciated.
You can change the color of an individual bar by overriding the renderer's getItemPaint(), as shown here and here for other renderer's. Once you receive a ChartEntity of type CategoryItemEntity, you can determine which dataset, series, and bar was clicked. Then you can condition your custom renderer's to apply the desired color with the next repaint().
Alternatively, display each series and color in a JTable and use JColorChooser to select colors, as shown in How to Use Tables.
Related
I've got lots of items in a dimension and the display by default is really bad.
How can I show this chart only if the user select less than 5 items in that dimension ?
You could use a display condition on the object.
Open the setting window of the chart holding the click on the chart
Fill the change option button with a statement as below:
{"display_condition":{"condition":"COUNT(DISTINCT *your_dimension*)=2", "message":"Please select only 2 items of *your_dimension* to see the chart !"}}
Leave the message property empty to see the default message or just write a space if you don't want any message.
I'm using Material Table at the moment and am having difficulty customizing the position of the selection text (presented when one or more rows are selected via the checkbox).
Looking at the documents, I can see that the toolbar is overridable (https://material-table.com/#/docs/features/component-overriding), however the examples show simpler changes e.g. how to change the background color. I wonder if it's possible to separate the selection text from the toolbar and render it in a different location, like the below picture demonstrates.
Does anyone know if this is possible?
In the end, I turned off the row selection text in the toolbar by using showTextRowsSelected: false
I then made a custom footer using the row data presented by the onSelectionChange handler.
I have very simple grid which contains a lot of data - so my scroll ball is quite narrow. I edit data in cells. Left to my grid there is picture with coordinates points. I wish this behavior: when I click on coordinate point I want to go to corresponding grid row. They are related by id(id row = id point div). How can it be made?
Also when I edit grid in the middle and bind coordinates of new point to row(by using store) - the grid gets automatically reloaded after store is updated - and scroll gets to the top. How can I track last edited row in the middle of the list so I can auotmatically focus on it? Thanx in advance.
use the focusRow method (http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.view.Table-method-focusRow) to scroll where you want, for example :
yourGrid.getView().focusRow(10);
To disable the 'scroll to the top" effect when you reload the grid, set preserveScrollOnRefresh to true on the viewConfig of your grid (http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.view.Table-cfg-preserveScrollOnRefresh).
I am new in ADF and my requirement is that when I run the page containing the drop down list input box initially it should be yellow colour with blank input box and after clicking on drop down list then list comes in white background colour. After select any value from list again it display the yellow background input box with selected value.
You will need to use an ADF Skin (ex: https://blogs.oracle.com/jdevotnharvest/entry/how_to_learn_adf_skinning).
You will need to define several StyleClasses for each of your cases and apply that style class when needed.
I have two columns in my NSOutlineView. One is a Text and image cell (similar to the class in the DragNDropOutlineView Apple sample code). Next to that is a custom NSCell subclass called "XFToggleCell" that is used to display a visibility icon (eyeball) that you can toggle on and off (just like Photoshop).
The XFToggleCell supports mouse tracking/dragging (again, just like Photoshop) so you can click one eyeball, then drag down to show/hide multiple items at once. In the text and image cell, I display the text in gray when the item's hidden, and black when it's not.
Almost everything is working fine. When I click an eyeball (XFToggleCell), it's image clears out and my model object becomes hidden. However, the adjacent text and image cell's font doesn't become gray (it doesn't update) until I click the toggle cell again...and when I do, the coloring of the image and text cell's text is always opposite of what it should be (when the visibility is clicked on, the text goes gray, and vice versa).
I determined that the reason this is happening is because the text and image cell is being redrawn before the value of the toggle cell is changed. As a result, its display is always "one click behind". The sequence goes like this:
I mousedown on column 1's toggle cell.
The text and image cell in column 0 is redrawn.
The object value for the toggle cell in column 1 is changed.
The toggle cell in column 1 is redrawn.
If I can force a redraw of the text and image cell in column 0 as step 5 above, I should be good to go.
How do I force an update to the drawing of column 0's text and image cell as a result of clicking on column 1's cell?
Here's the implementation of what I think is the key method...In my XFToggleCell.m, which is in column 1:
- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
{
.
.
.
...do some stuff...
.
.
.
//Here's where I change the cell's object value, causing the cell to be redrawn.
//This part works fine.
[self setObjectValue:([self.representedObject newState]) ? self.image : nil];
.
.
.
//Why doesn't this next line update the adjacent cell?!?!?!?!?
//Column 0 contains the text and image cell I'm trying to update
[controlView setNeedsDisplayInRect:[(NSOutlineView *)controlView frameOfCellAtColumn:0 row:thisRow]];
}
return YES;
}
Well, I'm not quite sure why, but calling
[(NSOutlineView *)controlView setNeedsDisplayInRect:[(NSOutlineView *)controlView frameOfCellAtColumn:col row:row]];
didn't work when I put it at the end of
-(BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
in my XFToggleCell class.
So I tried adding
[outlineView setNeedsDisplayInRect:[outlineView frameOfCellAtColumn:col row:row]];
at the end of my
-(void) outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
method in my NSOutlineView datasource and it worked. Not sure why, but this is how to do it. If anyone can shed light as to why it didn't work calling essentially the same thing in the cell, I'd appreciate the info.