Search Results

Search found 28 results on 2 pages for 'barchart'.

Page 1/2 | 1 2  | Next Page >

  • wpf set barchart graph width programmatically C#

    - by Aizaz
    I have a chart and I am adding ColumnSeries and chart legend etc but how to programmatically set its bar width... ??? | |------| | | | | |set | | |this | | |width | | | | | | | | | |BarChart Graph |_______|______|_______________________________ <charting:Chart x:Name="mainChart" Grid.Row="0" Margin="0,8,8,8" Title="Protocols Usage" Height="Auto" Width="Auto" LegendTitle="Protocols" Background="#FFE5F1FE"> </charting:Chart> legend and others things produced on the fly... How to set width of ColumnSeries from C# code?

    Read the article

  • Flex BarChart and XML

    - by theband
    <mx:BarChart id="barChart" showDataTips="true" dataProvider="{testInfo}" width="100%" height="100%"> <mx:verticalAxis> <mx:CategoryAxis categoryField="ProjectName"/> </mx:verticalAxis> <mx:series> <mx:BarSeries id="barSeries" yField="ProjectName" xField="State" displayName="State" /> </mx:series> </mx:BarChart> I get the Project Names in the y -Axis, but nothing is displayed in the Chart. Could not construe on what's going as wrong. private function xmlHandler(evt:ResultEvent):void{ testInfo = evt.result.Project; }

    Read the article

  • Flex barChart and XML Data

    - by theband
    <Projectlist> <Project> <ProjectName>Alcoswitch - ToggleSwitches </ProjectName> <ProjectStatusname>Planning</ProjectStatusname> </Project> <Project> <ProjectName> Transverse Wedge</ProjectName> <ProjectStatusname>Canceled</ProjectStatusname> </Project> <Project> <ProjectName>High Speed Pluggable I/O</ProjectName> <ProjectStatusname>In-Progress</ProjectStatusname> </Project> <Project> <ProjectName>"High Speed Pluggable I/O - Product Breakouts:</ProjectName> <ProjectStatusname>In-Progress</ProjectStatusname> </Project> <Project> <ProjectName>Circular Plastic Connector (CPC)</ProjectName> <ProjectStatusname>In-Progress</ProjectStatusname> </Project> </Projectlist> This is my XML data i am recieving, how can i show this in a bar chart. <mx:BarChart id="barChart" showDataTips="true" dataProvider="{ProjectStateInfo}" width="100%" height="100%"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="ProjectStatusname"/> </mx:horizontalAxis> <mx:verticalAxis> <mx:CategoryAxis categoryField="ProjectName"/> </mx:verticalAxis> <mx:series> <mx:BarSeries id="barSeries" visible="true" yField="ProjectName" xField="ProjectStatusname" displayName="ProjectStatusname" /> </mx:series> </mx:BarChart> My X-Axis shows muliple values of In-Progress, but i just need one. Is it possible to represent such relationship using BarChart. Any other Flex chart is Advisable.

    Read the article

  • Allow horizontal scrolling only in the core-plot barchart?

    - by Madhup
    Hi all, I am using core-plot lib to draw bar charts in my app like this My problem is that i want the enabling of grapgh movement only in horizontal direction so that I can see the records for a long period of time, But the problem is that i just wnt to keep the y axis fixed to its place, How can i do this? Waiting for help....

    Read the article

  • Axis value changes in barchart while swapping the phone using Achartengine

    - by Vasu
    Hi I have included the Barchart using AchartEngine API .When I swap the orientation of the screen the yaxis value is altered as same values. For eg. initially it is (0,10) , (10,25) but after swapping its changes to (0,10), (10,10) i could not understand why it is happening . And I have place string in x axis instead of numbers , I used addtextlabel method but the string is overlapped on the number . I need to display only the names. could you help on this. I have included my code here. public class Analytics extends Activity implements OnClickListener { private Button settings_btn; private RelativeLayout relativeLayout3; private boolean isClicked = false; private static final int SERIES_NR = 1; static int multiple_of_five; private GraphicalView mChartView; XYMultipleSeriesRenderer renderer; static int value=20; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.analytics); settings_btn = (Button) findViewById(R.id.settings_btn); relativeLayout3 = (RelativeLayout) findViewById(R.id.relativeLayout3); settings_btn.setOnClickListener(this); if (SharedValues.isClicked) { relativeLayout3.setVisibility(View.VISIBLE); } else { relativeLayout3.setVisibility(View.GONE); } renderer = getBarDemoRenderer(); setChartSettings(renderer); if (mChartView == null) { RelativeLayout layout = (RelativeLayout) findViewById(R.id.relativeLayout5); // mChartView= ChartFactory.getLineChartView(this, getDemoDataset(), getDemoRenderer()); mChartView = ChartFactory.getBarChartView(getApplicationContext(),getBarDemoDataset(),renderer,Type.DEFAULT); layout.addView(mChartView,new LayoutParams(LayoutParams.FILL_PARENT, 280)); } else { mChartView.repaint(); } // Intent intent = ChartFactory.getLineChartIntent(this, getDemoDataset(), getDemoRenderer()); // intent = ChartFactory.getBarChartIntent(this, getBarDemoDataset(), renderer, Type.DEFAULT); // startActivity(intent); } @Override protected void onResume() { super.onResume(); } public XYMultipleSeriesRenderer getBarDemoRenderer() { XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); renderer.setAxisTitleTextSize(16); renderer.setChartTitleTextSize(20); renderer.setLabelsTextSize(15); renderer.setLegendTextSize(15); // renderer.setApplyBackgroundColor(true); // renderer.setBackgroundColor(R.color.chart_bg); // renderer.setMarginsColor(R.color.settings_bg_color); // renderer.setBackgroundColor(getResources().getColor(R.color.background)); renderer.setPanEnabled(false, false); renderer.setZoomEnabled(false, false); renderer.setMargins(new int[] {0, 10, 0, 0}); SimpleSeriesRenderer r = new SimpleSeriesRenderer(); // r.setColor(Color.MAGENTA); // renderer.addSeriesRenderer(r); r = new SimpleSeriesRenderer(); r.setColor(Color.CYAN); renderer.addSeriesRenderer(r); return renderer; } private void setChartSettings(XYMultipleSeriesRenderer renderer) { // renderer.setChartTitle("Chart demo"); // renderer.setXTitle("x values"); // renderer.setYTitle("y values"); renderer.setXAxisMin(2); renderer.setMarginsColor(Color.parseColor("#00F5DA81")); renderer.addXTextLabel(1.0, "Q1"); renderer.addXTextLabel(3.0, "Q2"); renderer.addXTextLabel(5.0, "Q3"); renderer.addXTextLabel(7.0, "Q4"); renderer.addXTextLabel(9.0, "Q5"); renderer.setXAxisMax(20); renderer.setYAxisMin(0); renderer.setYAxisMax(100); renderer.setZoomEnabled(false, false); // renderer.setApplyBackgroundColor(true); // renderer.setMarginsColor(R.color.settings_bg_color); renderer.setBackgroundColor(Color.TRANSPARENT); // renderer.setBackgroundColor(R.color.chart_bg); } private XYMultipleSeriesDataset getDemoDataset() { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); final int nr = 10; Random r = new Random(); for (int i = 0; i < SERIES_NR; i++) { XYSeries series = new XYSeries(""); for (int k = 0; k < nr; k++) { if(k%2==1) { series.add(0, 0); } else { series.add(k, 20); } } dataset.addSeries(series); } return dataset; } private XYMultipleSeriesRenderer getDemoRenderer() { XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); renderer.setAxisTitleTextSize(6); renderer.setChartTitleTextSize(10); renderer.setLabelsTextSize(5); renderer.setLegendTextSize(5); renderer.setPointSize(5f); // renderer.setMarginsColor(R.color.settings_bg_color); // renderer.setApplyBackgroundColor(true); // renderer.setBackgroundColor(R.color.chart_bg); renderer.setMargins(new int[] {20, 30, 15, 0}); XYSeriesRenderer r = new XYSeriesRenderer(); r.setColor(Color.BLUE); r.setPointStyle(PointStyle.SQUARE); r.setFillBelowLine(true); r.setFillBelowLineColor(Color.WHITE); r.setFillPoints(true); renderer.addSeriesRenderer(r); r = new XYSeriesRenderer(); r.setPointStyle(PointStyle.CIRCLE); r.setColor(Color.GREEN); r.setFillPoints(true); renderer.addSeriesRenderer(r); renderer.setAxesColor(Color.DKGRAY); renderer.setLabelsColor(Color.LTGRAY); return renderer; } private XYMultipleSeriesDataset getBarDemoDataset() { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); final int nr = 10; Random r = new Random(); for (int i = 0; i < SERIES_NR; i++) { CategorySeries series = new CategorySeries("Quadrant"); for (int k = 0; k < nr; k++) { value=value+5; // multiple_of_five=k+5; // Log.i("multiple_of_five", ""+multiple_of_five); // series.add(20 +multiple_of_five ); if(k%2==1){ series.add(value ); } else { series.add(0); } } dataset.addSeries(series.toXYSeries()); } return dataset; } @Override public void onClick(View v) { if (v == settings_btn) { if (SharedValues.isClicked) { relativeLayout3.setVisibility(View.GONE); SharedValues.isClicked = false; } else { relativeLayout3.setVisibility(View.VISIBLE); SharedValues.isClicked = true; } } } }

    Read the article

  • core-plot barchart does not work!!

    - by user355068
    Hello~ I try to draw bar chart!! numberForPlot is not good work, only CPBarPlotFieldBarLength set. -(NSNumber *)numberForPlot: (CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index { NSDecimalNumber *num = nil; NSString *key = (fieldEnum == CPScatterPlotFieldX) ? @"x" : @"y"; if ( [plot isKindOfClass:[CPBarPlot class]] ) { switch ( fieldEnum ) { NSLog(@"fieldEnum = %d",fieldEnum); case CPBarPlotFieldBarLocation: num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger:index]; NSLog(@"CPBarPlotFieldBarLocation return num = %@",num); break; case CPBarPlotFieldBarLength: num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger: (index+1)*(index+1)]; if ( [plot.identifier isEqual:Plot3Identity] ) num = [[self.ExForPlot objectAtIndex:index] valueForKey:key]; NSLog(@"CPBarPlotFieldBarLength return num = %@",num); break; } } else { NSLog(@"...??.."); } return num; } # LOG 2010-06-01 02:43:19.424 myHealth[5071:207] CPBarPlotFieldBarLength return num = 0 2010-06-01 02:43:19.425 myHealth[5071:207] CPBarPlotFieldBarLength return num = 0 2010-06-01 02:43:19.425 myHealth[5071:207] CPBarPlotFieldBarLength return num = 30 # EXPlot set // Add some initial data NSMutableArray *contentArray = [NSMutableArray arrayWithCapacity:100]; int prevWeight = 0; int prevBmi = 0 ; if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) { while (sqlite3_step(statement)==SQLITE_ROW) { id x = [NSNumber numberWithInt:graphTimeStamp]; id y = [NSNumber numberWithInt:sqlite3_column_int(statement, 2)]; [contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x, @"x", y, @"y", nil]]; } self.ExForPlot = contentArray;

    Read the article

  • width of the bar in Jfreechart

    - by Harish
    Is there a way to adjust the width of the bars in a Barchart.I create my chart with the following code. final JFreeChart chart = ChartFactory.createBarChart("Report", // chart title "Date", // domain axis label "Number", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );

    Read the article

  • Google Pie Chart and Bar Chart (both Interactive) not showing labels.

    - by iRubens
    I'm trying to put Google's BarChart and PieChart both the client side version, and i'm experiencing some problems with the labels over the pie and the labels on the left of the vertical axis (of the bar chart). I checked the code a lot of times and it seems to be like that you can see in the examples. I've tried the same page on Firefox and Chrome and it shows the labels without problems. If i try the examples on IE8 the labels are shown but not in my page. Sincerely I've not any idea where to start to fix this thing. Someone can help me or give me an advice? Thanks in advance.

    Read the article

  • Flex chart not displaying right values along x axis.

    - by Shah Al
    I don't know of any better way to ask this question. If the below code is run (i know the cData sections are not visible in the preview, something causes it to be ignored). The result does not represent the data correctly. 1. Flex ignores missing date 24 aug for DECKER. 2. It wrongly associates 42.77 to 23-Aug instead of 24-AUG. Is there a way in flex, where the x-axis is a union of all available points ? The below code is entirely from : Adobe website link I have only commented 2 data points. //{date:"23-Aug-05", close:45.74}, and //{date:"24-Aug-05", close:150.71}, <?xml version="1.0"?> [Bindable] public var SMITH:ArrayCollection = new ArrayCollection([ {date:"22-Aug-05", close:41.87}, //{date:"23-Aug-05", close:45.74}, {date:"24-Aug-05", close:42.77}, {date:"25-Aug-05", close:48.06}, ]); [Bindable] public var DECKER:ArrayCollection = new ArrayCollection([ {date:"22-Aug-05", close:157.59}, {date:"23-Aug-05", close:160.3}, //{date:"24-Aug-05", close:150.71}, {date:"25-Aug-05", close:156.88}, ]); [Bindable] public var deckerColor:Number = 0x224488; [Bindable] public var smithColor:Number = 0x884422; ]] <mx:horizontalAxisRenderers> <mx:AxisRenderer placement="bottom" axis="{h1}"/> </mx:horizontalAxisRenderers> <mx:verticalAxisRenderers> <mx:AxisRenderer placement="left" axis="{v1}"> <mx:axisStroke>{h1Stroke}</mx:axisStroke> </mx:AxisRenderer> <mx:AxisRenderer placement="left" axis="{v2}"> <mx:axisStroke>{h2Stroke}</mx:axisStroke> </mx:AxisRenderer> </mx:verticalAxisRenderers> <mx:series> <mx:ColumnSeries id="cs1" horizontalAxis="{h1}" dataProvider="{SMITH}" yField="close" displayName="SMITH" > <mx:fill> <mx:SolidColor color="{smithColor}"/> </mx:fill> <mx:verticalAxis> <mx:LinearAxis id="v1" minimum="40" maximum="50"/> </mx:verticalAxis> </mx:ColumnSeries> <mx:LineSeries id="cs2" horizontalAxis="{h1}" dataProvider="{DECKER}" yField="close" displayName="DECKER" > <mx:verticalAxis> <mx:LinearAxis id="v2" minimum="150" maximum="170"/> </mx:verticalAxis> <mx:lineStroke> <mx:Stroke color="{deckerColor}" weight="4" alpha="1" /> </mx:lineStroke> </mx:LineSeries> </mx:series> </mx:ColumnChart> <mx:Legend dataProvider="{myChart}"/>

    Read the article

  • Crystal Reports Legends

    - by AWinters
    Is there a way to force a Bar Chart legend in Crystal Report 11.5 to display its objects in a particular order? For Example, say I am reporting on the consumption of "Bananas" and "Apples" by State. The Bar Chart should display the percentage of people who eat these fruits by county (Percent Bar Chart). The "Apples" percentage always displays on top of the bar chart and the "Bananas" on the bottom. The legend for this graph also displays the "Apple" color first, then the "Banana" color. However, if the "Banana" percentage is 0% the legend displays the "Banana" color first on the legend. This creates a inconsistent report (with plenty of complaints). I would like the "Banana" color to always display second in the legend. Hope I didn't confuse anyone and any ideas would be helpful.

    Read the article

  • Flex chart display with no datapoint

    - by Shah Al
    I need to display price of item for every date in the month. The chart can be Bar chart or plot chart. Question: Suppose there is no data available for 01/15/2010 then, Is there a way to display (01/15/2010) on x axis but no (bar or plot point) corresponding y axis point ? i.e. there will be a empty space between 2 bars or plot points. Currently i am using 0 , But 0 is a valid value. Let me know if such a display is possible.

    Read the article

  • how to run this qt script? (newbie question)

    - by GB_J
    I have a qt script(barchart.qs) that creates a graph for me. I don't know how i can incorporate(ie show the graph) in my qt mainwindow. Can some one please help me look at the code and what its outputs are? I tried engine.evaluate, but i do not know what is the QScriptValue i'm getting in return. Thanks sooo much. This is the script: BarChart.prototype = new QWidget; BarChart.prototype.suffix = ""; function BarChart(parent) { QWidget.call(this, parent); } // find the maximum value and widest (pixel-wise) label and suffix BarChart.prototype.showEvent = function(event) { var fm = new QFontMetrics(this); this.margin = 20; this.titleHeight = fm.height(); this.barHeight = 1.5 * fm.height(); this.barSpacing = 0.6 * fm.height(); this.maxValue = this.suffixWidth = this.labelWidth = 0; var count = 0; for (d in this.data) { this.labelWidth = Math.max(this.labelWidth, fm.width(d)); this.maxValue = Math.max(this.maxValue, this.data[d]); this.suffixWidth = Math.max(this.suffixWidth, fm.width(String(this.data[d]) + " " + this.suffix)); count++; } this.startHue = 15; this.hueDelta = 360 / count; this.size = new QSize(640, this.titleHeight + 2 * this.margin + (this.barHeight + this.barSpacing) * count); } BarChart.prototype.paintEvent = function(event) { var p = new QPainter; p.begin(this); // background and title p.fillRect(this.rect, new QBrush(new QColor(255, 255, 255))); p.drawText(0, 0, this.width, this.margin + this.titleHeight, Qt.AlignCenter, this.windowTitle, 0); var ofs = this.labelWidth + this.margin; var ww = this.width - this.suffixWidth - ofs - 2 * this.margin; var hue = this.startHue; var y = 0; p.translate(this.margin, this.titleHeight + 1.5 * this.margin); for (d in this.data) { // label on the left side p.setPen(new QColor(Qt.black)); p.drawText(0, y, this.labelWidth, this.barHeight, Qt.AlignVCenter + Qt.AlignRight, d, 0); // the colored bar var gradient = new QLinearGradient(new QPoint(ofs, y), new QPoint(ofs, y + this.barHeight)); gradient.setColorAt(0, QColor.fromHsv(hue, 255, 240)); gradient.setColorAt(1, QColor.fromHsv(hue, 255, 92)); p.setBrush(new QBrush(gradient)); p.setPen(new QColor(96, 96, 96)); var bw = this.data[d] * ww / this.maxValue; p.drawRect(ofs, y, bw, this.barHeight); // extra text at the end of the bar var text = new String(this.data[d] + " " + this.suffix); p.setPen(new QColor(Qt.black)); p.drawText(ofs + bw + this.margin/2, y, this.suffixWidth, this.barHeight, Qt.AlignVCenter + Qt.AlignLeft, text, 0); // for the next bar y += (this.barHeight + this.barSpacing); hue += this.hueDelta; if (hue >= 360) hue -= 360; } p.end(); } BarChart.prototype.wheelEvent = function(event) { this.startHue += event.delta() / 8 / 5; if (this.startHue = 360) this.startHue -= 360; if (this.startHue < 0) this.startHue += 360; this.update(); event.ignore(); } BarChart.prototype.mousePressEvent = function(event) { var fname = QFileDialog.getSaveFileName(this, "Save", ".", "*.png", 0, 0); if (fname.length > 0) { var img = new QImage(this.size, QImage.Format_ARGB32_Premultiplied); this.render(img); img.save(new QFile(fname)); } } var chart = new BarChart; chart.windowTitle = "Monthly"; chart.suffix = "reports"; chart.data = { "September" : 45, "October" : 60, "November" : 56, "December" : 0 }; chart.show(); QCoreApplication.exec();

    Read the article

  • How to properly close a UDT server in Netty 4

    - by Steffen
    I'm trying to close my UDT server (Netty 4.0.5.Final) with shutDownGracefully() and reopen it on the same port. Unfortunately, I always get the socket exception below although it waits until the future has completed. I also added the socket option SO_REUSEADDR. What is the proper way to do this? Exception in thread "main" com.barchart.udt.ExceptionUDT: UDT Error : 5011 : another socket is already listening on the same UDP port : listen0:listen [id: 0x323d3939] at com.barchart.udt.SocketUDT.listen0(Native Method) at com.barchart.udt.SocketUDT.listen(SocketUDT.java:1136) at com.barchart.udt.net.NetServerSocketUDT.bind(NetServerSocketUDT.java:66) at io.netty.channel.udt.nio.NioUdtAcceptorChannel.doBind(NioUdtAcceptorChannel.java:71) at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:471) at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1006) at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:504) at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:487) at io.netty.channel.ChannelDuplexHandler.bind(ChannelDuplexHandler.java:38) at io.netty.handler.logging.LoggingHandler.bind(LoggingHandler.java:254) at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:504) at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:487) at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:848) at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:193) at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:321) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:366) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) at java.lang.Thread.run(Thread.java:724) A small test program demonstration the problem: public class MsgEchoServer { public static class MsgEchoServerHandler extends ChannelInboundHandlerAdapter { } public void run() throws Exception { final ThreadFactory acceptFactory = new UtilThreadFactory("accept"); final ThreadFactory connectFactory = new UtilThreadFactory("connect"); final NioEventLoopGroup acceptGroup = new NioEventLoopGroup(1, acceptFactory, NioUdtProvider.MESSAGE_PROVIDER); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); try { final ServerBootstrap boot = new ServerBootstrap(); boot.group(acceptGroup, connectGroup) .channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR) .option(ChannelOption.SO_BACKLOG, 10) .option(ChannelOption.SO_REUSEADDR, true) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new MsgEchoServerHandler()); } }); final ChannelFuture future = boot.bind(1234).sync(); } finally { acceptGroup.shutdownGracefully().syncUninterruptibly(); connectGroup.shutdownGracefully().syncUninterruptibly(); } new MsgEchoServer().run(); } public static void main(final String[] args) throws Exception { new MsgEchoServer().run(); } }

    Read the article

  • Twitter ?? Nashorn ????(??)

    - by Homma
    ???? Nashorn ? Java ??????? Twitter ???????????????????? JavaFX ??????????????? ????? ??? jlaskey ??? Nashorn Blog ????????????? https://blogs.oracle.com/nashorn/entry/nashorn_in_the_twitterverse_continued ???????? ?? Twitter ???????????????????????? JavaFX ??????????????????????????????? Nashorn ?? JavaFX ??????????????JavaFX ???????????????????????????????????????Nashorn ? Java ????????????????????????????????????(JavaFX ?????????????????????)? ?????????????????????????????????????????????? Twitter ????????????????????????? var twitter4j = Packages.twitter4j; var TwitterFactory = twitter4j.TwitterFactory; var Query = twitter4j.Query; function getTrendingData() { var twitter = new TwitterFactory().instance; var query = new Query("nashorn OR nashornjs"); query.since("2012-11-21"); query.count = 100; var data = {}; do { var result = twitter.search(query); var tweets = result.tweets; for each (var tweet in tweets) { var date = tweet.createdAt; var key = (1900 + date.year) + "/" + (1 + date.month) + "/" + date.date; data[key] = (data[key] || 0) + 1; } } while (query = result.nextQuery()); return data; } ??????????????????getTrendingData() ??????????????(??????????Nashorn ???????? OpenJDK ?????? 2012 ? 11 ? 21 ???)??????????????????????????????????? ????JavaFX ? BarChart ??????????? var javafx = Packages.javafx; var Stage = javafx.stage.Stage var Scene = javafx.scene.Scene; var Group = javafx.scene.Group; var Chart = javafx.scene.chart.Chart; var FXCollections = javafx.collections.FXCollections; var ObservableList = javafx.collections.ObservableList; var CategoryAxis = javafx.scene.chart.CategoryAxis; var NumberAxis = javafx.scene.chart.NumberAxis; var BarChart = javafx.scene.chart.BarChart; var XYChart = javafx.scene.chart.XYChart; var Series = javafx.scene.chart.XYChart.Series; var Data = javafx.scene.chart.XYChart.Data; function graph(stage, data) { var root = new Group(); stage.scene = new Scene(root); var dates = Object.keys(data); var xAxis = new CategoryAxis(); xAxis.categories = FXCollections.observableArrayList(dates); var yAxis = new NumberAxis("Tweets", 0.0, 200.0, 50.0); var series = FXCollections.observableArrayList(); for (var date in data) { series.add(new Data(date, data[date])); } var tweets = new Series("Tweets", series); var barChartData = FXCollections.observableArrayList(tweets); var chart = new BarChart(xAxis, yAxis, barChartData, 25.0); root.children.add(chart); } ????????????????????????????????stage.scene = new Scene(root) ? stage.setScene(new Scene(root)) ????????????????????Nashorn ? stage ??????? scene ???????????????????(Dynalink ?????????)Java Beans ???????????????? (setScene()) ???????????????????????????????Nashorn ? FXCollections ??????????????????????????????observableArrayList(dates) ??????????Nashorn ? JavaScript ??? (dates) ? Java ???????????????????????????? JavaScript ?????????????????? Java ????????????????????????????????????????????????????????????? ????????????????????????????????? JavaFX ???????????????????????? JavaFX ??????????????javafx.application.Application ??????????????????????????? JavaFX ????????????????????????????????????????????????? import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javafx.application.Application; import javafx.stage.Stage; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class TrendingMain extends Application { private static final ScriptEngineManager MANAGER = new ScriptEngineManager(); private final ScriptEngine engine = MANAGER.getEngineByName("nashorn"); private Trending trending; public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { trending = (Trending) load("Trending.js"); trending.start(stage); } @Override public void stop() throws Exception { trending.stop(); } private Object load(String script) throws IOException, ScriptException { try (final InputStream is = TrendingMain.class.getResourceAsStream(script)) { return engine.eval(new InputStreamReader(is, "utf-8")); } } } ???? Nashorn ??????? JSR-223 ? javax.script ????????? private static final ScriptEngineManager MANAGER = new ScriptEngineManager(); private final ScriptEngine engine = MANAGER.getEngineByName("nashorn"); ????????? JavaScript ???????? Nashorn ???????????????????? load ???????????????????????engine ???????????????load ????????????? ???????????????Java ???????????????????????????????????????????????????? Java ????????????????JavaFX ???????? start ????? stop ?????????????????????????????????????? public interface Trending { public void start(Stage stage) throws Exception; public void stop() throws Exception; } ?????????????????????????????? function newTrending() { return new Packages.Trending() { start: function(stage) { var data = getTrendingData(); graph(stage, data); stage.show(); }, stop: function() { } } } newTrending(); ?????? Trending ?????????????????????start ????? stop ??????????????????????????????????? eval ???? Java ??????????????? trending = (Trending) load("Trending.js"); ????????????????Trending.js ??????? getTrendingData ???????????? newTrending ????????????????????? Java ?????????newTrending ????????? eval ????????? Trending ????????????????????????????????????????????????????????? trending.start(stage); ???????? ???? Nashorn ????????? http://www.myexpospace.com/JavaOne2012/SessionFiles/CON5251_PDF_5251_0001.pdf ???????? Dynalink ??????? https://github.com/szegedi/dynalink ????????

    Read the article

  • Nashorn in the Twitterverse, Continued

    - by jlaskey
    After doing the Twitter example, it seemed reasonable to try graphing the result with JavaFX.  At this time the Nashorn project doesn't have an JavaFX shell, so we have to go through some hoops to create an JavaFX application.  I thought showing you some of those hoops might give you some idea about what you can do mixing Nashorn and Java (we'll add a JavaFX shell to the todo list.) First, let's look at the meat of the application.  Here is the repackaged version of the original twitter example. var twitter4j      = Packages.twitter4j; var TwitterFactory = twitter4j.TwitterFactory; var Query          = twitter4j.Query; function getTrendingData() {     var twitter = new TwitterFactory().instance;     var query   = new Query("nashorn OR nashornjs");     query.since("2012-11-21");     query.count = 100;     var data = {};     do {         var result = twitter.search(query);         var tweets = result.tweets;         for each (tweet in tweets) {             var date = tweet.createdAt;             var key = (1900 + date.year) + "/" +                       (1 + date.month) + "/" +                       date.date;             data[key] = (data[key] || 0) + 1;         }     } while (query = result.nextQuery());     return data; } Instead of just printing out tweets, getTrendingData tallies "tweets per date" during the sample period (since "2012-11-21", the date "New Project: Nashorn" was posted.)   getTrendingData then returns the resulting tally object. Next, use JavaFX BarChart to display that data. var javafx         = Packages.javafx; var Stage          = javafx.stage.Stage var Scene          = javafx.scene.Scene; var Group          = javafx.scene.Group; var Chart          = javafx.scene.chart.Chart; var FXCollections  = javafx.collections.FXCollections; var ObservableList = javafx.collections.ObservableList; var CategoryAxis   = javafx.scene.chart.CategoryAxis; var NumberAxis     = javafx.scene.chart.NumberAxis; var BarChart       = javafx.scene.chart.BarChart; var XYChart        = javafx.scene.chart.XYChart; var Series         = XYChart.Series; var Data           = XYChart.Data; function graph(stage, data) {     var root = new Group();     stage.scene = new Scene(root);     var dates = Object.keys(data);     var xAxis = new CategoryAxis();     xAxis.categories = FXCollections.observableArrayList(dates);     var yAxis = new NumberAxis("Tweets", 0.0, 200.0, 50.0);     var series = FXCollections.observableArrayList();     for (var date in data) {         series.add(new Data(date, data[date]));     }     var tweets = new Series("Tweets", series);     var barChartData = FXCollections.observableArrayList(tweets);     var chart = new BarChart(xAxis, yAxis, barChartData, 25.0);     root.children.add(chart); } I should point out that there is a lot of subtlety going on in the background.  For example; stage.scene = new Scene(root) is equivalent to stage.setScene(new Scene(root)). If Nashorn can't find a property (scene), then it searches (via Dynalink) for the Java Beans equivalent (setScene.)  Also note, that Nashorn is magically handling the generic class FXCollections.  Finally,  with the call to observableArrayList(dates), Nashorn is automatically converting the JavaScript array dates to a Java collection.  It really is hard to identify which objects are JavaScript and which are Java.  Does it really matter? Okay, with the meat out of the way, let's talk about the hoops. When working with JavaFX, you start with a main subclass of javafx.application.Application.  This class handles the initialization of the JavaFX libraries and the event processing.  This is what I used for this example; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javafx.application.Application; import javafx.stage.Stage; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class TrendingMain extends Application { private static final ScriptEngineManager MANAGER = new ScriptEngineManager(); private final ScriptEngine engine = MANAGER.getEngineByName("nashorn"); private Trending trending; public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { trending = (Trending) load("Trending.js"); trending.start(stage); } @Override public void stop() throws Exception { trending.stop(); } private Object load(String script) throws IOException, ScriptException { try (final InputStream is = TrendingMain.class.getResourceAsStream(script)) { return engine.eval(new InputStreamReader(is, "utf-8")); } } } To initialize Nashorn, we use JSR-223's javax.script.  private static final ScriptEngineManager MANAGER = new ScriptEngineManager(); private final ScriptEngine engine = MANAGER.getEngineByName("nashorn"); This code sets up an instance of the Nashorn engine for evaluating scripts. The  load method reads a script into memory and then gets engine to eval that script.  Note, that load also returns the result of the eval. Now for the fun part.  There are several different approaches we could use to communicate between the Java main and the script.  In this example we'll use a Java interface.  The JavaFX main needs to do at least start and stop, so the following will suffice as an interface; public interface Trending {     public void start(Stage stage) throws Exception;     public void stop() throws Exception; } At the end of the example's script we add; (function newTrending() {     return new Packages.Trending() {         start: function(stage) {             var data = getTrendingData();             graph(stage, data);             stage.show();         },         stop: function() {         }     } })(); which instantiates a new subclass instance of Trending and overrides the start and stop methods.  The result of this function call is what is returned to main via the eval. trending = (Trending) load("Trending.js"); To recap, the script Trending.js contains functions getTrendingData, graph and newTrending, plus the call at the end to newTrending.  Back in the Java code, we cast the result of the eval (call to newTrending) to Trending, thus, we end up with an object that we can then use to call back into the script.  trending.start(stage); Voila. ?

    Read the article

  • New January 2013 Release of the Ajax Control Toolkit

    - by Stephen.Walther
    I am super excited to announce the January 2013 release of the Ajax Control Toolkit! I have one word to describe this release and that word is “Charts” – we’ve added lots of great new chart controls to the Ajax Control Toolkit. You can download the new release directly from http://AjaxControlToolkit.CodePlex.com – or, just fire the following command from the Visual Studio Library Package Manager Console Window (NuGet): Install-Package AjaxControlToolkit You also can view the new chart controls by visiting the “live” Ajax Control Toolkit Sample Site. 5 New Ajax Control Toolkit Chart Controls The Ajax Control Toolkit contains five new chart controls: the AreaChart, BarChart, BubbleChart, LineChart, and PieChart controls. Here is a sample of each of the controls: AreaChart: BarChart: BubbleChart: LineChart: PieChart: We realize that people love to customize the appearance of their charts so all of the chart controls include properties such as color properties. The chart controls render the chart on the browser using SVG. The chart controls are compatible with any browser which supports SVG including Internet Explorer 9 and new and recent versions of Google Chrome, Mozilla Firefox, and Apple Safari. (If you attempt to display a chart on a browser which does not support SVG then you won’t get an error – you just won’t get anything). Updates to the HTML Sanitizer If you are using the HtmlEditorExtender on a public-facing website then it is really important that you enable the HTML Sanitizer to prevent Cross-Site Scripting (XSS) attacks. The HtmlEditorExtender uses the HTML Sanitizer by default. The HTML Sanitizer strips out any suspicious content (like JavaScript code and CSS expressions) from the HTML submitted with the HtmlEditorExtender. We followed the recommendations of OWASP and ha.ckers.org to identify suspicious content. We updated the HTML Sanitizer with this release to protect against new types of XSS attacks. The HTML Sanitizer now has over 220 unit tests. The Ajax Control Toolkit team would like to thank Gil Cohen who helped us identify and block additional XSS attacks. Change in Ajax Control Toolkit Version Format We ran out of numbers. The Ajax Control Toolkit was first released way back in 2006. In previous releases, the version of the Ajax Control Toolkit followed the format: Release Year + Date. So, the previous release was 60919 where 6 represented the 6th release year and 0919 represent September 19. Unfortunately, the AssembyVersion attribute uses a UInt16 data type which has a maximum size of 65,534. The number 70123 is bigger than 65,534 so we had to change our version format with this release. Fortunately, the AssemblyVersion attribute actually accepts four UInt16 numbers so we used another one. This release of the Ajax Control Toolkit is officially version 7.0123. This new version format should work for another 65,000 years. And yes, I realize that 7.0123 is less than 60,919, but we ran out of numbers. Summary I hope that you find the chart controls included with this latest release of the Ajax Control Toolkit useful. Let me know if you use them in applications that you build. And, let me know if you run into any issues using the new chart controls. Next month, back to improving the File Upload control – more exciting stuff.

    Read the article

  • I want to input JSONObject from jquery.post() to a a simple JS chart(bar chart)?

    - by ann-stack
    HI I am very new to both json and js charts. In the example of bar chart, they are giving a hard coded array like this, var myData = new Array(['U.S.A.', 69.5], ['Canada', 2.8], ['Japan & SE.Asia', 5.6] ); var myChart = new JSChart('graph', 'bar'); myChart.setDataArray(myData); Instead of that I want to use the response of $.post() method which is in json. Here is the piece of code. var myData=[]; $.post("JSONServlet", function(data) { $.each(data.Userdetails, function(i, data) { myData[i] = []; myData[i]['text'] = data['firstname']; myData[i]['id'] = data['ssn']; alert("first name " +myData[i]['text']+ " salary " +myData[i]['id']); // I am getting correct data here, but how to assign this myData to barchart }); }, "json"); is this the logic to use or how else can i get username and salary from the response and pass it to the barchart. Please help. I am stuck with this. thanks in advance.

    Read the article

  • Reducing width of bar chart series

    - by gAMBOOKa
    Note: by width i mean the height here, I use width because by default, bar charts are vertical and flex uses the width property I want to reduce the width of the following barchart so Type 5, Type 4, Type 3, Type 2, Type 1 are very close to each other. I tried playing with the barWidthRatio, the horizontalAxisRatio and the maxBarWidth properties. Neither is giving me the desired result. I can only manage to reduce the width of the orange bars, how do I reduce the width of the blue bars?

    Read the article

  • Data table with legends in JfreeChart

    - by TiNS
    Hi All, I am using JFreeChart to generate images. I am trying to create barchart like below. I am able to create it successfully without data table. I tried to get from the jfreechar forums and found this post). According to the post , its not supported by JfreeChart. Is it still not supported by jfreechart API ? If yes, can I use any other charting (open source) tool to generate chart with data table ? Thanks

    Read the article

  • Data table with legends in JfreeChart/Java

    - by TiNS
    Hi All, I am using JFreeChart to generate images. I am trying to create barchart like below. I am able to create it successfully without data table. I tried to get more information from the jfreechar forums and found this post. According to the post , its not supported by JfreeChart. Is it still not supported by jfreechart API ? If yes, can I use any other charting (open source) tool to generate chart with data table ? Thanks

    Read the article

1 2  | Next Page >