I'm developing an application with the GWT framework and Sencha GXT on the front-end.
I managed to display some data in a pie chart but I would also like to have a label inside the donut pie chart like . I looked at the demo provided by sencha as well as the "Chart" class but I don't see any cases where there is text inside a pie chart. Is it feasible ?
I'm using "Sencha GXT 4.0.0 - Sencha for GWT"
I finally found a solution, I just need to use the setX method in my textConfig so my code looks something like this :
TextSprite textConfig = new TextSprite();
textConfig.setFont("Arial");
textConfig.setTextBaseline(TextBaseline.MIDDLE);
textConfig.setFontSize(18);
textConfig.setTextAnchor(TextAnchor.MIDDLE);
textConfig.setZIndex(15);
textConfig.setX(-150);
150 worked for me but maybe it won't for you.
Related
I'm using MPAndroid Chart , I'm trying to remove these 2 lines and I don't know how.
In my code I already have these:
chart.animateY(500);
chart.invalidate();
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setDoubleTapToZoomEnabled(true);
chart.setScaleEnabled(false);
chart.setTouchEnabled(false);
chart.getXAxis().setEnabled(false);
chart.getXAxis().setDrawLabels(false);
chart.getAxisLeft().setDrawLabels(false);
chart.getAxisRight().setDrawLabels(false);
chart.getLegend().setEnabled(false);
chart.getDescription().setEnabled(false);
chart.getXAxis().setDrawGridLines(false);
chart.getAxisRight().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getXAxis().setDrawGridLines(false);
What is it that I am missing?
From the docs, setDrawAxisLine(boolean enabled): Set this to true if the line alongside the axis (axis-line) should be drawn or not.
In your case you could try with
chart.getAxisLet().setDrawAxisLine(false)
chart.getAxisRight().setDrawAxisLine(false)
Hope it helps!
I'm creating an SWT (ported Mac OSX version) application. I am trying to set a specific button to have the bezel style of "inline". Here is what I want my button to look like on mac.
(screenshotted in storyboard view in xcode)
The code I am using to try to get this inline button:
// created button named "inlineButton" and applied layout to it.
// here is where I set the bezel style and text.
NSButton nsInlineButton = (NSButton) inlineButton.view;
nsSaveButton.setBezelStyle(15); // NSBezelStyleInline is enum 15 for cocoa
this.inlineButton.setText("Inline Button");
And the result:
(screenshotted from my java program)
I have also tried to redraw and relayout the shell and a variety of other methods with no avail.
Is this a bug or am I doing something wrong?
Solved. I just needed to add the SWT style of "FLAT"
this.inlineButton = new Button(this, SWT.FLAT);
NSButton inlineButton = (NSButton) inlineButton.view;
inlineButton.setBezelStyle(15);
I created a Vaadin pie chart with following code.
Chart chart = new Chart(ChartType.PIE);
DataSeries dataSeries = new DataSeries("Logins");
chart.getConfiguration().setSeries(dataSeries);
I need to update my chart dynamically. I tried following (this code gets executed whenever new data is available).
adding new item:
dataSeries.add(new DataSeriesItem("New item", value), true, false);
updating existing item:
DataSeriesItem dataSeriesItem = dataSeries.get(0);
dataSeriesItem.setY(newValue);
dataSeries.update(dataSeriesItem);
But none of the above worked.
The only solution I could find is clearing the chart (chart.clear()), re, populating the data series and re drawing the chart (chart.drawChart()).
This method is not optimal since it re-draws the chart, and also the selection in the chart gets lost.
Does pie chart support dynamic updating? Can anyone suggest a way to fix this?
Try to call chart.getConfiguration().addSeries(dataSeries) before updating items. If that doesn't work, I think you should re-draw your chart.
I had the same problem and fixed it with chart.drawChart() after updating the data series in configurations (chart.getConfiguration.setSeries(newSeries)).
In my case (vaadin version 7.6.3), chart.clear() was not required.
There are other more complicated ways like vaadin-push plugin as well which I didn't find necessary for my case.
I know this question is old, but I will share how I solved this problem to Chart Pie in DChart 1.7.0.
DataSeries dataSeries = new DataSeries();
dataSeries.newSeries();
dataSeries.add( "Food", 500);
dataSeries.add( "Clothes", 1000);
chart.setDataSeries(dataSeries);
chart.show(); //this will update the chart in the browser;
Late to the question, but I encountered similar problem in 2020, I solved it using below code:
dataSeries.clear();
dataSeries.add(new DataSeriesItem("Expense", 120));
dataSeries.add(new DataSeriesItem("Saving", 20));
dataSeries.add(new DataSeriesItem("Balance", 100));
chart.getConfiguration().setSeries(dataSeries);
chart.drawChart();
I am creating a Jasper report template in IReport which I'm compiling and filing using a Java application.
On a scatter chart I want to plot a regression line as a spline. Currently, the only way I found to do this was using the JFreeCharts XYSplineRenderer. However, this requires me to create the chart in my Java code and then pass it to the report as a parameter while filling it. This also requires me to customize the appearance of my chart in the code.
I would like to be able to design my chart inside the jrxml with IReport, compile the report in Java, fetch the chart object and set a custom renderer to it before filling it.
Something like this:
JasperReport report = JasperCompileManager.compileReport(reportIs);
JRChart jrChart = (JRChart) report.getSummary().getElementByKey("chart");
JFreeChart chart = jrChart.getJFreeChart(); // this method does not exist
((XYPlot)chart.getPlot()).setRenderer(new XYSplineRenderer());
The problem is that I can't find a way to retrieve an actual JFreeChart object from a compiled report, nor can I find any other method to pass a custom plot renderer to a chart.
Does anyone have any ideas?
Thanks in advance.
You can use a chart customizer to accomplish this. It allows you to access the chart as a JFreeChart (as well as a JRChart) which should be just what you need. Add a chart customizer to your chart by setting the customizerClass attribute. The customize method is called by Jasper and allows you to modify the chart during the report filling process.
Create a customizer that looks something like this:
public class MyChartCustomizer implements JRChartCustomizer {
#Override
public void customize(JFreeChart jFreeChart, JRChart jRChart) {
((XYPlot)jFreeChart.getPlot()).setRenderer(new XYSplineRenderer());
}
}
Then compile it and make sure that it's on Jasper's classpath when you come to fill the report.
I am using GXT for UI development. I have used HTML5 for Dragging file from Desktop to my application and upload it. But now i am having reverse requirement. I want to drag files from browser to desktop which will download the file to desktop.
I know that is possible in Chrome only. And had checked the below demo:
http://www.thecssninja.com/javascript/gmail-dragout
I had tried to implement the above code in my GXT application, but the issue is that i am using Editable Grid which is supporting DnD to TreePanel. Now when i drag from grid to Desktop i think its not capturing the browser event (may be i am wrong here).
Any idea, how it should be done?
Thanks.
Below is the small piece of code which i call after the Data had been inserted in Grid. All records are having the CSS class name as ".icon". The problem is that when i start to drag, the "dragstart" is not being called. Any suggestion?
NOTE: This code is working when i create Buttons, Labels, etc and making them draggable=true with other required parameters.
public static native void test(String id)/*-{
var files = $doc.querySelectorAll('.icon');
for (var i = 0, file; file = files[i]; ++i) {
file.addEventListener("dragstart",function(evt){
$wnd.alert("Drag Event started.. ");
evt.dataTransfer.setData("DownloadURL",this.dataset.downloadurl);
},false);
}
}-*/;
I used this, and it successully performs, no you should check some other place in your code.