i m working on a project using ZK charts Using MVC approach, what i want to do exactly is to change the background or to add a guideline ( with diffrent color) to a specific column for example the one with index 3 : where is what i do want to achieve
here is my chart :
and here is what i want with diffrent color in column with index 3 :
or with a guide line ( green color):
is this possible in Zk ? and thx
I don't know how useful this gonna be to you, i found this example about ZK charts, as the example shows in the model class it manages the colors as public static values, so, maybe you're managing the color in a similar way. here,
https://www.zkoss.org/zkdemo/chart/bar_chart
Then, if you wanna change a specific color of a bar, this example gives you a hint how to do it.
Related
My source is generating an agent called Sitz with several parameters which get their value out of a database. One of the parameters is product_type.
Now I would like to count and illustrate the number of Sitz for each product_type in bar chart.
I am thinking of a bar chart which shows 2 bars, one with Sitz product_type = A400S and one with Sitz product_type = A660.
My idea is to write something like sink.count(agent.product_type = "A400S") as value in the bar charts data section, but this is not the right way. What would be the right code?
There are a ton of ways, here is one:
First, create a variable countA440S. Then, in the sink, write
if (agent.product_type.equals("A400S")) {
countA440S++;
}
In your bar chart, link it to the variable as below:
PS: Best always check the example models first, many show how to apply these basic techniques
I am trying to show some data in a bar chart and stacked bar chart using JavaFx. I am using 4 series into which I populate the data, using eclipse oxygen.
I use series1 and series2 in the Bar Chart.
I use series1, series2, series3, and series4 in the Stacked Bar Chart.
I have created my screen using the JavaFx Scene Builder. Populate the scenes and displaying the data. My problem is that I am not able to show both the graphs at the same time. Only the latter gets populated, depending on the order of the population. The extra bit I have added is that the graphs expand on a mouse enter event and then reduces to the orginal size on the mouse exit event.
Can anyone help me by pointing out what I am doing wrong?
My code is as follows
#FXML
private void bcsbg_mouseentered() {
if (!clickEntered) {
clickEntered = true;
prefWidth = bcByGroup.getPrefWidth();
prefHeight = bcByGroup.getPrefHeight();
bcByGroup.setPrefSize(1500, 900);
gXAxis.setPrefHeight(Region.USE_COMPUTED_SIZE);
gXAxis.setPrefWidth(Region.USE_COMPUTED_SIZE);
gYAxis.setPrefHeight(Region.USE_COMPUTED_SIZE);
gYAxis.setPrefWidth(Region.USE_COMPUTED_SIZE);
gXAxis.setVisible(true);
gYAxis.setVisible(true);
gXAxis.setLabel("Value");
gYAxis.setLabel("Question");
gXAxis.setTickLabelsVisible(true);
gYAxis.setTickLabelsVisible(true);
gXAxis.setTickMarkVisible(true);
gYAxis.setTickMarkVisible(true);
sbcByAll.setVisible(false);
} else {
clickEntered = false;
bcByGroup.setPrefSize(prefWidth, prefHeight);
gXAxis.setPrefHeight(0);
gXAxis.setPrefWidth(0);
gYAxis.setPrefHeight(0);
gYAxis.setPrefWidth(0);
gXAxis.setVisible(false);
gYAxis.setVisible(false);
gXAxis.setLabel("");
gYAxis.setLabel("");
gXAxis.setTickLabelsVisible(false);
gYAxis.setTickLabelsVisible(false);
gXAxis.setTickMarkVisible(false);
gYAxis.setTickMarkVisible(false);
sbcByAll.setVisible(true);
sbcByAll.getData().clear();
sbcByAll.getData().addAll(series1, series2, series3, series4);
}
bcByGroup.getData().clear();
bcByGroup.getData().addAll(series1, series2);
}
The problem here is not in your code, but in the way the chart API is written. (I'm not normally a fan of criticizing languages or standard libraries, but parts of this API appear to have been written by an unsupervised intern with a particularly bad hangover.)
The XYChart.Data class keeps a reference to the node that displays the data. (This fairly obviously violates the most basic tenets of MVC, and makes separating the data into a different class completely redundant.)
Consequently, if you try to use the same data in two charts, the same node tries to appear in two parents, which is not allowed, and you only see the visualization of the data in one place. Unfortunately, you need to replicate the data for each chart.
Thank you, Dave. You are right. I did not go through the standard documentation on the XYData.Chart to notice that this object would be attached to the node in which the data was going to be displayed.
I was really hoping to avoid replication but the code does work as soon as the data series is replicated and attached to the different charts.
As mentioned by Dave,
The XYChart.Data class keeps a reference to the node that displays the data. (This fairly obviously violates the most basic tenets of MVC, and makes separating the data into a different class completely redundant.)
Please go through the standard documentation provided in Dave's link.
In my application I want to display some data on a pie chart. I'm using the MPAndroidChart library and following the documentation I managed to program a nice looking chart with all my data correctly displayed.
Now, I'd like to improve my chart, but I'm having some trouble. My data refers to a single day, but there are two categories: incomes and revenues. Until now I've handled them as a single PieDataSet (they have labels, so it is quite easy to distinguish among them). Now I'd like to differentiate among incomes and revenues, to show them with different colors in the same pie chart.
I tried following this link (the line chart part) adapting it to pie charts, but Android Studio tells me that I can't use a List<IPieDataSet> as parameter for a constructor of a PieData object. Here is the code:
public static void drawPie( List<PieEntry> entriesU, List<PieEntry>entriesE, PieChart chart){
PieDataSet set = new PieDataSet(entriesU,"uscite");
PieDataSet set1 = new PieDataSet(entriesE,"entrate");
List<IPieDataSet> dataSets = new ArrayList<>();
dataSets.add(set);
dataSets.add(set1);
set.setSliceSpace(5);
set1.setSliceSpace(5);
PieData data = new PieData(dataSets);
chart.setData(data);
}
I've searched a lot but I still haven't found an answer to this problem.
Question:
It is possible to display multiple data sets on the same pie chart or not? And if it is possible, how can I do it?
A pie-chart is a single 360-degree circle where slices represent percentages of a total of a given dataset. This only makes sense in the context of a single IDataSet. Therefore, unlike BarChart and LineChart, a PieChart doesn't support multiple IDataSet.
I think what you really want is to use different colors for your "incomes" and "revenues". To do this, all you need to do is create a List<Integer> of resolved colors (not color resources) where the position in the list matches the order the PieEntry is added to the chart.
To illustrate, let's say we have this:
entries.add(new PieEntry(15f, "entrate1")); //revenue1
entries.add(new PieEntry(20f, "uscite1")); //expense1
entries.add(new PieEntry(10f, "entrate2")); //revenue2
entries.add(new PieEntry(50f, "uscite2")); //expense2
You just create a List<Integer> of resolved colors that matches that:
List<Integer> colors = new ArrayList<Integer>();
colors.add(ContextCompat.getColor(context, R.color.red));
colors.add(ContextCompat.getColor(context, R.color.blue));
colors.add(ContextCompat.getColor(context, R.color.red));
colors.add(ContextCompat.getColor(context, R.color.blue));
dataSet.setColors(colors);
Now all your revenues are red and your expenses are blue. You can even be clever and write a function that maps PieEntry to colors rather than do it manually.
In any case, this answer here is correct for setting colors for the pie chart slices.
I am using a combined chart (Stacked Column + Line) for my application. Is it possible to change the line plotting?. (somewhat like shown in RED in the image). If yes then how is it possible?
I'm sure you already know the VIZ documentation where you can find all possible properties of VizFrame. As far as I know there currently is no way to get the behavior you're asking for except for writing your own lineRenderer (vizProperties.plotArea.lineRenderer). There is one alternative line plotting mode available which is smoothening it but I'm sure thats not what you want.
However you could use a second series of column chart instead. Just use a standard column chart and add two data series instead of one. I think this would show the exact information you're trying to get with the current diagram just no connection between them.
I've got a kinda requirement in which there is a kinda graph (static picture) on a page. In that picture I need to plot some points dynamically. That means using a shape filled with blue color. The number of points is floating depending upon the number of applicants choosen. How can I make it work or how can I add new elements to report at runtime. Am working in ASP.nET using VB and the AR version is 6.2
If I have understood your query right,then you want to plot some points depending on the dynamic data.
A suggestion would be to make use of Chart control in report. The chart can be bound to anything from a list to an array and the data can be changed dynamically from time to time.
Moreover,you can set the backcolor and other properties of the Chart control to give a look and feel of your choice.
Regards,
Mohita
Sorry if my question makes any confusion.. Actually I was able to make that. So am just sharing that code if it helpful for someone else.. I put this to the report start event. (We are not permitted to make this in details event)
Dim pic As New DataDynamics.ActiveReports.Picture
pic.Image = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(String.Format("~/images/circle.gif", cl)))
pic.SizeMode = SizeModes.Zoom
Detail1.Controls.Add(pic)