Accessing non-axis data attributes in dimple.js - d3.js

One of my favorite aspects of d3 is that it groups collections of data that can be accessed easily at any point in the process of creating and drawing a visualization.
I picked up Dimple to build some prettier graphs, implementing the following example:
http://dimplejs.org/advanced_examples_viewer.html?id=advanced_dynamic_line_color
I'd like to access an ID attribute of my data in an onclick event associated with the data points. Unfortunately, the only data passed to these events by dimple is the axis coordinates.
Is there a simple way to get at the rest of the attributes of the data in dimple?

The reason is that dimple will pre-aggregate the data so it doesn't work from the original data rows. Virtually all of the examples on the dimple website are drawn from the same tsv and in each case dimple aggregates the data to different levels. The benefit of this is that it means you can use very similar code for a line, area, bubble, bar or pie chart at any level of aggregation without any data manipulation in your own code.
Therefore if you would like another field it must be part of the aggregation, you can include as many fields as you like in the the series definition so:
var lines = myChart.addSeries(null, dimple.plot.line);
could become:
var lines = myChart.addSeries(["Brand", "Owner", "SKU", "Product"], dimple.plot.line);
And those 4 fields would be accessible.
Beware though that a line will be drawn for every distinct combination of those dimension values so you can't use this method to access a more granular datum.

Related

Amazon Quicksight - How do I show two different filters of the same data on the same line graph?

In Amazon Quicksight, I have a dataset with a bunch of data items which are imported into SPICE from JSON in S3. For simplicity, assume that data items look like this:
{url: "/us/page1.html", errors: 6, Responsetime: "2021-03-21T10:00:01"}
There are many data items for the same URL, run on different test dates (the Responsetime).
I can create a graph, a "visual", of total errors over time for all urls by making a line chart with value sum(errors) and X dimension of Responsetime, and that works fine.
I can create the same visual showing total errors over time but only for URLs matching /us/ by creating a custom filter for url matching contains /us/ and applying this filter to the visual, and this also works fine and looks like this:
I can create the same visual showing total errors over time but only for URLs matching /blog/ by creating a custom filter for contains /blog/ identically to the above but with a diferent filter, and this also works fine and looks like this:
What I want to do is display those last two graphs as two lines on the same graph. So I have one linechart with two values on it, where one value is field errors filtered by url contains /us/, and the second value is field errors filtered by url contains /blog/. That is, something like this:
How do I do this?
I know how to plot two different values on the same linechart, but not how to plot the same value but filtered in two different ways.
you can create a calculated field like url_type and pass the formula to know what type of url is it
ifelse(locate({url}, "/us/") > 0, "us",locate({url}, "/blog/") > 0, "blog", "other")
and add this calculated field to the color of the line chart. This will divide the same dataset into two parts.
The url_type field will have "other" value as well, you can add a filter if that's not needed.

Linkmap graph using 3DJS

I have a website linking map in a csv file. it is represented by 2 column, one for Origin URL and one for Target URL
I would like to draw a chart that represent the relationship between all pages. I'm looking for a logic to implement that make me draw the chart using 3DJS
I used the collapsed force layout of 3DJS https://bl.ocks.org/mbostock/1062288
As you can see, the JS parse a JSON file that represent the relationship between nodes.
here is what my mapping looks like https://imgur.com/uzh1lnR
Currently, I have my data stored in a database. I can parse it and create a JSON/CSV file. I'm looking for an appropriate format for that JSON file
any help ?

Extract a column from crossfilter

Heres my problem. I have a working dc.js based dashboard and some data within it. A column of the data contains text data (twitter info). Is it somehow possible to extract that specific column from crossfilter? My aim is to create some charts and the crossfilter containing the text data should feed into a d3 based word cloud so that i can do the drill down based filtering as well which dc and crossfilter provide out of the box. I tried a dimension.top(infinity) but that returns all the key value pairs in the data. I just need the values for a particular key across the whole data set. I hope my question makes some sense.
EDIT:
More research reveals that the wordcloud will accept data in key value pair where the key is the word and value is its frequency of appearance. So i am guessing that will need to be implemented as well. If there is a ready to implement library out there kindly let me know as well. This changes things a bit as far as crossfilter is concerned.I need to throw this calculated key value pair (fit for the word cloud consumption) whenever a filter is triggered. How to go about it?
Looking forward to hearing from you all.
Best,
Anmol
Answer to the first part of the question: Probably dimension.top(Infinity) and then use an accessor to get the values you need. Not exactly efficient, but it is what it is.
Answer to the 2nd part of the question:
You need groupAll, I think. You want to take a tweet, generate an array of tokens (words), then generate a Crossfilter grouping that is a count per word, right? You can code your own custom crossfilter.dimension.groupAll reducers (if you want to do that, create a working example and I can probably cook it up). Or if you want to use Reductio:
tweetWords = data.dimension(function(d) { return d.tweetText.split(' '); });
wordCounts = tweetWords.groupAll();
reducer = reductio()
.groupAll(function(d) {
return d.tweetText.split(' ');
})
.count(true);
reducer(wordCounts);
wordCounts.all();
If you want to filter on this dimension you'll have to override the filter handler and check if the group key is in the dimension array for the record using a filterFunction.

Tableau calculated-field filter on pie-chart doesn't work

Based on previous question, I had to create calculated value for Location, and use that as quick filter, i.e.
Location Filter:
LOOKUP(ATTR([Location (Loc)]),0)
Workbook is on Public Tableau
For hovering over points in a map, the calculated field works, but when I create pie chart, it doesn't work.
For instance, if I select All, this is the result
And if I select a business from Location Filter, this is what I get
How to troubleshoot?
Additional Info
However, if I use regular Location filter, then it works, i.e
There are two separate issues to address here:
LOOKUP(ATTR([Location (Loc)]),0) is a sneaky way of filtering the data in the view while still maintaining all of the locations in the partition (by disguising the field as a table calculation, the filtered partition is created before this table calculation is ever executed). Because you've used it here, you still have every location in the partition, even when you filter them out with the quick filter. Because they're still in the partition, when you calculate the percent of total, those other locations will be included in that total, even if they're not displayed in the view.
I don't see a reason for you to keep all of the locations in your partition in this case, so I'd just replace that filter with [Location].
It looks like you've dragged [Location] into your mark as a dimension. As a result, it's broken up the pie slices into smaller chunks, one per location. If you add a dimension to your data, then Tableau will have to group by that dimension when calculating the aggregations.
If you want the Location to appear in the tooltip of your pie chart, you'll have to either add it as an attribute (in which case you'll have to deal with the "*" when you have more than one location in the partition), or you'll just have to deal with the slices being broken up further.

TABLEAU: Create global filter from a secondary data source to multiple data sources on dashboard

I have a Tableau dashboard with various visualizations created from 3 data sources (i.e. A,B, C).
Each data source has a relationship (join) with the same secondary data source (i.e. D), and the secondary data sources provides information to create a filter for each data source. In other words, there is the following relationship for my data sources:
A - D
B - D
C - D
I would like to create a global filter on a dashboard I have created. I would like one filter card from "D" to show up and be applied to "A," "B," and "C" at once rather than having a separate filter card show up for each data source.
I tried to create a global filter via a parameter and calculated field, but the parameter requires layers of connections because data sources "A,B, and C" only have "D" in common.
Thoughts?
Its not completely clear from your question, but it sounds like you are using Tableau data blending on your worksheets to include data from multiple data sources, rather than a join to create a data source based on multiple tables. If all your tables are on the same database server or spreadsheet, then traditional joins are usually more efficient than data blending.
The following approach often works well.
Instead of using Tableau's quick filter feature, create a worksheet based solely on D that shows the values you wish to use for filtering. It can be a simple list of names, or a bubble chart or anything you like. Use that worksheet as your filter by creating actions where it is the source and all the other worksheets on your dashboard are the target. Typically, you would want to specify the field names explicitly.
Data blending is useful but can be complex. Depending on details, you may need to make D the primary data source on your other worksheets. Experiment.
The parameter and calculated field you mentioned can be even simpler and faster than using actions, but users are restricted to selecting a single value for a parameter unlike the filter action approach. (Of course, one parameter value can represent multiple values in your target data source field depending entirely on how your calculated field interprets the parameter).
I can't tell why that didn't work for you or what you mean by "layers of connections". You might consider clarifying that part of your question.

Resources