Tapestry: How to create stacked JqPlotBar chart - jqplot

How do I create a stacked JqPlotBar chart in Tapestry? This is what I have tried.
List<TextValueDataItem> list1 = CollectionFactory.newList();
List<List<TextValueDataItem>> dataList = CollectionFactory.newList();
list1.add(new TextValueDataItem("Test1", 50));
list1.add(new TextValueDataItem("Test1", 60));
dataList.add(list1);
return dataList;
The result I get is a bar chart with one color until 60, with points label at 50 and 60. There is also no legend.
Any help would be much appreciated. Thanks.

There is now an example of stacked bar chart at https://github.com/got5/tapestry5-jqPlot.
I have a problem when trying to package the project using maven mvn package. It is trying to search for files under folder org\got5\tapestry5\jquery\jqplot\jquery\jqplot_core\jquery\jqplot\v1_0_8 but the folder in your tapestry-jqplot jar file is capital V1_0_8. You need to change it to small letter v1_0_8 for the jar file to work.

Related

How to align legend dynamically on top-center of the chart in c3.js?

I want to put the same legend top center of the chart. Legend items will be dynamic, likes sometimes 2,5 or 9, etc.
So, it should take space dynamically like how it is acting on the bottom.
I tried with inset functionality but it seems this is not looking better like the bottom one.
and there are few more complexity like I want it like a flat, so now if I define step size 3 then maybe, for now, it looks good for 9 items. but when there will be 2 items, it will show as a list!!
Although I solved that problem through the following solution:
// get parent elements
let parentEle = d3.selectAll("#chartID svg");
let childrenEle = parentEle
//Convert selection to selection representing the children
.selectAll(function () { return this.childNodes; })
.filter('g');
// putting legends position on TOP
d3.select(childrenEle._groups[0][2]).attr('transform', 'translate(0, 5)');
you have to keep eye on chart width - height and according to this, you may have to control padding in TOP for the chart.
might be this is not a good solution but it works fine for me :D

horizontal bars with vaadein 8

i very new with Vaadin.
i have a chart with bars veritcally.
i want to geht horizontal bars
i have read here:
https://vaadin.com/docs/v8/charts/java-api/charts-charttypes.html
thats a part of my source (no errors):
Chart chart = new Chart(ChartType.BAR);
Configuration configuration = junkPerMachineChart.getConfiguration();
configuration.getChart().setType(ChartType.BAR);
configuration.addSeries(series);
junkPerMachineChart.setCaption("Stündlicher Verbrauch Mischer");
getUI().access(() -> junkPerMachineChart.drawChart());
i searched inside my junkPerMachineChart for a method like
.setType(ChartType.Vertical);
there is no option like this.
i also searched inside the configuration and found no method like this:
i changed ChartType to COLUMN and the bars are now horizontal
Configuration conf = junkPerMachineChart.getConfiguration();
conf.getChart().setType(ChartType.COLUMN);

Nvd3- is it possible to display any string value at x-axis at nvd3 line / bar chart?

I am using NVD3 chart library to display charts in my application.I used to show many chart types say line,bar,pie,scatter,etc..
Till now ,i used to show only integer/float values at x-axis of line/bar chart chart..Its working well.(Sample data : (x-10, y-50),(x-20, y-100))
But the problem is,when am trying to display the line chart with some string value at x-axis,the nvd3 chart doesn't display anything..Dont know where am going wrong?
(sample data : (x-sun,y-50),(x-mon,y-75),(x-tue,y-100))
Need help.Thanks in advance
Try this, it works for me:
select all the svg element that corresponds to text. container is a variable referring a string for selection of text;
d3.selectAll(container + ' .nv-x .tick text').text(function(d){return d;})

Select a line in a d3.js or nvd3.js line graph

In a D3 or NVD3.js line graph, how can I select a particular line once the graph is rendered? For example, suppose I want to animate the stroke width on a line, like this:
d3.selectAll('path').transition().duration(2000).style("stroke-width", "20");
The above will select all paths, obviously, but I would like to select a particular series—for example, the Oranges series in a data set defined like this:
var data = [{key: "Apples", values: array1},{key: "Oranges", values: array2}]
I thought something this might work, but it did not:
d3.select('#chart svg').datum(data[1]).transition... // or alternatively,
d3.select('#chart svg').datum(data[1].values).transition...
I've been trying to figure it out using the Cumulative Line Chart example in the code editor here, with no success: http://nvd3.org/livecode/#codemirrorNav
This is a very basic question, but I'm new to D3 and have been unable to figure it out.
There are couple of simple ways that I can think of:
You can store each path in its own variable (or inside an array):
var path1 = graph.append("g").append("path").data([data1]).attr("class", "line1");
Now you can apply your transitions to just this path variable and it should work.
Another option is to give each path a unique class and then use d3.selectAll(".uniqueclassname") and apply your transitions.
In this fiddle, look at the tick function (specially for the following piece of code).
// redraw the lines
graph.select(".line1").attr("d", line).attr("transform", null);
path2.attr("d", line).attr("transform", null);
path3.attr("d", line).attr("transform", null);
graph.select(".line4").attr("d", line).attr("transform", null);

Show tooltip of a column chart programmatically in StockChart (highchart)

I've a Highstock chart (Line with markers and shadow) and would like to show a highstock tooltip programmatically, i.e. when i select, for example, a row on some table (that contains chart data) i would like to show the corresponding highstock tooltip.
Is that possible?
For StockChart this solution doesn't work:
In this example you have to replace this:
chart.tooltip.refresh(chart.series[0].data[i]);
to this:
chart.tooltip.refresh([chart.series[0].points[i]]);
The solution is available here.
If what you want is to trigger tooltip on the plot near ith data point, then probaly you can use this answer, which suggest to do something like
chart.series[0].data[i].setState('hover');
where chart is the result of your new Highcharts.Chart. (jsfiddle from the comments to that answer).
I guess that if you want to do it on <tr> click, than your js could finally look like this
var chart = new Highcharts.Chart({ <your options> });
$('#yourTableId tr').click(function(){
var i = $(this).index(); // `this` points to <tr>, get its index
chart.series[0].data[i].setState('hover');
});

Resources