Raphael bar chart - bc.bars.length always returning 1 - raphael

Hi I am using Raphael to generate a bar chart on my web and would like to attach an index to the bars following the replies in this page
https://stackoverflow.com/questions/4057035/raphaeljs-charts-bar-index-fetching?answertab=votes#tab-top.
In order to do this, I will need to fetch the value of bc.bars.length. However, no matter how many bars are in my bar chart, bc.bars.length always returning 1.
Here is my code:
//Create a bar chart using the values in the selected objects
r = Raphael("bar");
txtattr = { font: "12px arial" };
r.text(160, 10, "Title").attr(txtattr);
var bc = r.barchart(10, 10, 300, 220, [myData]).hover(fin, fout);
alert(bc.bars.length); //always returning 1
Anyone knows what is going wrong here? Thanks in advance.

this might be a little late, but for anyone out there, you know, I found myself in the same situation, so let me share my answer and the things I noticed:
(I'm using graphael 0.5.1)
-I noticed that when you use and array for the bars, it returns 1, like what you have:
var bc = r.barchart(10, 10, 300, 220, [myData])
alert(bc.bars.length); //always returning 1
-BUT if you put the values directly, like:
var bc = r.barchart(10, 10, 300, 220, [100,450,340,500])
alert(bc.bars.length); //seems to return 4
-BUT ! that doesn't work if you are getting dinamic data!
so THE SOLUTION I'VE FOUND IS THIS:
//after creating the barchart, let's loop it
var i = 1;
bc.each(function() {
i++;
console.log("bar: "+ i);
});
var total_bars=i-1;
console.log('total_bars: '+total_bars)
I hope this helps other people =), this is a nice library to chart, but it's a shame it's a little buggy with each new version, like the labels and such =(

Related

Chart.js - make barchart element blink

I'm reading docs but there seems to be no parameters to do what i need: I have a plain bar chart and I need to make some bars blink depending on threshold configuration. Is there any plugin or secret parameter to obtain this?
As far as I understand, you want to have a blinking bar.
So what you can do is create the bar and then dynamically update its background-color from 'transparent' to the original color periodically using a timer.
This will create a blinking effect.
Ok, so if you want the first bar to blink:
let count = 0;
setInterval(() => {
if(count % 2 === 0) {
myChart.data.datasets[0].backgroundColor[0] = 'transparent';
myChart.update();
}
else {
myChart.data.datasets[0].backgroundColor[0] = '#FFC857';
myChart.update();
}
count++;
}, 2000);
I don't know if there is a better solution for it, but this is the first thing that came to my mind.

Why does this code not set the background color for a cell (Aspose Cells)?

I need a cell to have a light blue background color; I have code that works in another sheet, but the same exact code (except for the names of the vars and column index val):
Style styleShipVariance = null;
CellsFactory cfShipVariance = new CellsFactory();
Cell ShipVarianceCell = customerWorksheet.Cells[0, SHIPVARIANCE_COL];
ShipVarianceCell.PutValue("Ship Variance");
styleShipVariance = cfShipVariance.CreateStyle();
styleShipVariance.HorizontalAlignment = TextAlignmentType.Left;
styleShipVariance.Font.Name = fontForSheets;
styleShipVariance.Font.IsBold = true;
styleShipVariance.Font.Size = 11;
styleShipVariance.ForegroundColor = Color.LightBlue;
styleShipVariance.Pattern = BackgroundType.Solid;
ShipVarianceCell.SetStyle(styleShipVariance);
...does not work on the other sheet. The value ("Ship Variance") is displayed in that cell, but the color is not being applied.
Why would this not work? What is missing?
Note: I also tried adding this:
var flag = new StyleFlag
{
CellShading = true,
FontName = true,
FontSize = true,
FontColor = true,
FontBold = true,
NumberFormat = true
};
...and changing the last line above to:
ShipVarianceCell.SetStyle(styleShipVariance, flag);
...but it made no difference.
UPDATE
I am saving as xlsx:
var filename = String.Format(#"{0}\{1} - Fill Rate - {2}.xlsx", sharedFolder, _unit, fromAsYYYYMMDD);
if (File.Exists(filename))
{
File.Delete(filename);
}
workBook.Save(filename, SaveFormat.Xlsx);
UPDATE 2
I just noticed that the vals are also not being bolded or left-aligned. The text values themselves are being assigned, but none of the formatting is...
UPDATE 3
Why it was necessary, I don't know, but by adding the colorizing code AFTER the data rows were added to the sheet, it works now.
Well, normally it should work fine. But if you are saving to an XLS file (instead of XLSX file), the light blue background color might not be applied so, you got to add to MS Excel color palette first via the line of code:
e.g
Sample code:
.........
workbook.ChangePalette(Color.LightBlue, 55);
Anyways, we need your template Excel file, so we could evaluate your issue precisely and test to apply the color to the cell on our side and guide you appropriately. I think you may follow up your thread in the Aspose.Cells forums.
I am working as Support developer/ Evangelist at Aspose.

Parse Issue - expected unqualified id

Hey guys this is my code and i am relatively new to C++ and even coding really dont know why i am getting a parse error
though i as per my understanding i have placed the parenthesis properly anyone please suggest if i am missing anything here.
i am getting error at this line
class getProcessor()->RequestUIUpdate()// UI update must be done each time a new editor is constructed
Full Code:
StereoWidthCtrlAudioProcessorEditor::StereoWidthCtrlAudioProcessorEditor (StereoWidthCtrlAudioProcessor* ownerFilter)
: AudioProcessorEditor(ownerFilter)
{
addAndMakeVisible (WidthCtrlSld = new Slider ("Width Factor Slider"));
WidthCtrlSld->setRange (0, 5, 0.1);
WidthCtrlSld->setSliderStyle (Slider::LinearHorizontal);
WidthCtrlSld->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
WidthCtrlSld->addListener (this);
addAndMakeVisible (BypassBtn = new TextButton ("Bypass Button"));
BypassBtn->setButtonText (TRANS("Bypass"));
BypassBtn->addListener (this);
addAndMakeVisible (label = new Label ("new label",
TRANS("Stereo Width Factor:")));
label->setFont (Font (15.00f, Font::plain));
label->setJustificationType (Justification::centredLeft);
label->setEditable (false, false, false);
label->setColour (Label::textColourId, Colour (0xffa34747));
label->setColour (TextEditor::textColourId, Colours::black);
label->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
//[UserPreSize]
//[/UserPreSize]
setSize (600, 400);
//[Constructor] You can add your own custom stuff here..
class getProcessor()->RequestUIUpdate()// UI update must be done each time a new editor is constructed
startTimer(200)//starts timer with interval of 200mS
BypassBtn->setClickingTogglesState(true);
//[/Constructor]
}
StereoWidthCtrlAudioProcessorEditor::~StereoWidthCtrlAudioProcessorEditor()
{
//[Destructor_pre]. You can add your own custom destruction code here..
//[/Destructor_pre]
WidthCtrlSld = nullptr;
BypassBtn = nullptr;
label = nullptr;
//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]enter code here
}
class is a keyword mainly used in declarations. You probably meant:
getProcessor()->RequestUIUpdate();

jQuery Equal Height Columns

http://shoes4school.project-x.me/get-involved.html
Can someone please tell me what i'm doing wrong the the jQuery column faux... I can not get it to work after trying several different methods...
The code i'm using is... my url is above
$j(".content-block").height(Math.max($("#right").height(), $(".content-block").height()));
How to faux columns on webpage
(function($){
// add a new method to JQuery
$.fn.equalHeight = function() {
// find the tallest height in the collection
// that was passed in (.column)
tallest = 0;
this.each(function(){
thisHeight = $(this).height();
if( thisHeight > tallest)
tallest = thisHeight;
});
// set each items height to use the tallest value found
this.each(function(){
$(this).height(tallest);
});
}
})(jQuery);
Firebug show this error :
preloadImages is not defined
preloadImages([

How do I refresh a TMS layer in OpenLayers?

I have a TMS layer that looks something like this:
var v = 1;
my_tms = new OpenLayers.Layer.TMS(
"My TMS",
"my_mapserver.php?v="+my_var+"&",
{ transparent: 'true', type:'png', getURL:get_my_url }
);
Where my_mapserver.php returns map tiles according to the value of v.
The app allows users to change v, and I simply want to refresh the my_tms layer, however, so far the only way I can get it to refresh is by destroying the map and recreating it.
I thought I could just do something like this:
v = 2;
my_tms = new OpenLayers.Layer.TMS(
"My TMS",
"my_mapserver.php?v="+my_var+"&",
{ transparent: 'true', type:'png', getURL:get_my_url }
);
my_tms.redraw();
However, these tiles are not getting requested when I redraw().
Any help is appreciated.
As TMS layers inherits from Grid layer you could try to call clearGrid() method to remove all existing tiles and then spiralTileLoad() to load new ones.
layer.redraw();, OpenLayers.Strategy.Refresh and clearGrid() didn't help me in reloading tiles of OpenLayers.Layer.TMS layer in OpenLayers 2.13.1, but helped:
layer.mergeNewParams({});