DBI Cheats

Hi Toufik, the sample script is meant to read the values of the data points under the location of the mouse. If you would like to get to the value of a different series, then you need to position the mouse over that series.

You can also get access to the entire cellset being shown on a chart using chart1.metricSetBindings[0].dataResult.cellset.rows or chart1.metricSetBindings[0].dataResult.cellset.cells

I know but accessing that whole dataset will not be aligned with current mouse position.

I want to be able move the mouse anywhere and show on a couple of labels the X axis value and the values of all series corrzsponsing to the same x axis value.

Instead of hitTest(), you can get the index of the entire row corresponding with the mouse position with:

e.relatedData.rows[0]


Then, you can access each cell value in this row:

chart1.metricSetBindings[0].dataResult.cellset.cells[measureIndex][rowIndex].value

where [measureIndex] is e.relatedData.columns[0] and [rowIndex] is e.relatedData.rows[0]


For example:

var row = e.relatedData.rows[0];

var xValue = "";

chart1.metricSetBindings[0].dataResult.cellset.cells.forEach(function(measure){xValue += "/"+ parseFloat(measure[row].value);});

label.labelText = xValue;

Controlling Left Axis scale with Right Axis

I had a need for a bar and line chart in one graph with the Left X Axis for the bars (big numbers) and the Right X Axis for the line (small numbers). Once I got all that worked out the scaling for the line graph was following its own rules and looking as big bar chart numbers. I found the "Share the scale with another chart or axis" but this made it so the line part of the graph was just a striaght line at the bottom.


What I needed was for the Left Axis to be controlled by the Right Axis but by a factor.


This is what I came up with and it woking quite nicely.


On the chart Data Changed script (put here because like most chart it has a filter and the right axis scale changes depending on what is selected).


Put this simple script:

chart1.control.y2Axes["0"].autoMaximumLowerLimit = chart1.control.yAxes["0"].actualMaximum/2;


I at first had this to help me dig into all the parts (using the Browser developer tools) and figure out what is was I needed to do.

debugger;
var axesRight = chart1.control.y2Axes;
var axesLeft = chart1.control.yAxes;

var max = axesLeft["0"].actualMaximum; //so I could run in debugger and see the value, looked at many different things with that.
axesRight["0"].autoMaximumLowerLimit = axesLeft["0"].actualMaximum/2;


You might not need this one linner script but the process that I went trough to find what I was looking for might be what you need. By looking at the API Docs and saying that sounds like what I need but it was not when I actually ran it in the debugger and saw that not the value I am expecting. Then going back through the list (some times the list is short and others there are a lot of simular sounding like in dundas.controls.ChartAxis).


Reminder: Try to remeber to cleaned up your "Trying Things Out Code" into production code.


The link is not there any more :(

Luis thanks for sharing this.

I needed this but for showing a layer and also controled the parameter filter value based on what section of a pie chart was clicked.

I made a little script on a No Data Action that goes back one time period.


// Get the parent view.
var parentView = this.parentView;
// Get the view parameters.
var viewParameters = parentView.control.viewParameters;
// Using the library, get the view parameter based on it's name
var viewParameter = this.parentView.control.getViewParameterByName("jvMetricMatLaborRevDateviewParameter");
//Go back one time period on offset
viewParameter.parameterValue.token.offset = viewParameter.parameterValue.token.offset -1;
viewParameter.invalidateParameterValueLastModifiedTime();
viewParameter.refreshAllAdapters();


At first this was really long, I was copying the token then clearing tokens and values then setting the token.

Turns out all that was need was to change the offset value.


This goes back one time period (what ever the level is set to) if that new one has no data it just keeps going untill it "Has Data".

Here is a working link for that article:

https://www.dundas.com/support/support-center/support-articles/metric-sets/display-top-n-other-measures-using-data-cube-transforms

This is amazing! Bookmarking this thread right away!

Good idea! Very useful for many cases!

1 Like

Cool ! We did a google like search in which we invented a key pressed event in JS :slight_smile:

1 Like

Very cool and useful! Great idea!

This forum thread is great, but I would like some way to organise it as it is unwieldy to find the piece that you want when you need it.

1 Like

I completely agree, it need to be it own forum topic so that we can have a thread per tip or trick (or is it trick or treat today :scream::ghost:)

If you hold down control when using the arrow keys, then it moves 10 pixels instead of the 1 when you don’t hold down control key.

1 Like

Doesn’t work on osx Chrome

This is all interesting but very unorganised as there are no categories or anything like that. hard to find things

It should work on Chrome as well (at least it does for me). Can you confirm you are holding down the “ctrl” key and hitting the arrow keys? If indeed it doesn’t work with you then we can work with the support team to further investigate.

I wish I could refute that, but you are correct! Unfortunately, when this thread was first created it was prior to our new User Forums structure, making it much more difficult to separate (and navigate) threads. Since there’s such a great wealth of knowledge in this thread, we felt it worthwhile to keep it (as cumbersome as it is) vs. removing it entirely.

That being said, it is now easier to search for the cheats within this thread using our new, advanced search functionality (you just may need to know what you’re searching for :wink:)

We’ve also separated our tips of the week into individual threads now so they are much easier to find. A great starting place as well is our business intelligence resources thread - we update this frequently with new content.

Could Lock this tread and make a new Category for new ones to go?