How to modify data-table columns with Highcharts - highcharts

Here is the fiddle I'm referring http://jsfiddle.net/mm484L57/
Highcharts.tableLine = function (renderer, x1, y1, x2, y2) {
renderer.path(['M', x1, y1, 'L', x2, y2]).attr({
'stroke': 'silver',
'stroke-width': 5
}).add();
};
I would like to get the legend on the table to be in rows rather in column,
it must be vice versa. Note: I'm referring to the data-table shown there. In
simple, City names(Tokyo, New York, Berlin, London) must be row wise and the
months should be column wise.
Any help is much appreciated.
Thanks.

Related

Trying to emulate Bressenham's Line Algorithm in Lua but it returns an error(CC: Tweaked)

I am trying to make a module for CC: Tweaked that as one of its features uses Bressenham's Line Algorithm to draw a line between 2 points on a monitor. However when I run my program I get this error:
pixels.lua:24: attempt to index local 'y1' (a number value)
Please note that I got this code from a youtube video and it is possible that I wrote something wrong.
Here is my code:
local pixels = {}
function pixels.drawPixel(x, y, monitor, color)
monitor.setCursorPos(x, y)
monitor.setBackgroundColor(color)
monitor.write(" ")
end
function pixels.fillScreen(color)
x, y = monitor.getSize()
for j = 1,y,1
do
for i = 1,x,1
do
pixels.drawPixel(i,j,monitor,color)
end
end
end
function pixels.drawLine(x1, y1, x2, y2, monitor, color)
error = 0
slope = y2 - y1 / x2 - x1
pixels.drawPixel(x1, y1. monitor, color)
for x = x1,x2,1
do
error = error + slope
if error >= 0.5
then
y = y1 + 1
error = error - 1
end
pixels.drawPixel(x,y,monitor,color)
end
end
return pixels
Line 24:
pixels.drawPixel(x1, y1. monitor, color)
As stated in the comments above, y1 has a period instead of a comma after it, telling Lua to look for a value from y1.monitor when y1 is not a table. Thus, "Attempted to index a number".
(Also, you do not have to declare your incrementor number with your for loops if the number is 1)

How to break a long line in Lua

Util = {
scale = function (x1, x2, x3, y1, y3) return (y1) + ( (y2) - (y1)) * \
( (x2) - (x1)) / ( (x3) - (x1)) end
}
print(Util.scale(1, 2, 3, 1, 3))
What is the proper syntax for breaking a long line in Lua?
In your particular case, the convention would be ...
Util = {
scale = function (x1, x2, x3, y1, y3)
return (y1) + ( (y2) - (y1)) * ( (x2) - (x1)) / ( (x3) - (x1))
end
}
Where the break is on statements
Further breaking could be done if the multiplication needs to be split with
Util = {
scale = function (x1, x2, x3, y1, y3)
return (y1) + ( (y2) - (y1)) *
( (x2) - (x1)) / ( (x3) - (x1))
end
}
With the multiplication token used to split the line. By leaving a token at the end of the line, the parser requires more input to complete the expression, so looks onto the next line.
Lua is generally blind to line characters, they are just white-space. However, there are cases where there can be differences, and I would limit line breaks to places where there is an obvious need for extra data.
a = f
(g).x(a)
Is a specific case where it could be treated as a = f(g).x(a) or a = f and (g).x(a)
By breaking after a token which requires continuation, you ensure you are working with the parser.

Converting Multilabel dataset into Single Label?

i am working on single label text categrorization with a dataset of reuter-21578 however the dataset is multi-label by default. Many researchers removed multilabel instances from thi dataset and their number of instances in reuters categories is quite different than mine. How can i remove all the instance that belongs to more than one category in a dataset ? Can i use weka or Rapidminer for this purpose to identify multilabel instances in a dataset ?
Example:
Input Dataset = {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10}
Labels = {acq, earn, grain , corn}
Classification Results =
x1, x2, x3 = acq
x4, x5 = earn
x6, x7, x8 = grain
x9 = grain, corn
x10 = grain, acq
Output Dataset (what i want) =
output dataset = {x1, x2, x3, x4, x5, x6, x7, x8}
output labels = {acq, earn, grain, corn}
Classification Results =
x1, x2, x3 = acq
x4, x5 = earn
x6, x7, x8 = grain
**OR**
{This is what i assume i have achieved with PolynomiaByBinomial Operator }
output dataset = {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10}
output labels = {acq, earn, grain, corn}
Classification Results =
x1, x2, x3 = acq
x4, x5 = earn
x6, x7, x8, x9, x10 = grain
x9 = grain
x10 = grain
Thanks in advance
The simplest way is to break the dataset into binary problems. If for example you have the datasets
text1: science
text2: sports, politics
Break the dataset into 3 datasets:
dataset1 (science): text1:true, text2:false
dataset2 (sports): text2:false, text2:true
dataset3 (science): text1:false, text2:true
Create 3 binary classifiers, one for each class, use the corresponding datasets to train them, and combine the results.

Is the absolute value function differentiable at x=0

Both Wolfram Alpha (diff abs(x)) and Maxima (diff(abs(x),x,1);) say that the absolute value function is differentiable at x=0, and that the derivative is x/abs(x).
How would you go about excluding the point x=0 from the domain when formulating the query?
Thanks!
P.S. This occurs with Maxima (build_info("5.27.0","2012-05-09 21:24:21","x86_64-unknown-linux-gnu","GNU Common Lisp (GCL)","GCL 2.6.7")).
In maxima you can use a wrapper function with wider domain:
f: abs(x);
df(x):= ''(diff(f, x));
dfun(x):= block([eps: 1e-15], if abs(x)>eps then df(x) else 1);
plot2d(dfun(x), [x, -1, 1], [y, -1.1, 1.1], [ylabel, df(x)]);

Create a path in a grid in prolog

I have to create a path between two given points in a grid in Prolog. The code I have so far is:
createPath(GridSize, BeginPosition, EndPosition, VisitedPoints, Path):-
nextStep(BeginPosition, NextStep, GridSize),
(
NextStep \== EndPosition,
->
nonmember(NextStep, VisitedPoints),
add(NextStep, VisitedPoints, NewVisitedPoints),
add(NextStep, Path, NewPath),
createPath(GridSize, NextStep, EndPosition, NewVisitedPoints, NewPath)
;
???
).
A little bit of explanation of my code:
GridSize is just an integer. If it is 2, the grid is a 2x2 grid. So all the grids are square.
The BeginPosition and EndPosition are shown like this: pos(X,Y).
The function nextStep looks for a valid neigbor of a given position. The values of X and Y have to be between 1 and the grid size. I've declared 4 different predicates of nextStep: X + 1, X - 1, Y + 1 and Y - 1.
This is the code:
nextStep(pos(X,Y),pos(X1,Y),GridSize):-
X1 is X + 1,
X1 =< GridSize.
nextStep(pos(X,Y),pos(X1,Y),_):-
X1 is X - 1,
X1 >= 1.
nextStep(pos(X,Y),pos(X,Y1),GridSize):-
Y1 is Y + 1,
Y1 =< GridSize.
nextStep(pos(X,Y),pos(X,Y1),_):-
Y1 is Y - 1,
Y1 >= 1.
nonmember returns true if a given element doesn't occur in a given list.
add adds an element to a given list, and returns the list with that element in it.
Another thing to know about VisitedPoints: Initially the BeginPosition and EndPosition are stored in that list. For example, if I want to find a path in a 2x2 grid, and I have to avoid point pos(2,1), then I will call the function like this:
createPath(2, pos(1,1), pos(2,2), [pos(1,1),pos(2,2),pos(2,1)], X).
The result I should get of it, should be:
X = [pos(1,2)]
Because that is the point needed to connect pos(1,1) and pos(2,2).
My question is, how can I stop the code from running when NextStep == EndPosition. In other words, what do I have to type at the location of the '???' ? Or am I handling this problem the wrong way?
I'm pretty new to Prolog, and making the step from object oriented languages to this is pretty hard.
I hope somebody can answer my question.
Kind regards,
Walle
I think you just placed the 'assignment' to path at the wrong place
createPath(GridSize, BeginPosition, EndPosition, VisitedPoints, Path):-
nextStep(BeginPosition, NextStep, GridSize),
(
NextStep \== EndPosition,
->
nonmember(NextStep, VisitedPoints),
add(NextStep, VisitedPoints, NewVisitedPoints),
% add(NextStep, Path, NewPath),
% createPath(GridSize, NextStep, EndPosition, NewVisitedPoints, NewPath)
createPath(GridSize, NextStep, EndPosition, NewVisitedPoints, Path)
;
% ???
% bind on success the output variable, maybe add EndPosition
Path = VisitedPoints
).
Maybe this is not entirely worth an answer, but a comment would be a bit 'blurry'

Resources