Search Results

Search found 34 results on 2 pages for 'addcolumn'.

Page 1/2 | 1 2  | Next Page >

  • Adding Column to a SQL Server Table

    - by Dinesh Asanka
    Adding a column to a table is  common task for  DBAs. You can add a column to a table which is a nullable column or which has default values. But are these two operations are similar internally and which method is optimal? Let us start this with an example. I created a database and a table using following script: USE master Go --Drop Database if exists IF EXISTS (SELECT 1 FROM SYS.databases WHERE name = 'AddColumn') DROP DATABASE AddColumn --Create the database CREATE DATABASE AddColumn GO USE AddColumn GO --Drop the table if exists IF EXISTS ( SELECT 1 FROM sys.tables WHERE Name = 'ExistingTable') DROP TABLE ExistingTable GO --Create the table CREATE TABLE ExistingTable (ID BIGINT IDENTITY(1,1) PRIMARY KEY CLUSTERED, DateTime1 DATETIME DEFAULT GETDATE(), DateTime2 DATETIME DEFAULT GETDATE(), DateTime3 DATETIME DEFAULT GETDATE(), DateTime4 DATETIME DEFAULT GETDATE(), Gendar CHAR(1) DEFAULT 'M', STATUS1 CHAR(1) DEFAULT 'Y' ) GO -- Insert 100,000 records with defaults records INSERT INTO ExistingTable DEFAULT VALUES GO 100000 Before adding a Column Before adding a column let us look at some of the details of the database. DBCC IND (AddColumn,ExistingTable,1) By running the above query, you will see 637 pages for the created table. Adding a Column You can add a column to the table with following statement. ALTER TABLE ExistingTable Add NewColumn INT NULL Above will add a column with a null value for the existing records. Alternatively you could add a column with default values. ALTER TABLE ExistingTable Add NewColumn INT NOT NULL DEFAULT 1 The above statement will add a column with a 1 value to the existing records. In the below table I measured the performance difference between above two statements. Parameter Nullable Column Default Value CPU 31 702 Duration 129 ms 6653 ms Reads 38 116,397 Writes 6 1329 Row Count 0 100000 If you look at the RowCount parameter, you can clearly see the difference. Though column is added in the first case, none of the rows are affected while in the second case all the rows are updated. That is the reason, why it has taken more duration and CPU to add column with Default value. We can verify this by several methods. Number of Pages The number of data pages can be obtained by using DBCC IND command. Though, this an undocumented dbcc command, many experts are ok to use this command in production. However, since there is no official word from Microsoft, use this “at your own risk”. DBCC IND (AddColumn,ExistingTable,1) Before Adding the Columns 637 Adding a Column with NULL 637 Adding a column with DEFAULT value 1270 This clearly shows that pages are physically modified. Please note, a high value indicated in the Adding a column with DEFAULT value  column is also a result of page splits. Continues…

    Read the article

  • A bug in grpah while using google visualization API on IE

    - by gili
    Hi, i'm using google visulization API to build a line chart grapgh. it works fine on FF and Chrome but i'm having problems on IE7: the problem is that the scailing of the x-axis (string) and y-axis (integer) is all wrong. both axis have the same values for some reason, but naturally those valuse are wrong. my code is the following one: var data = new google.visualization.DataTable(); data.addColumn('string', 'Date'); data.addColumn('number', '??????? ???? ??????'); data.addColumn('number', '??????? ??????'); data.addColumn('number', '??????'); data.addColumn('number', '???????'); data.addColumn('number', '???????'); var n = userRightGuessArray.length; data.addRows(userRightGuessArray.length); data.setCell(0, 0, '?? ?????? ??'); data.setCell(0, 1, 0); data.setCell(0, 2, 0); data.setCell(0, 3, 0); data.setCell(0, 4, 0); data.setCell(0, 5, 0); for(var t = 1 ; t // Create and draw the visualization. var chart = new google.visualization.ImageLineChart(document.getElementById('line_div')); chart.draw(data, {width: 400,legend: 'top'/showValueLabels:false/}); thank you for your help, Gili

    Read the article

  • Django templates crashes with no sense

    - by user233323
    Hello I'm trying to use google visualization API along with django templates system. I got an error that don't know how to fix. The error is the following: invalid_block_tag raise self.error(token, "Invalid block tag: '%s'" % command) django.template.TemplateSyntaxError: Invalid block tag: 'endfor' The code is: function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('date', 'time'); data.addColumn('number', 'x'); data.addColumn('number', 'y'); data.addColumn('number', 'z'); data.addRows([ {% for d in datos &} [new Date({{d.instante|date:"Y, m, d, H, i, s"}}), {{d.x}}, {{d.y}}, {{d.z}}] {% if not forloop.last %},{% endif %} ]); {% endfor %} var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div')); chart.draw(data, {displayAnnotations: true}); } Thanks you all!

    Read the article

  • Google Chart Number formatting

    - by MizAkita
    I need to format my pie and column charts to show the $ and comma in currency format ($###,###) when you hover over the charts. Right now, it is displaying the number and percentage but the number as #####.## here is my code. Any help would be appreciated. // Load the Visualization API and the piechart package. google.load('visualization', '1.0', {'packages':['corechart']}); // Set a callback to run when the Google Visualization API is loaded. google.setOnLoadCallback(drawChart); var formatter = new google.visualization.NumberFormat({ prefix: '$' }); formatter.format(data, 1); var options = { pieSliceText: 'value' }; // Callback that creates and populates a data table, // instantiates the pie chart, passes in the data and // draws it. function drawChart() { // REVENUE CHART - Create the data table. var data4 = new google.visualization.DataTable(); data4.addColumn('string', 'Status'); data4.addColumn('number', 'In Thousands'); data4.addRows([ ['Net tution & Fees', 213.818], ['Auxiliaries', 30.577], ['Government grants/contracts', 39.436], ['Private grants/gifts', 39.436], ['Investments', 10.083], ['Clinics', 14.353], ['Other', 5.337] ]); // EXPENSES CHART - Create the data table. var data5 = new google.visualization.DataTable(); data5.addColumn('string', 'Status'); data5.addColumn('number', 'Amount'); data5.addRows([ ['Instruction', 133.868], ['Sponsored Progams', 34.940], ['Auxiliaries', 30.064], ['Academic Support', 25.529], ['Depreciation & amortization', 18.548], ['Student Services', 22.626], ['Plant operations & maintenance', 18.105], ['Fundraising', 13.258], ['Geneal Administration', 11.628], ['Interest', 6.846], ['Student Aid', 1.886], ]); // ENDOWMENT CHART - Create the data table. var data6 = new google.visualization.DataTable(); data6.addColumn('string', 'Status'); data6.addColumn('number', 'In Millions'); data6.addRows([ ['2010', 178.7], ['2011', 211.693], ['2012', 199.3] ]); // Set REVENUE chart options var options4 = { is3D: true, fontName: 'Arial', colors:['#AFD8F8', '#F6BD0F', '#8BBA00', '#FF8E46', '#008E8E', '#CCCCCC', '#D64646', '#8E468E'], 'title':'', 'width':550, 'height':250}; // Set EXPENSES chart options var options5 = { is3D: true, fontName: 'Arial', colors:['#AFD8F8', '#F6BD0F', '#8BBA00', '#FF8E46', '#008E8E', '#CCCCCC', '#D64646', '#8E468E'], 'title':'', 'width':550, 'height':250}; // Set ENDOWMENT chart options var options6 = { is3D: true, fontName: 'Arial', colors:['#AFD8F8', '#F6BD0F', '#8BBA00', '#FF8E46', '#008E8E', '#CCCCCC', '#D64646', '#8E468E'], 'title':'', 'width':450, 'height':250}; // Instantiate and draw our chart, passing in some options. var chart4 = new google.visualization.PieChart(document.getElementById('chart_div4')); chart4.draw(data4, options4); var chart5 = new google.visualization.PieChart(document.getElementById('chart_div5')); chart5.draw(data5, options5); var chart6 = new google.visualization.ColumnChart(document.getElementById('chart_div6')); chart6.draw(data6, options6);}

    Read the article

  • load google annotated chart within jquery ui tab content via ajax method

    - by twmulloy
    Hi, I am encountering an issue with trying to load a google annotated chart (http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html) within a jquery ui tab using content via ajax method (http://jqueryui.com/demos/tabs/#ajax). If instead I use the default tabs functionality, writing out the code things work fine: <div id="tabs"> <ul> <li><a href="#tabs-1">Chart</a></li> </ul> <div id="tabs-1"> <script type="text/javascript"> google.load('visualization', '1', {'packages':['annotatedtimeline']}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); data.addColumn('number', 'cloudofinc.com'); data.addColumn('string', 'header'); data.addColumn('string', 'text') data.addColumn('number', 'All Clients'); data.addRows([ [new Date('May 12, 2010'), 2, '2 New Users', '', 3], [new Date('May 13, 2010'), 0, undefined, undefined, 0], [new Date('May 14, 2010'), 0, undefined, undefined, 0], ]); var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_users')); chart.draw(data, { displayAnnotations: false, fill: 10, thickness: 1 }); } </script> <div id='chart_users' style='width: 100%; height: 400px;'></div> </div> </div> But if I use the ajax method for jquery ui tab and point to the partial for the tab, it doesn't work completely. The page renders and once the chart loads, the browser window goes white. However, you can see the tab partial flash just before the chart appears to finish rendering (the chart never actually displays). I have verified that the partial is indeed loading properly without the chart. <div id="tabs"> <ul> <li><a href="ajax/tabs-1">Chart</a></li> </ul> </div>

    Read the article

  • jquery google visual api graph's data rows does not work.

    - by marharépa
    Hi! I'd like to use google drawVisualization API. Example: var data = new google.visualization.DataTable(); data.addColumn('string'); data.addColumn('number'); data.addRows([ ['a', 14], ['b', 47], ['c', 80], ['d', 55], ['e', 16], ['f', 90], ['g', 29], ['h', 23], ['i', 58], ['j', 48] ]); My version gets elements by an other google api, and join them, and after place the variable between ([ and ]), to be like in the example. var outputGraph = []; for (var i = 0, entry; entry = entries[i]; ++i) { var asd = [ entry.getValueOf('ga:pageTitle'), entry.getValueOf('ga:pageviews') ].join("',"); outputGraph.push(" ['" + asd + "]"); //get the 2 elements and join them to be like ['asd', 2], } // this is fine, the outputgraph is like ['asd', 2], ['asd', 2], ['asd', 2] as seen in the example var outputGraphFine = ("(["+outputGraph+"])"); // i suggest this is which fails the script. var data = new google.visualization.DataTable(); data.addColumn('string', 'Task'); data.addColumn('number', 'Hours per Day'); data.addRows = outputGraphFine; But it doesn't work. Why?

    Read the article

  • Google visualization API Junk characters in the generated graph

    - by vimson
    I am using google visulization API for one of my project in Arabic. My problem is in the generated graph Arabic characters seems to be Junk characters. data.addColumn('number', '?????'); data.addColumn('number', '?????'); I am using Visualization API for generating Line and Bar charts. Can anyone please suggest a solution for this?

    Read the article

  • DynamicJasper font encoding problem

    - by user266956
    Hello All, I'm new to DynamicJasper, I think it's a great project but for a few days I cannot run simple example which will display polish fonts properly. Details sections is generated without any problems automatically displaying polish letters like 'c z z a' etc. where title and column headers contain strange letters instead. I was trying to do the following, but it doesn't work: FastReportBuilder drb = new FastReportBuilder(); Font font = new Font(25, "SansSerif", "Helvetica", Font.PDF_ENCODING_CP1257_Baltic, true); Style titleStyle = new StyleBuilder(false).setFont(font).build(); DynamicReport dr = drb.addColumn("State", "state", String.class.getName(),30) .addColumn("Branch", "branch", String.class.getName(),30) .addColumn("Product Line", "productLine", String.class.getName(),50) .addGroups(2) .setTitle("November 2008 Zrebie aczc!") .setTitleStyle(titleStyle) .setSubtitle("This report was generated at " + new Date()) .setPrintBackgroundOnOddRows(true) .setUseFullPageWidth(true) .build(); JRDataSource ds = new JRBeanCollectionDataSource(this.simples); JasperPrint jp = DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), ds); JasperViewer.viewReport(jp); //finally display the report report Any help would be highly appreciated as dynamicjasper forums seems to be dead and constantly spammed. Thanks in advance! Kris

    Read the article

  • How can i use Google-o-Meter or Google Vizualisation API with Jenkins

    - by kamal
    Here is a sample that displays a static chart: google.load("visualization", "1.0", {packages:["imagechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var dataTable = new google.visualization.DataTable(); dataTable.addColumn('string'); dataTable.addColumn('number'); dataTable.addColumn('string'); // Row data is [chl, data point, point label] dataTable.addRows([ ['January',40,undefined], ['February',60,'Initial recall'], ['March',60,'Product withdrawn'], ['April',45,undefined], ['May',47,'Relaunch'], ['June',75,undefined], ['July',70,undefined], ['August',72,undefined] ]); var options = {cht: 'lc', chds:'0,160', annotationColumns:[{column:2, size:12, type:'flag', priority:'high'},]}; var chart = new google.visualization.ImageChart(document.getElementById('line_div')); chart.draw(dataTable, options); } How can i replace the static values and variables in dataTable.addRows([ with real live data ? In case the compete code is not visible, refer to : http://code.google.com/apis/visualization/documentation/gallery/genericimagechart.html When this Javascript is copied to the "Description" it renders a chart, what i want to know is how to replace the name/value in dataTable.addRows, to the name/values coming from Jenkins

    Read the article

  • Google Charts - Adding Tooltip to Colorized Column Chart

    - by David K
    I created a column chart with google charts that has a different color assigned to each column using the following posting: Assign different color to each bar in a google chart But now I'm trying to figure out how to customize the tooltips for each column to also include the number of users in addition to the percent, so "raw_data[i][1]" I would like it to look like "70% (80 Users)" I understand that there is "data.addColumn({type:'number',role:'tooltip'});" but I'm having trouble understanding how to implement it for this use-case. function drawAccountsChart() { var data = new google.visualization.DataTable(); var raw_data = [ ['Parents', 80, 160], ['Students', 94, 128], ['Teachers', 78, 90], ['Admins', 68, 120], ['Staff', 97, 111] ]; data.addColumn('string', 'Columns'); for (var i = 0; i < raw_data.length; ++i) { data.addColumn('number', raw_data[i][0]); } data.addRows(1); for (var i = 0; i < raw_data.length; ++i) { data.setValue(0, i+1, raw_data[i][1]/raw_data[i][2]*100); } var options = { height:220, chartArea: { left:30, width: "70%", height: "70%" }, backgroundColor: { fill:"transparent" }, tooltop:{ textStyle: {fontSize: "12px",}}, vAxis: {minValue: 0} }; var formatter = new google.visualization.NumberFormat({ suffix: '%', fractionDigits: 1 }); formatter.format(data, 1); formatter.format(data, 2); formatter.format(data, 3); formatter.format(data, 4); formatter.format(data, 5); var chart = new google.visualization.ColumnChart(document.getElementById('emailAccountsChart')); chart.draw(data, options); }

    Read the article

  • Event Listener in Google Charts API

    - by DeanGrobler
    I'm busy using Google Charts in one of my projects to display data in a table. Everything is working great. Except that I need to see what line a user selected once they click a button. This would obviously be done with Javascript, but I've been struggling for days now to no avail. Below I've pasted code for a simple example of the table, and the Javascript function that I want to use (that doesn't work). <html> <head> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {packages:['table']}); google.setOnLoadCallback(drawTable); var table = ""; function drawTable() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Name'); data.addColumn('number', 'Salary'); data.addColumn('boolean', 'Full Time Employee'); data.addRows(4); data.setCell(0, 0, 'Mike'); data.setCell(0, 1, 10000, '$10,000'); data.setCell(0, 2, true); data.setCell(1, 0, 'Jim'); data.setCell(1, 1, 8000, '$8,000'); data.setCell(1, 2, false); data.setCell(2, 0, 'Alice'); data.setCell(2, 1, 12500, '$12,500'); data.setCell(2, 2, true); data.setCell(3, 0, 'Bob'); data.setCell(3, 1, 7000, '$7,000'); data.setCell(3, 2, true); table = new google.visualization.Table(document.getElementById('table_div')); table.draw(data, {showRowNumber: true}); } function selectionHandler() { selectedData = table.getSelection(); row = selectedData[0].row; item = table.getValue(row,0); alert("You selected :" + item); } </script> </head> <body> <div id='table_div'></div> <input type="button" value="Select" onClick="selectionHandler()"> </body> </html> Thanks in advance for anyone taking the time to look at this. I've honestly tried my best with this, hope someone out there can help me out a bit.

    Read the article

  • How to create a chart from mysql data?

    - by user187580
    Hello, I have some data and want to create some dynamic charts. I have looked on Google visualisation api .. It looks great but the problem is I am not very familiar with it. Any ideas, how I can set the data.setValue from mysql data. <script type='text/javascript'> google.load('visualization', '1', {'packages': ['geomap']}); google.setOnLoadCallback(drawMap); function drawMap() { var data = new google.visualization.DataTable(); data.addRows(6); data.addColumn('string', 'Country'); data.addColumn('number', 'Popularity'); data.setValue(0, 0, 'Germany'); data.setValue(0, 1, 200); data.setValue(1, 0, 'United States'); data.setValue(1, 1, 300); data.setValue(2, 0, 'Brazil'); data.setValue(2, 1, 400); data.setValue(3, 0, 'Canada'); data.setValue(3, 1, 500); data.setValue(4, 0, 'France'); data.setValue(4, 1, 600); data.setValue(5, 0, 'RU'); data.setValue(5, 1, 700); var options = {}; options['dataMode'] = 'regions'; var container = document.getElementById('map_canvas'); var geomap = new google.visualization.GeoMap(container); geomap.draw(data, options); }; </script> I can create chart using some other methods but just interested in using Google Visualisation API. Thanks.

    Read the article

  • How to use QCOMPARE Macro to compare events

    - by vels
    Hi, I have MyWindow class which popus a blank window, which accepts a mouse click, I need to unit test the mouse click event Code snippet: void TestGui::testGUI_data() { QTest::addColumn<QTestEventList>("events"); QTest::addColumn<QTestEventList>("expected"); Mywindow mywindow; QSize editWidgetSize = mywindow.size(); QPoint clickPoint(editWidgetSize.rwidth()-2, editWidgetSize.rheight()-2); QTestEventList events, expected ; events.addMouseClick( Qt::LeftButton, 0, clickPoint); expected.addMouseClick( Qt::LeftButton, 0, clickPoint); QTest::newRow("mouseclick") << events << expected ; } void TestGui::testGUI() { QFETCH(QTestEventList, events); QFETCH(QTestEventList, expected); Mywindow mywindow; mywindow.show(); events.simulate(&mywindow); QCOMPARE(events, expected); } // prints FAIL! : TestGui::testGUI(mouseclick) Compared values are not the same How to test the mouse click on mywindow. is there any beeter approach to unit test mouse events? Thanks, vels

    Read the article

  • Google Bar Chart Time Label Interval

    - by Alex Angelini
    Hi I am using Google Bar Chart through the visualization API on my site: http://code.google.com/apis/visualization/documentation/gallery/imagebarchart.html And my x-axis is time, and every time interval is a time of day in the format (HH:MM) Here is my code for the graph: <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> %s google.load("visualization", "1", {packages:["imagebarchart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Date'); data.addColumn('number', 'Amount'); data.addRows({{Rows}}); %s var chart = new google.visualization.ImageBarChart(document.getElementById('chart_div')); chart.draw(data, {width: 900, height: 340, min: 0, isVertical:true, legend:'none'}); } </script> The rows of data are added later using a templating engine, but that is the jist of my chart. Because I have added my time variable as 'string' I cannot use the valueLabelsInterval option to only show every 4 labels. Because I can't do that the labels overlap and look ugly. Is there any other way to only show every other time label or every 4th one, I read through the docs but could not see how to do it. Any help would be greatly appreciated thanks

    Read the article

  • jQuery load Google Visualization API with AJAX

    - by Curro
    Hello. There is an issue that I cannot solve, I've been looking a lot in the internet but found nothing. I have this JavaScript that is used to do an Ajax request by PHP. When the request is done, it calls a function that uses the Google Visualization API to draw an annotatedtimeline to present the data. The script works great without AJAX, if I do everything inline it works great, but when I try to do it with AJAX it doesn't work!!! The error that I get is in the declaration of the "data" DataTable, in the Google Chrome Developer Tools I get a Uncaught TypeError: Cannot read property 'DataTable' of undefined. When the script gets to the error, everything on the page is cleared, it just shows a blank page. So I don't know how to make it work. Please help Thanks in advance $(document).ready(function(){ // Get TIER1Tickets $("#divTendency").addClass("loading"); $.ajax({ type: "POST", url: "getTIER1Tickets.php", data: "", success: function(html){ // Succesful, load visualization API and send data google.load('visualization', '1', {'packages': ['annotatedtimeline']}); google.setOnLoadCallback(drawData(html)); } }); }); function drawData(response){ $("#divTendency").removeClass("loading"); // Data comes from PHP like: <CSV ticket count for each day>*<CSV dates for ticket counts>*<total number of days counted> // So it has to be split first by * then by , var dataArray = response.split("*"); var dataTickets = dataArray[0]; var dataDates = dataArray[1]; var dataCount = dataArray[2]; // The comma separation now splits the ticket counts and the dates var dataTicketArray = dataTickets.split(","); var dataDatesArray = dataDates.split(","); // Visualization data var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); data.addColumn('number', 'Tickets'); data.addRows(dataCount); var dateSplit = new Array(); for(var i = 0 ; i < dataCount ; i++){ // Separating the data because must be entered as "new Date(YYYY,M,D)" dateSplit = dataDatesArray[i].split("-"); data.setValue(i, 0, new Date(dateSplit[2],dateSplit[1],dateSplit[0])); data.setValue(i, 1, parseInt(dataTicketArray[i])); } var annotatedtimeline = new google.visualization.AnnotatedTimeLine(document.getElementById('divTendency')); annotatedtimeline.draw(data, {displayAnnotations: true}); }

    Read the article

  • Escape key event problem in wxPython?

    - by MA1
    Hi All The following key event is not working. Any idea? class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, title='testing', size=(300,380), style= wx.MINIMIZE_BOX|wx.SYSTEM_MENU |wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN) self.tree = HyperTreeList(self, style = wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HAS_VARIABLE_ROW_HEIGHT | wx.TR_HIDE_ROOT) # create column self.tree.AddColumn("coll") self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) def OnKeyDown(self, event): keycode = event.GetKeyCode() print "keycode ", keycode if keycode == wx.WXK_ESCAPE: print "closing" self.Close() Regards,

    Read the article

  • QListView how to add column ?

    - by Samir
    How can I add columns to QListView control. Found a method addColumn while seardhing, but in my Qt Creator 1.2.1 based on Qt 4.5.2(32 bit) QListView doesn't have such method at all !!! So how would I add columns ? Say I have 3 columns then what is the code to add a row ?

    Read the article

  • Change axes of google chart without refresh?

    - by Mike Kriess
    If I was using the following: https://developers.google.com/chart/interactive/docs/gallery/annotatedtimeline Assuming I did not have the line: data.addColumn('number', 'Sold Pencils'); or anything referring to 'Sold Pencils'; How do I make it such that when the user clicks an external link 'Sold Pencils' I am able to retrieve the data and add it to the graph (without the user refreshing the page). Is there some way to redraw the graph/add the column in this way?

    Read the article

  • Adding Columns to JTable dynamically

    - by martilyo
    I have an empty JTable, absolutely nothing in it. I need to dynamically generate its table columns in a certain way. A simplified version for the code I have for my attempt: @Action public void AddCol() { for (int i = 0; i < 10; i++) { TableColumn c = new TableColumn(i); c.setHeaderValue(getColNam(i)); table.getColumnModel().addColumn(c); } } But I'm getting an Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 error. What am I doing wrong?

    Read the article

  • Asp.net Google Charts SSL handler for GeoMap

    - by Ian
    Hi All, I am trying to view Google charts in a site using SSL. Google Charts do not support SSL so if we use the standard charts, we get warning messages. My plan is to create a ASHX handler that is co9ntained in the secure site that will retrieve the content from Google and serve this to the page the user is viewing. Using VS 2008 SP1 and the included web server, my idea works perfectly for both Firefox and IE 8 & 9(Preview) and I am able to see my geomap displayed on my page as it should be. But my problem is when I publish to IIS7 the page using my handler to generate the geomap works in Firefox but not IE(every version). There are no errors anywhere or in any log files, but when i right click in IE in the area where the map should be displayed, I see the message in the context menu saying "movie not loaded" Below is the code from my handler and the aspx page. I have disabled compression in my web.config. Even in IE I am hitting all my break points and when I use the IE9 Developer tools, the web page is correctly generated with all the correct code, url's and references. If you have any better ways to accomplish this or how i can fix my problem, I will appreciate it. Thanks Ian Handler(ASHX) public void ProcessRequest(HttpContext context) { String url = "http://charts.apis.google.com/jsapi"; string query = context.Request.QueryString.ToString(); if (!string.IsNullOrEmpty(query)) { url = query; } HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(HttpUtility.UrlDecode(url))); request.UserAgent = context.Request.UserAgent; WebResponse response = request.GetResponse(); string PageContent = string.Empty; StreamReader Reader; Stream webStream = response.GetResponseStream(); string contentType = response.ContentType; context.Response.BufferOutput = true; context.Response.ContentType = contentType; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.Cache.SetNoServerCaching(); context.Response.Cache.SetMaxAge(System.TimeSpan.Zero); string newUrl = IanLearning.Properties.Settings.Default.HandlerURL; //"https://localhost:444/googlesecurecharts.ashx?"; if (response.ContentType.Contains("javascript")) { Reader = new StreamReader(webStream); PageContent = Reader.ReadToEnd(); PageContent = PageContent.Replace("http://", newUrl + "http://"); PageContent = PageContent.Replace("charts.apis.google.com", newUrl + "charts.apis.google.com"); PageContent = PageContent.Replace(newUrl + "http://maps.google.com/maps/api/", "http://maps.google.com/maps/api/"); context.Response.Write(PageContent); } else { { byte[] bytes = ReadFully(webStream); context.Response.BinaryWrite(bytes); } } context.Response.Flush(); response.Close(); webStream.Close(); context.Response.End(); context.ApplicationInstance.CompleteRequest(); } ASPX Page <%@ Page Title="" Language="C#" MasterPageFile="~/Site2.Master" AutoEventWireup="true" CodeBehind="googlechart.aspx.cs" Inherits="IanLearning.googlechart" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> <script type='text/javascript' src='~/googlesecurecharts.ashx?'></script> <script type='text/javascript'> google.load('visualization', '1', { 'packages': ['geomap'] }); google.setOnLoadCallback(drawMap); var geomap; function drawMap() { var data = new google.visualization.DataTable(); data.addRows(6); data.addColumn('string', 'City'); data.addColumn('number', 'Sales'); data.setValue(0, 0, 'ZA'); data.setValue(0, 1, 200); data.setValue(1, 0, 'US'); data.setValue(1, 1, 300); data.setValue(2, 0, 'BR'); data.setValue(2, 1, 400); data.setValue(3, 0, 'CN'); data.setValue(3, 1, 500); data.setValue(4, 0, 'IN'); data.setValue(4, 1, 600); data.setValue(5, 0, 'ZW'); data.setValue(5, 1, 700); var options = {}; options['region'] = 'world'; options['dataMode'] = 'regions'; options['showZoomOut'] = false; var container = document.getElementById('map_canvas'); geomap = new google.visualization.GeoMap(container); google.visualization.events.addListener( geomap, 'regionClick', function(e) { drillDown(e['region']); }); geomap.draw(data, options); }; function drillDown(regionData) { alert(regionData); } </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <div id='map_canvas'> </div> </asp:Content>

    Read the article

  • Google Vizualization with CSV data

    - by Shlomo Shmai
    Hi, I have a URL that returns data in CSV format. I would like to use Google Vizualization to create an interactive chart of the data. I've looked at several examples on Google Chart and Vizualization web page but I'm a bit confused as I'm not familiar with JavaScript or web programming in general. Question: Do I have to use JavaScript to parse the CSV string myself and manually construct the DataTable with addColumn() and addRows()? Or, is there a way to simply pass the CSV url to the charting function? I'm hoping to do something like this: var csv_data = get_data_from_url('http://...') var data = new google.visualization.DataTable(csv_data); var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, ...); Can someone please help me out? Thanks.

    Read the article

  • Retrieving a single Guid in CRM 4.0

    - by user1746560
    I'm new to CRM (version 4.0) and i'm trying to return a 'yearid' guide based on a given year (which is also stored in the entity).So far i've got: public static Guid GetYearID(string yearName) { ICrmService service = CrmServiceFactory.GetCrmService(); // Create the query object. QueryExpression query = new QueryExpression("year"); ColumnSet columns = new ColumnSet(); columns.AddColumn("yearid"); query.ColumnSet = columns; FilterExpression filter = new FilterExpression(); filter.FilterOperator = LogicalOperator.And; filter.AddCondition(new ConditionExpression { AttributeName = "yearName", Operator = ConditionOperator.Equal, Values = new object[] { yearName} }); query.Criteria = filter; } But my questions are: A) What code do in addition to this to actually store the Guid? B) Is using a QueryExpression the most efficient way to do this?

    Read the article

  • Referencing ASP.net textbox data in JavaScripts

    - by GoldenEarring
    I'm interested in making an interactive 3D pie chart using JavaScript and ASP.net controls for a webpage. Essentially, I want to make an interactive version of the chart here: https://google-developers.appspot.com/chart/interactive/docs/gallery/piechart#3D I want to have 5 ASP.net textboxes where the user enters data and then submits it, and the chart adjusts according to what the user enters. I understand using ASP.net controls with JS is probably not the most effective way to go about it, but I would really appreciate if someone could share how doing this would be possible. I really don't know where to begin. Thanks for any help! <%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server"> void btn1_Click(object sender, EventArgs e) { double s = 0.0; double b = 0; double g = 0.0f; double c = 0.0f; double h = 0.0f; s = double.Parse(txtWork.Text); b = double.Parse(txtEat.Text); g = double.Parse(txtCommute.Text); c = double.Parse(txtWatchTV.Text); h = double.Parse(txtSleep.Text); double total = s + b + g + c + h; if (total != 24) { lblError.Text = "Warning! A day has 24 hours"; } if (total == 24) { lblError.Text = string.Empty; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", { packages: ["corechart"] }); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ]); var options = { title: 'My Daily Activities', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); chart.draw(data, options); } var data = new google.visualization.DataTable(); var txtWork = document.getElementById('<%=txtWork.ClientID%>') txtEat = document.getElementById('<%=txtEat.ClientID%>') txtCommute = document.getElementById('<%=txtCommute.ClientID%>') txtWatchTV = document.getElementById('<%=txtWatchTV.ClientID%>') txtSleep = document.getElementById('<%=txtSleep.ClientID%>'); var workvalue = parseInt(txtWork, 10) var eatvalue = parseInt(txtEat, 10) var commutevalue = parseInt(txtCommute, 10) var watchtvvalue = parseInt(txtWatchTV, 10) var sleepvalue = parseInt(txtSleep, 10) // Declare columns data.addColumn('string', 'Task'); data.addColumn('Number', 'Hours per day'); // Add data. data.addRows([ ['Work', workvalue], ['Eat', eatvalue], ['Commute', commutevalue], ['Watch TV', watchtvvalue], ['Sleep', sleepvalue], ]); </script> </head> <body> <form id="form1" runat="server"> <div id="piechart_3d" style="width: 900px; height: 500px;"> </div> <asp:Label ID="lblError" runat="server" Font-Size="X-Large" Font-Bold="true" /> <table> <tr> <td>Work:</td> <td><asp:TextBox ID="txtWork" Text="11" runat="server" /></td> </tr> <tr> <td>Eat:</td> <td><asp:TextBox ID="txtEat" text="2" runat="server" /></td> </tr> <tr> <td>Commute:</td> <td><asp:TextBox ID="txtCommute" Text="2" runat="server" /></td> </tr> <tr> <td>Watch TV:</td> <td><asp:TextBox ID="txtWatchTV" Text="2" runat="server" /></td> </tr> <tr> <td>Sleep:</td> <td><asp:TextBox ID="txtSleep" Text="7" runat="server" /></td> </tr> </table> <br /> <br /> <asp:Button ID="btn1" text="Draw 3D PieChart" runat="server" OnClick="btn1_Click" /> </form> </body> </html>

    Read the article

  • how to sort JTable by providing column index externally.

    - by user345940
    I would like to implement sorting on JTable by providing column index externally in program. Here is my sample code in which i have initialize JTable, Add one Column and 30 rows to JTable. After rows has been added i am sorting JTable by providing column index 0 but i could not get sorted data. how can i get my first column in sorted order? what's wrong with my code. **Why sortCTableonColumnIndex() method could not sort data for specify column index? ` public class Test { private JTable oCTable; private DefaultTableModel oDefaultTableModel; private JScrollPane oPane; private JTableHeader oTableHeader; private TableRowSorter sorter; public void adddata() { for (int i = 0; i < 30; i++) { Object[] row = new Object[1]; String sValueA = "A"; String sValueB = "A"; row[0] = ""; if (i % 2 == 0) { if (i < 15) { sValueA = sValueA + sValueA; row[1] = sValueA; } else { if (i == 16) { sValueB = "D"; row[1] = sValueA; } else { sValueB = sValueB + sValueB; row[1] = sValueA; } } } else { if (i < 15) { sValueB = sValueB + sValueB; row[1] = sValueB; } else { if (i == 17) { sValueB = "C"; row[1] = sValueB; } else { sValueB = sValueB + sValueB; row[1] = sValueB; } } } } } public void createTable() { oCTable = new JTable(); oDefaultTableModel = new DefaultTableModel(); oCTable.setModel(oDefaultTableModel); oTableHeader = oCTable.getTableHeader(); oCTable.setAutoResizeMode(oCTable.AUTO_RESIZE_OFF); oCTable.setFillsViewportHeight(true); JTable oTable = new LineNumberTable(oCTable); oPane = new JScrollPane(oCTable); oPane.setRowHeaderView(oTable); JPanel oJPanel = new JPanel(); oJPanel.setLayout(new BorderLayout()); oJPanel.add(oPane, BorderLayout.CENTER); JDialog oDialog = new JDialog(); oDialog.add(oJPanel); oDialog.setPreferredSize(new Dimension(500, 300)); oDialog.pack(); oDialog.setVisible(true); } public void insert() { oDefaultTableModel.addColumn("Name"); int iColumnPlace = ((DefaultTableModel) oCTable.getModel()).findColumn("Name"); CellRendererForRowHeader oCellRendererForRowHeader = new CellRendererForRowHeader(); TableColumn Column = oCTable.getColumn(oTableHeader.getColumnModel().getColumn(iColumnPlace).getHeaderValue()); Column.setPreferredWidth(300); Column.setMaxWidth(300); Column.setMinWidth(250); Column.setCellRenderer(oCellRendererForRowHeader); for (int i = 0; i < 30; i++) { Object[] row = new Object[1]; String sValueA = "A"; if (i % 2 == 0) { if (i < 15) { sValueA = sValueA + "a"; oDefaultTableModel.insertRow(oCTable.getRowCount(), new Object[]{""}); oDefaultTableModel.setValueAt(sValueA, i, 0); } else { if (i == 16) { sValueA = sValueA + "b"; oDefaultTableModel.insertRow(oCTable.getRowCount(), new Object[]{""}); oDefaultTableModel.setValueAt(sValueA, i, 0); } else { sValueA = sValueA + "c"; oDefaultTableModel.insertRow(oCTable.getRowCount(), new Object[]{""}); oDefaultTableModel.setValueAt(sValueA, i, 0); } } } else { if (i < 15) { sValueA = sValueA + "d"; oDefaultTableModel.insertRow(oCTable.getRowCount(), new Object[]{""}); oDefaultTableModel.setValueAt(sValueA, i, 0); } else { if (i == 17) { sValueA = sValueA + "e"; oDefaultTableModel.insertRow(oCTable.getRowCount(), new Object[]{""}); oDefaultTableModel.setValueAt(sValueA, i, 0); } else { sValueA = sValueA + "f"; oDefaultTableModel.insertRow(oCTable.getRowCount(), new Object[]{""}); oDefaultTableModel.setValueAt(sValueA, i, 0); } } } } } public void showTable() { createTable(); insert(); sortCTableonColumnIndex(0, true); } public void sortCTableonColumnIndex(int iColumnIndex, boolean bIsAsc) { sorter = new TableRowSorter(oDefaultTableModel); List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(); if (bIsAsc) { sortKeys.add(new RowSorter.SortKey(iColumnIndex, SortOrder.ASCENDING)); } else { sortKeys.add(new RowSorter.SortKey(iColumnIndex, SortOrder.DESCENDING)); } sorter.setSortKeys(sortKeys); oDefaultTableModel.fireTableStructureChanged(); oCTable.updateUI(); } public static void main(String[] argu) { Test oTest = new Test(); oTest.showTable(); } class CellRendererForRowHeader extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = null; try { label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (column == 0) { label.setBackground(new JLabel().getBackground()); label.setForeground(Color.BLACK); } } catch (RuntimeException ex) { } return label; } } class LineNumberTable extends JTable { private JTable mainTable; public LineNumberTable(JTable table) { super(); mainTable = table; setAutoCreateColumnsFromModel(false); setModel(mainTable.getModel()); setAutoscrolls(false); addColumn(new TableColumn()); getColumnModel().getColumn(0).setCellRenderer(mainTable.getTableHeader().getDefaultRenderer()); getColumnModel().getColumn(0).setPreferredWidth(40); setPreferredScrollableViewportSize(getPreferredSize()); } @Override public boolean isCellEditable(int row, int column) { return false; } @Override public Object getValueAt(int row, int column) { return Integer.valueOf(row + 1); } @Override public int getRowHeight(int row) { return mainTable.getRowHeight(); } } } `

    Read the article

  • how to restrict a jsp hit counter?

    - by user261002
    I am writing a hot counter in jsp, for my coursework. I have write the code, and there is not error and its working, but the problem is that: if the user have open the website and try to user different page, when ever that the user get back to the home page the counter still is adding a number , how can I restrict this part??? shall restrict it with session?? this is my code : The current count for the counter bean is: <% counter.saveCount(); int _numberofvisitors=counter.getVisitorsNumber(); out.println(_numberofvisitors); % Bean: package counter; import java.sql.*; import java.sql.SQLException; public class CounterBean implements java.io.Serializable { int coun = 0; public CounterBean() { database.DatabaseManager.getInstance().getDatabaseConnection(); } public int getCoun() { return this.coun; } public void setCoun(int coun) { this.coun += coun; } public boolean saveCount() { boolean _save = false; database.SQLUpdateStatement sqlupdate = new database.SQLUpdateStatement("counter", "hitcounter"); sqlupdate.addColumn("hitcounter", getCoun()); if (sqlupdate.Execute()) { _save = true; } return _save; } public int getVisitorsNumber() throws SQLException { int numberOfVisitors = 0; if (database.DatabaseManager.getInstance().connectionOK()) { database.SQLSelectStatement sqlselect = new database.SQLSelectStatement("counter", "hitcounter", "0"); ResultSet _userExist = sqlselect.executeWithNoCondition(); if (_userExist.next()) { numberOfVisitors = _userExist.getInt("hitcounter"); } } return numberOfVisitors; } }

    Read the article

1 2  | Next Page >