Listing category names in the legend - kendo-ui

I know this is a little outside of Kendo DataViz's intent but alas the client requested. I need my chart legend to consist of the category names instead of the series names. I has to be svg since this chart will be converted to a pdf later.
Here's a fiddle of what I have so far.
http://jsfiddle.net/JoelStransky/7QUt3/4/
function notsurewhyihavetoincludecode(){
return;
}

Related

How to integrate chart and table and make them dynamic?

I have two tables, one that shows the sales history of salespeople per year, and another table that shows the sales history in months. As you can see in the image below:
I need to create a composite chart (I believe it is a composite chart, as it will have more than 01 line) that is exactly the representation of the month table.
After creating the chart when I click on the seller Miguel for example, the chart will be rendered with the history of that seller.
And for example if I click on month 03 of the graph, the table of sellers will be rendered only with the sales that were made in month 03.
I don't know how to do it, I managed to create a composite chart that presents the same data as the month table, however, I was unable to integrate my chart together with my tables.
Can you tell me how I can do that?
I put the codes I made in JSFiddle, here are the links:
Sales/Month Table: https://jsfiddle.net/bernalvinicius/ejxcfpvz/15/
Month Chart: https://jsfiddle.net/bernalvinicius/kanm158j/17/
Thanks in advance.
Just put all your code in the same file(s), combine your crossfilter instances, and put all the charts in the same chart group (the default), and it should work fine.
The chart group is the second parameter to each chart constructor. If it's not specified, then the chart goes into the default chart group.
When any chart is filtered in a chart group, it will tell all the other charts in that chart group to redraw, and they will pull their new data from their respective crossfilter groups. (Sorry about the naming, a dc.js chart group has nothing to do with a crossfilter group.)
In order to combine your code, I renamed both of the crossfilter instances to cf. Then I added the new fields you are generating to the existing rows, instead of mapping the data:
data.forEach(d =>
Object.assign(d, {
mes: d.Month,
atual: d.Vendas_Ano,
passado: d.Vendas_Ant
})
);
In your table fiddle, you were initializing the table for every row in the data with a data.forEach() which wasn't necessary. That's why it was so slow to load.
Other than that, both fiddles had the same general structure so I just copied and pasted the code from the table fiddle to the composite fiddle, HTML, JS, and CSS.
In the JS I made sure to put the same lines outside and inside the d3.json() callback as before.
It looks like it works?
https://jsfiddle.net/gordonwoodhull/0q1y5ftr/15/

highcharts - onclick event handlers redraw/remove

Currently I have 4 charts. The selection (via column or legend) of a category from the main one triggers multiple events. It changes the selected item's color on two charts and it creates two more charts.
For the two created charts, I'm having problems with redrawing/removing (that is what I'm assuming I will have to do) when the column/legend is deselected.
I may be wrong but from what I've looked at, it seems that when you prevent show/hide it doesn't change the visibility property so I wasn't sure if there was a way to use that.
Any help would be appreciated!
Fiddle here: http://jsfiddle.net/jlm578/gy9og69r/4/
I also thought about whether I needed to add it into the logic of the function (possibly one below) or if the sibling aspect needed to be added to the others.
function drawSignifNonSignifEruptionsChart(series){
if (series.index == '0'){
var eruptVEI = ['VEI 0'];
var signifErupt = [10];
var nonSignifErupt = [600];
}

dc.js: using dc.dataCount counts in other d3 charts on page

In dc.js I'm displaying the number of filtered and total rows with dc.dataCount:
dc.dataCount(".dc-data-count", "charts")
.dimension(data_cf)
.group(all);
and
<div class="dc-data-count">
<strong class="filter-count"></strong> selected out of <strong class="total-count"></strong> records
On the same page, I have a d3 donut chart that I've drawn. Within this chart I'd like to display the filter-count (which updates as filters are applied), as well as other calculations like the sum of a value in the current selection. Given that dc.dataCount is accessed by a div class, I don't know how to access the number to place precisely in my donut chart.
How can I pass values from dc.dataCount or some other grouping into a d3 object?
Thanks!
I would do this with a renderlet on the donut chart that just reads the values you need, and adds them. Renderlets run after the chart has rendered, so there is a slight delay, but it shouldn't be too disturbing for this use.
As for how to get the numbers, there is no magic to the dataCount widget; it's just reading crossfilter values:
https://github.com/dc-js/dc.js/blob/master/src/data-count.js#L77
So you can add text elements to the svg using dimension.size() and group.value() in the same way.

Getting chart information from nvd3

I have a number of nvd3 charts on a page, and I store some useful information in the chart's id attribute (basically a rowkey that I used to populate the data).
What I want to do is fetch additional data when the user clicks a point on the graph.
The problem is, with many graphs on the page, when the user clicks (I have registered for lines.dispatch.on('elementClick')), I need to somehow know which graph I am on so I have the information I need to make the subsequent query.
Is there some way to grab the containing chart information when the user clicks on a point? Or knowing the chart's ID?
If you have jquery on your page, then you can use jquery.closest to look for the parent chart element and extract its ID:
.on('elementClick', function (d, i) {
var chartId = $(this).closest('svg').attr('id');
// ...
});

Filtering data for d3.js sankey diagrams

I'm trying to have a d3.js Sankey visualisation filter a data set according to categories.
I'm using d3.csv method to input the data as shown in this example - http://bl.ocks.org/timelyportfolio/5052095
I would however like to upload a data set with four columns -
source, target, value, category
My aim is to have a visualisation with the ability to switch between categories. So each Sankey visualisation will only represent one particular category. Then user can switch from the dropdown to another one.
Is this possible using the current d3.csv input method?
Would this work ?
d3.csv("file.csv", function(data) {
[...]
// Called each time there is an action on the dropdown menu
function updateGraph() {
// Select only data that are tagged with a certain category
var dataset = data.filter(function(d) { return d.category == selectedCategory; });
// Update graph visualization
}
}
This way you wouldn't have to reload your csv file each time.
This a very long method for the second part but, creating multiple html/php and csv files depending on your categories and then adding the following code in each of your html/php files. This method would be extra work if you have a lot of categories.
Category 1
category 2
If you figured out a solution the way you were trying it, then if possible please update your answer. it would be helpful.
Thanks.

Resources