How to create trend line in cfchart?

I can create a scatter chart in cfchart - but I do not know how to create a linear regression trend line in the same chart as a second data series. Kodemonki provided an answer in a forum discussion a few years ago (http://forums.adobe.com/message/192848#192848) - but I am not able to make it work (I have a dangerously small knowledge of coldfusion and statisitcal formulas). Can someone tell me where i put in my to data query variables - such as for a query that gives results for two data fields, "Item1" and "Item2".
Here is Kodemonki's solution:
<!--- The min setting is a preference based on how you want the data to be displayed. --->
<!---<cfset min = arrayMin(grabData["value"]) - 5>--->
     <cfset min = 0>
     <cfset max = ceiling(arrayMax(grabData["value"])) + 1>
     <cfset n = grabData.recordCount>
     <cfset sum_x = 0>
     <cfset sum_x2 = 0>
     <cfset sum_xy = 0>
     <cfloop from="1" to="#grabData.RecordCount#" index="i">
          <cfset sum_x = sum_x + i>
          <cfset sum_xy = (i*grabData.value[i]) + sum_xy>
          <cfset sum_x2 = sum_x2 + (i*i)>
     </cfloop>
     <cfset sum_y = arraySum(grabData["value"])>
     <cfset slope = round(((n*sum_xy) - (sum_x*sum_y))/((n*sum_x2) - (sum_x*sum_x)))>
     <cfset intercept = round((sum_y - (slope*sum_x))/n)>
     <cfset best_fit = QueryNew("id, value")>
     <cfloop from="1" to="#grabdata.RecordCount#" index="i">
          <cfset queryAddRow(best_fit)>
          <cfset value = round((slope*i) + intercept)>
          <cfset QuerySetCell(best_fit, "id", grabData.xlabel[i])>
          <cfset QuerySetCell(best_fit, "value", value)>
     </cfloop>
     <cfchart scalefrom="#min#" scaleto="#max#" title="#GrabDatapointInfo.label#" format="jpg" chartHeight="450" chartwidth="500" xaxistitle="Month/Year">
          <cfchartseries type="line" query="best_fit" valuecolumn="value" itemcolumn="id"/>
          <cfchartseries type="line" query="grabData" valuecolumn="value" itemcolumn="xlabel"/>
     </cfchart>

Have you read the docs for CFCHART, CHCHARTSERIES, etc?  Did you mess around with the example code sufficiently so you understand how the tags work?
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-79 30.html
Adam

Similar Messages

  • Can You Create Trend Line in CFCHART?

    Have pretty much got CF7 Charts and WebCharts3D down, at
    least to the point where they can do what I need the most. However,
    the one thing I'd like to be able to do, but not sure if it's
    possible, is create a TREND LINE.
    This would be a LINE charts with 2 series. The first series
    would be a line with the actual counts covering a period of time.
    I'd like to add a 2nd line, using the same data from the
    first series, but have it displayed as a TREND line. In Excel, you
    can easily create a TREND line, it's even offered as an option.
    I've seen somehwere (CFCHART or WebCharts3D) something to so
    with "logarithmic" options, which is one of the options for Excel
    charts.
    Two more quick questions:
    Q1. Is there any way to control the margin between the left
    and right borders of the charts, and the bars? Have tried
    experimenting, but can't seem to get this to work. Reason is, when
    I try to show a chart in 3D, the first bar on the left is "butted
    up" against the left chart border. Would like to add a little space
    there.
    Q2. Rather than display rectangular bars, I'd like to display
    rounded cylinders. I've tried setting the chart type in CFCHART to
    "cylinder" but it still displays a bar. When I try to change the
    type to "cylinder" in WebCharts3D, the chart STILL displays
    rectangular bars. Yet I've seen many examples of rounded, cylinder
    bars.
    Don't mean to push my luck with too many questions. Thanks
    for any advice, help.
    Gary

    Trend Lines:
    CFChart does not do trend lines of any type. However, it is
    not too difficult to compute the regression of your choice and to
    plot it as a second series.
    Logarithmic:
    Not sure what you are asking here.
    In theory, cfchart does do log-lin and log-log charts.
    However, it is so buggy, and the scaling problems are so
    great, that we have never been able to get it to work well.
    We use ChartDirector for anything that requires a log scale.
    Side margins:
    You cannot control these directly. Here are some workarounds:
    For "Category" axis:
    Make sure the "isBucketed" property is set to true (this is the
    default).
    If that is not enough, add extra bars to your data series,
    usually value zero. It's not ideal but it may be good enough.
    For "Scale" axis:
    Usually this works well enough. Otherwise, try toggling the
    "isAbsolute" property.
    The only other recourse is to manually scale the plot using the
    "scaleMin" and "scaleMax" properties. This can be a real pain for
    obvious reasons and also because cfchart scaling is fraught with
    bugs and "quirks".
    Cylinder Bars:
    These work. Perhaps there was a setting conflict within the
    XML or between the CFChartSeries setting and the XML?
    Also the cylinders will only look round when 3D is turned on.
    (Side view of a cylinder is just a shaded bar.)
    Anyway, I've said it before: cfchart is barely usable for a
    very limited range of charts.
    For real business or common engineering and scientific needs,
    you need to step up to something better.
    The package we use (has all the features and very reasonably
    priced) is ChartDirector (
    http://www.advsofteng.com/cdcoldfusion.html).
    (And, no, I'm not affiliated.)

  • How to get trending line in the graph

    Hi,
    I am using 10g. I have requirement as the following :
    Name Date Metric
    I can have bar graph against Date and Metric. My requirement is to have a trending line, so I calculated slope and regression line y=mx+c but I am not getting the right trend line. I can use regr_slope function to create a view in rpd but it doesnt support date values. Can you guys let me know how to get trending line like same in Excel.
    Thanks

    Hi,
    It's better to do at UI level.
    Can you please check the below link:
    http://kpipartners.blogspot.in/2009/04/linear-regression.html
    Hope this helps.
    Thanks,
    Pramod.

  • How to create a line type in data dictionary

    How to create a line type in data dictionary?Please explain step by step?
    Thanks & Regads,
    Sairam

    Hi,
    the details abbout the line type.
    The line type of a table type can be defined by:
    o Specification of a type that already exists (data element,
    structure, table type, table, view) whose properties are then copie
    as properties of the defined table line.
    o Direct type input, where data type, number of positions, and, if
    required, decimal places, are entered directly.
    o Specification of a reference type.
    and SE11 and click on datatype and click on table type and enter the line type.
    Thanks
    Shiva

  • How to create a trend line in cfchart?

    I  can create a scatter chart in cfchart - but I do not know how to create  a linear regression trend line in the same chart as a second data  series.
    Kodemonki provided an answer in a forum discussion a few years  ago (http://forums.adobe.com/message/192848#192848).
    But I am not able to make it work (I have a dangerously small  knowledge of coldfusion and statisitcal formulas).
    Can someone tell me  where i put in my to data query variables - such as for a query that  gives results for two data fields, "Item1" and "Item2".
    Thanks!
    Here is Kodemonki's solution:
    <!--- The min setting is a preference based on how you want the data to be displayed. --->
    <!---<cfset min = arrayMin(grabData["value"]) - 5>--->
         <cfset min = 0>
         <cfset max = ceiling(arrayMax(grabData["value"])) + 1>
         <cfset n = grabData.recordCount>
         <cfset sum_x = 0>
         <cfset sum_x2 = 0>
         <cfset sum_xy = 0>
         <cfloop from="1" to="#grabData.RecordCount#" index="i">
              <cfset sum_x = sum_x + i>
              <cfset sum_xy = (i*grabData.value[i]) + sum_xy>
              <cfset sum_x2 = sum_x2 + (i*i)>
         </cfloop>
         <cfset sum_y = arraySum(grabData["value"])>
         <cfset slope = round(((n*sum_xy) - (sum_x*sum_y))/((n*sum_x2) - (sum_x*sum_x)))>
         <cfset intercept = round((sum_y - (slope*sum_x))/n)>
         <cfset best_fit = QueryNew("id, value")>
         <cfloop from="1" to="#grabdata.RecordCount#" index="i">
              <cfset queryAddRow(best_fit)>
              <cfset value = round((slope*i) + intercept)>
              <cfset QuerySetCell(best_fit, "id", grabData.xlabel[i])>
              <cfset QuerySetCell(best_fit, "value", value)>
         </cfloop>
         <cfchart  scalefrom="#min#" scaleto="#max#" title="#GrabDatapointInfo.label#"  format="jpg" chartHeight="450" chartwidth="500"  xaxistitle="Month/Year">
              <cfchartseries type="line" query="best_fit" valuecolumn="value" itemcolumn="id"/>
              <cfchartseries type="line" query="grabData" valuecolumn="value" itemcolumn="xlabel"/>
         </cfchart>

    Have you read the docs for CFCHART, CHCHARTSERIES, etc?  Did you mess around with the example code sufficiently so you understand how the tags work?
    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-79 30.html
    Adam

  • How to create command line java client

    I have a java servlet FileClient.java and am invoking it thru POST method from the html file. How can I create command line java client so that I can execute this class file from windows command prompt.
    e.g. java FileClient <argument>
    TIA

    > .. there's also a "won't work".
    I could post a sample...I know that you can instantiate and call aservlet,
    or even write your own servlet container - butit's
    still a local instance. He can't invoke his remote
    servlet by calling its class on the client like he
    suggested.HttpURLConnection in main.Only if his Servlet has a main method. Which wouldn't really make it a servlet anymore.
    OP said he wants to invoke it from command-line using
    java -cp . TheServletClass
    He said he has a servlet called FileClient. And he can't invoke a servlet directly that way, without building a wrapper that starts it, making it more than a servlet, and it definitely won't execute on the server. That's my whole point. I never wanted to say you can't write a command-line program that invokes a servlet on a remote server. I do it myself after all.
    I guess I should have expressed myself more clearly.

  • How to create blank line in alv output

    Hi all,
    Iam getting alv output with currency values like below
    text1    20.0  10.0  30.0
    text2    25.0  11.0  30.0
    text3    27.0  19.0  30.0
    text1    24.0  18.0  30.0
    text2    27.0  16.0  30.0
    text3    29.0  15.0  30.0
    text1    23.0  17.0  30.0
    text2    22.0  13.0  30.0
    text3    21.0  14.0  30.0
    and so on...
    My requirement is to create blank line after text3. Since its currency field even i claer work area iam able to get 0.0.
    If i use no-zero in field catalog i will be able to get blank values for all 0.0, but thats not required.
    Can u help me out how to crate blank line after one set of values(text1, text2, text3) in alv display
    Thanks

    Hi,
    If i use no-zero, then all 0.0 will be replaced by blank, but that is not required.
    I want only blank line to be displayed after set of line items.
    Skip doesn't help in alv. Secondly if i append blank work area i will be getting 0.0 as it is a currency field.

  • Adobe Photoshop: how to create cut lines on landscape letter for two 5 by 7 in images?

    adobe photoshop: how do i create cutting lines in adobe photoshop if my document is landscape 8.5 by 11 inches and the image are two side by side 5 by 7 in (so appearing 10 inches wides, 7 inch height)... so basically this leaves a 0.5 border top/bottom/left right....i need corner crop marks and a little line in the middle top and bottom (in the crop area) to designate where to cut the 10 inches into 2, creating my two 5 by 7 inches for each image... my guidlines are perfectly aligned, i just need to know how to make cut lines out of my guidelines except in the middle

    What I use to do years ago, before most apps had auto crop marks. Was create the guidelines for the margin. Use a line tool, pen tool, etc. and create a line that goes from the guidelines where they meet each other and draw outwards to the edge of the page. Because the line is on the guideline, it snapped to it, making it a straight line. Repeated for the same corner drawing the other direction. (In other words, if I was doing the top left corner, I would draw out to the left, then repeat to draw out to the top of the page).
    Group the two line, copy and flip to snap it to the next corner and repeat until all four corners of the page are done.
    But if you have a postscript printer, acrobat pro, adober illustrator or adobe indesign, they will generate the crop marks for you.
    tip: Do the above while creating an action and your done for the next time. Just run the action. But I reccomend that you set the rules to percentages when creating the guidelines, that way, it can work on more than one image size.

  • How to create a Line JComponent

    Can anybody kindly show me how to create a JComponent which is a line or rectangle?

    As everywhere:
    shift return
    Peter

  • How to create dynamic line chart ?

    Dynamically create line on that graph.if select more than one values from multi select box , it will get id and execute query , draw the one more line on that graph.
    For example:
    oracle
    mysql
    sybase
    SQL server
    These are values in multiselect box.
    Now open the page with default value and show one line on the graph.Now i am going select another one values on multi select box.
    dynamically create another line on the same graph.
    How to do this graph ?

    jsf_VWP5.5.1 wrote:
    Any options in jasper reports ?Since when did jasper reports come into the picture?
    In any case, why don't you ask them, then? They should have some sort idea about it, I would think.

  • How to create 2 lines header in Report painter

    Hi. I am not good at Report painter. I want to create 2 lines header in Report painter just like SAP std report.
    When I create a new form, I only have one line header form but cannot add additional header line.
    I am looking at the 0SAPFS10-01 Trans.Fig.- Balances. which has two header lines
                               Debit              Credit            Balance       Accumulated Balanc
    Periods                     &1FY               &1FY               &1FY               &1FY
    I can create only one header just like
    Periods                 Debit              Credit            Balance       Accumulated Balanc
    cannot add additional line for
          &1FY               &1FY               &1FY               &1FY
    please advise me
    thanks in advance.

    In report painter you can select variouselements based on which the data will be pulled. I haven't seen any report painter with two header lines and don't think report painter allows that. But for your requirement I believe you can select the periods in the header line itself.

  • How to create a line without using execute action method.

    Hi All,
    I want to create a line whose weight and co-ordinate are given to me. I am using ActionDescriptor and execute action method to do this.
    Here is my code:
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        var idStrt = charIDToTypeID( "Strt" );
        var idHrzn = charIDToTypeID( "Hrzn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        var idVrtc = charIDToTypeID( "Vrtc" );
        var idPnt = charIDToTypeID( "Pnt " );
        var actRef = new ActionReference();
        actRef.putClass( idcontentLayer );
        var layerDesc = new ActionDescriptor();
        layerDesc.putReference( charIDToTypeID( "null" ), actRef );
        var lineDesc = new ActionDescriptor();
        lineDesc.putClass( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ) );
        var propertyDesc = new ActionDescriptor();
        var strtPointDesc = new ActionDescriptor();
        strtPointDesc.putUnitDouble( idHrzn, idPxl,  startX);                         //startX, startY, endX, endY are given..
        strtPointDesc.putUnitDouble( idVrtc, idPxl, startY);
        var endPointDesc = new ActionDescriptor();
        endPointDesc.putUnitDouble( idHrzn, idPxl, endX );
        endPointDesc.putUnitDouble( idVrtc, idPxl, endY );
        propertyDesc.putObject(  charIDToTypeID( "Strt" ), idPnt, strtPointDesc );
        propertyDesc.putObject( charIDToTypeID( "End " ), idPnt, endPointDesc);
        propertyDesc.putUnitDouble( charIDToTypeID( "Wdth" ), idPxl, weight );               // weight is given.
        lineDesc.putObject( charIDToTypeID( "Shp " ), charIDToTypeID( "Ln  " ), propertyDesc );
        layerDesc.putObject( charIDToTypeID( "Usng" ), idcontentLayer, lineDesc );
        executeAction( charIDToTypeID( "Mk  " ), layerDesc, DialogModes.NO );
    Is there any other way to do the above (using photoshop scripting method)?
    Thanks,
    AI

    You can only create normal and text layers using the Object Model. For other layer types you have to use Action Manager.

  • How to create RMA lines using OE_ORDER_PUB API

    Hi All,
    We are trying to create RMA lines using OE_ORDER_PUB API but every time API creating <b>Standard Order Line</b> line type in application.
    My program is creating order header as a <b>Return Order</b>, i am passing corrent line type ids (1028 - RMA Shipment, 1027 - RMA Receipt) but oracle API is creating Standard Order Lines (ID 1001).
    Can any one tell me about that?
    Thanks
    Ravi
    null

    Check the defaulting rules setup. Defaulting rule will derive the line type based on the order type and shippable flag etc.
    Also check the line flows assigned to the order type in transaction types window.
    Thanks / Bhaskar Akkala

  • How to create a line in flash action script 3.0

    i am trying to create a line that can be draggable and  extedable from start and end points of line. some one help plzz

    what problem are you having?

  • How to create additional Line in file based on condition available as part of ZINVOIC02 Idoc segment

    Scenario Details:
    Receiving Zinvoic02 Idoc in PI. Idoc to file translation creates comma separated file with .csv extn
    The logic was kept in such a way that how many E1EDP01 (items) are available in IDoc that many no of records will be created in csv file.
    The file logic for some the fields is as below:
    No of records
    InvNumber
    InvDate
    CusNumber
    LineitemDesc
    Tax1Type
    Tax1%
    for 1st E1EDP01
    E1EDK01-BELNR
    E1EDK03-DATUM
    E1EDK01-PARTN
    Populate when E1EDP04/MSKWZ=O2 or O4 with E1EDP19/KTEXT
    Hardcode when E1EDP04/MSKWZ=O2 or O4
    Sum all E1EDP04 /MSATZ when E1EDP04/MSKWZ=O2 or O4
    for 2nd E1EDP01
    E1EDK01-BELNR
    E1EDK01-DATUM
    E1EDK01-PARTN
    same as above
    same as above
    same as above
    for 3rd E1EDP01
    E1EDK01-BELNR
    E1EDK03-DATUM
    E1EDK01-PARTN
    same as above
    same as above
    same as above
    Additional Line to be created when one or more of E1EDP01 is having E1EDP04/MSKWZ = O3
    same as above
    same as above
    same as above
    Hardcode "REIM for USE TAX"
    Hardcode ""
    Hardcode ""
    Now we have got addition requirement to add a new lineitem when tax code is equal to O3 for any of the E1EDP01.
    Is it possible to create additional lineitem based on condition. If yes, please share what should be the approach.
    How we can create the additional lineitem?
    Currently we are using E1EDP01 to do context handling.
    The target structure is :
    MT_FILE
         INVOICE     0..unbounded
              InvNumber     0..1
              InvDate          0..1
              CusNumber     0..1
              LineitemDesc     0..1
              Tax1Type          0..1
              Tax1%               0..1

    Hello,
    Please add one extra field in the data structure of the target mapping and let its occurrence be 0..unbounded under the root node 'MT_ADP_Invoice'.
    Apply the condition, if tax code MSKWZ (with its context changed to E1EDP01) equalsS to '03', then map it to the newly created target field whose occurrence is 0..unbounded.
    This will then create an additional field which is your requirement.
    The above is one way.
    But if you want to have the same target field name as ADP_File appended for tax field being '03'.
    Then in that case you can you two message mapping for one common operational mapping / interface.
    In the first message mapping you need to have one target data structure created with the source data structure remaining the same as the one shown by you in scrn shot. Now this target data structure will be similar to the source, except that you need to add one more field at the end(name different from other fields) in target (whose occurrence should be 0..unbounded), and it needs to be mapped to E1EDP01 provided the tax code field MSKWZ(its context changed to E1EDP01) equalsS to constant '03'.
    In the second message mapping you need to map the target structure of previous message mapping to the actual required structure. The newly added field should be mapped to ADP_File of your final target structure.
    This will then create the same structure as required.
    Note : Please change the occurence of ADP_File to 0..unbounded.
    Regards,
    Souvik

Maybe you are looking for