« Previous Next »

Thread: CHART config using .js

Last post 06-08-2005 9:54 AM by LogParser User : Gabriele Giuseppini. 16 replies.

Average Rating Rate It (5)

RSS

Page 1 of 2 (17 items) 1 2 Next >

Sort Posts:

  • 05-18-2005, 8:07 AM

    CHART config using .js

    Hi!

    I can't use -config to configure font name and size for value on chart.

    When I using script as that

    chart.ChartArea.Font.Name = "tahoma";
    chart.ChartArea.Font.Size = 6;

    with command-line like

    D:\WindowsScripts\Mark>logparser file:os-browsers-ch.sql -i:IISW3C -o:CHART -chartTypeieExploded3D -viewN -groupSize:800x600 -categoriesFF -valuesN -config:chart.js

    logparser return error
    Error executing script "D:\WindowsScripts\Mark\chart.js": Error executing
      script at line 1: 'chart.ChartArea.Font' is null or not an object

    Help about Microsoft Office Web Components ChartSpace object model is absolutly useless.

    Who can help me about real-working script or object chart model.

    Thanks...

    With best wishes, Igor.

  • 05-19-2005, 8:34 AM In reply to

    I hear you...they could have done that help a little bit better.

    I've dug another link that looks better: http://msdn.microsoft.com/library/en-us/vbagr11/html/grobjChart1_HV05207176.asp?frame=true.

    What element of the chart you want to set the Font on? Title, Axis labels, Value labels, Legend?

  • 05-19-2005, 11:52 AM In reply to

    Yes, you're right! Help is poor. Book is better. Its a good business.

    I seen that link too and following to the manual. I read the MSDN site and can change the font of Title and Legend lables, but I can't to change value and Axis labels. People, who wrote this chart object has a strange logic. I can't understand why

    chart.Legend.Font.Bold = true;
    chart.Legend.Font.Name = "tahoma";
    chart.Legend.Font.Size = 6;

    works fine and for values I can't to use code like that chart.Values.Font.Bold = true?

    And I can't to find how to create pie like in attachment. With categories outside pie space.

    Thank you for your help.

     

  • 05-20-2005, 8:42 AM In reply to

    The difference between Legend and Values is that there's a single Legend in a chart, but there can be multiple Values ('Series'). In addition, each Series can have multiple Labels ('DataLabels').

    To access the Series and Labels, use chart.SeriesCollection, as in:

    chart.SeriesCollection(0).DataLabelsCollection(0).Font.Size = 8
    More or less the same thing applies to Axis.

    As for the pie, just say "-chartTypeie"; however, you won't get the labels outside of the pie (you can get a legend, labels on the slices, or both).

    There should be a way to do that with the config.js script, but I have no clue :-) Sorry about that.

  • 05-20-2005, 1:56 PM In reply to

    Thanks for your help. All works fine.

    And one more question - what is the SeririesCollection(1).blablabla or blablabla.DataLabelsCollection(1) ? Can I create more than one charts on one image?

    Have the no way to set the position of labels does charts with categories unused because if pie have 10 categories where one's value is 91% and other 9 are 1% - this 9 categories labels cover one another.

  • 05-21-2005, 11:50 AM In reply to

    You can create multiple series per chart, e.g. charts having multiple lines (SELECT Category, Value1, Value2, Value3), that's why Series and Labels are collections.

    On a side note, the Office Web Components also allow you to create multiple charts per image, but Log Parser does not expose that functionality - yet.

    You can turn off labels by setting the values parameter to OFF. Is this what you're asking?

  • 05-23-2005, 2:44 PM In reply to

    Hi, Gabriele.

     

    I know that my English is not well. But I am improving it.

    I know that I can turn values OFF. I’d want to say that have a command line options to setting value positions are good. Or have a good help about creating a charts script for setting value positions.

     

    And more one questions about series. If I have multiple series per chart how I can turn off/on some values? For example I want turn on only maximum values per series. Or another example – I want to turn on values of some series and turn off all values of other series in one chart.

     

    And about bugs:

    If I try to create chart image in subdirectory like “select date, bandwidth into 10\bw-line.gif …” and subdirectory not exists LogParser return error:

    Unexpected internal error calling chart object method ExportPicture:

             Exception occurred.

     

  • 05-24-2005, 10:59 AM In reply to

    I see now...hey, your English is good, it's mine that sucks :-)

    Well, the CHART output format exports some basic properties only. Everything else is supposed to be taken care of by custom config scripts; it'd be too complicated to export properties for all the tiny little details that can be configured for a chart.

    This said, you're right, the Office Web Components docs suck.....we'll make an effort next time to include more samples for chart configuration scripts!

    Now, in order to turn on/off some values, you should set 'values' to ON (so that all series have value labels) and then turn off individually the values through a script. Again, you'll have to dig into the awful Office docs, sorry about that :-)

    Good catch on the silly error message, we'll get it fixed! Thanks for pointing that out!!!!!

  • 05-29-2005, 7:36 AM In reply to

    This looks like a more appropriate topic than General Discussion> config-scripts topic where I originally posted. (Thanks for the suggestion, Igor!)

    I'm trying to reduce the font size of the Title appearing above the chart which is populated with the chartTitle:'text' paramater on the command line. Below is my config.js file. The chartSpace.ChartSpaceTitle objects are referring to the caption which appears below the chart. I don't want to omit the chartTitle paramater on the command line in exchange for populating the Title.Caption text in the config file, since that would require a unique config file for each chart. Numerous attempts with various Chart and ChartSpace properties have all resulted in errors or underdesired results, including the following:

    chart.ChartTitle.Font.Size = 12;

    ChartConfig24h.js": Error executing script at line 22: 'chart.ChartTitle.Font' is  null or not an object [The cluster resource could not be found.]

    My guess is that the appropriate property cannot be exposed by the config.js file in the current version of Logparser, but I'll be delighted if proven wrong!


    config.js (Pardon my scripting - I'm mildly capable with vbscript and totally ignorant when it comes to coding jscript)

    // Build timestamp string
    var d=new Date()
    var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
    var str1=""
    str1=str1 + weekday[d.getDay()] + " "
    str1=str1 + d.getDate() + "-"
    str1=str1 + monthname[d.getMonth()] + "-"
    str1=str1 + d.getFullYear() + " "
    str1=str1 + d.getHours() + ":"
    var minutes=d.getMinutes()
    minutes=((minutes < 10) ? "0" : "") + minutes
    str1=str1 + minutes
    str1=str1 + " (24 hour refresh)"

    // Add a caption
    chartSpace.HasChartSpaceTitle = true;
    chartSpace.ChartSpaceTitle.Caption = str1;
    chartSpace.ChartSpaceTitle.Font.Size = 8;
    chartSpace.ChartSpaceTitle.Position = chartSpace.Constants.chTitlePositionBottom;

    // Change the background color
    chart.PlotArea.Interior.Color = chartSpace.Constants.chColorNone;


  • 05-29-2005, 12:42 PM In reply to

    ----- quote -----
    The chartSpace.ChartSpaceTitle objects are referring to the caption which appears below the chart.
    ----- quote -----

    There not right.

    chartSpace.ChartSpaceTitle objects are referring to the caption OF CHART.

    The position of caption SETS by chartSpace.ChartSpaceTitle.Position property.

    If you want set the chart caption ABOVE the chart, you should set another constant value

    chartSpace.ChartSpaceTitle.Position = chartSpace.Constants.chTitlePositionTop;

    and caption appears above the chart.

    As for the rest your script work fine. See in attachment - I use your script to config chart.

     

  • 05-29-2005, 2:36 PM In reply to

    I should have been more clear about the script sample. The chartSpace.ChartSpaceTitle object in my script sample refers to the caption below the chart. There is not problem tweaking that object.

    What I am looking to do is:

    1) Reduce the font.size of the title above the chart that is defined by the -chartTitle:"Some BarChart" parameter on the command line.

    AND

    2) Have a "standardized" chartTitle (caption) below the chart that is defined by the config.js script.

    I don't want to replace the [-chartTitle:"Some Bar Chart"] with the config script file because then I would need to customize the config.js for every chartTitle variation.  I have several versions of config.js depending on the interval or some other variance, but I don't want to have to create one for every chart title. My ASP scripts, sample below, deal with populating the "Top" title.

    A sample graphic is also attached.


    <%

    Dim strInputPath   : strInputPath   = "\\10.0.0.27\d$\logfiles\1\"
    Dim strOutputPath  : strOutputPath  = "c:\web_data\site1\dev\images\"

    Call ChartMonthlyHits("NonApp")

    Sub ChartMonthlyHits(strHitType)

     Dim strLP
     strLP=strLP & " SELECT TO_TIMESTAMP(STRCAT(TO_STRING(Field1, 'yyyy-MM'), '-01 00:00:00'), 'yyyy-MM-dd hh:mm:ss') AS Month,"
     strLP=strLP & " SUM(CASE QUANTIZE(Field3, 100) WHEN 200 THEN TO_INT(Field4) ELSE 0 END) AS [Good Hits],"
     strLP=strLP & " SUM(CASE Field3 WHEN 304 THEN TO_INT(Field4) ELSE 0 END) AS [Use Cache],"
     strLP=strLP & " SUB(SUM(CASE QUANTIZE(Field3, 100) WHEN 300 THEN TO_INT(Field4) ELSE 0 END),[Use Cache]) AS Redirects,"
     strLP=strLP & " SUM(CASE QUANTIZE(Field3, 100) WHEN 400 THEN TO_INT(Field4) ELSE 0 END) AS [4xx Error],"
     strLP=strLP & " SUM(CASE QUANTIZE(Field3, 100) WHEN 500 THEN TO_INT(Field4) ELSE 0 END) AS [5xx Error]"
     strLP=strLP & " INTO " &  OutputFile("Monthly" & strHitType & "Hits.gif")
     strLP=strLP & " FROM DailyHits.csv"
     Select Case strHitType
      Case "App"
       strLP=strLP & " WHERE EXTRACT_EXTENSION(Field2) IN ('aspx'; 'asp')"
      Case "NonApp"
       strLP=strLP & " WHERE EXTRACT_EXTENSION(Field2) NOT IN ('aspx'; 'asp')"
      Case Else
       Exit Sub ' should have specified one or the other on the Call statement
     End Select
     strLP=strLP & " GROUP BY MONTH"
     strLP=strLP & " ORDER BY MONTH ASC"
     
     Set objLogQuery=CreateObject("MSUtil.LogQuery")
     Set objInputFormat=CreateObject("MSUtil.LogQuery.CSVInputFormat")
     Set objOutputFormat=CreateObject("MSUtil.LogQuery.ChartOutputFormat")

     objInputFormat.headerRow = False

     objOutputFormat.chartType  = "BarStacked"
     objOutputFormat.groupSize = "1200x300"  ' Increase the 2nd dimension every months as more periods come online
     Select Case strHitType
      Case "App"
       objOutputFormat.charttitle = "Application (ASP,ASPX) Hits"
      Case "NonApp"
       objOutputFormat.charttitle = "Non-Application Hits"
      Case Else
       Exit Sub ' should have specified one or the other on the Call statement
     End Select
     objOutputFormat.otsformat = "MMM yy"
     objOutputFormat.config  = "ChartConfig24h.js"

     objLogQuery.ExecuteBatch strLP, objInputFormat, objOutputFormat
     Set objLogQuery=Nothing
     
    End Sub 'ChartMonthlyAppHits

    Function InputFile(InputFilename)
     InputFile  = "'" & strInputPath & InputFilename & "'"
    End Function

    Function OutputFile(OutputFilename)
     OutputFile =  strOutputPath & OutputFilename
    End Function
    %>

  • 05-30-2005, 1:55 AM In reply to

    Sorry about my English.

    Now I understanding what you want to do.

    Try to add this code to config.js:

    chartSpace.Charts(0).Title.Font.Size=14;

    As I understand, when we set chartSpace.СhartSpaceTitle.properties chart object creating new additional title object, different from already set Title object.

    Also (as a tricks) you can use this code

    chart.Axes(-7).HasTitle=true;
    chart.Axes(-7).Title.Caption="Caption below";

    This code add caption below category line.

    I hope, I'd could to help you by this message.

  • 05-30-2005, 1:48 PM In reply to

    Igor, no need to apologize; it was my fault for not providing an example of the code.

    Your solution worked perfectly. It never occurred to me that I needed to enumerate which ChartsSpace.Charts object I was attempting to change.

    As a programmer from the COBOL age, I dispair ever getting my arms around object-oriented programming. There is a woefull lack of documentation by example, (by no means limited to Log Parser - the LP on-line documentation is quite good overall and my copy of the Log Parser Toolkit is well broken-in despite being only a few weeks old.)

    I very much appreciate your efforts towards finding the answer to my problem!

    Regards,

    Dave

     

     

  • 05-31-2005, 5:47 AM In reply to

    Welcome, Dave

    If you have more problems/questions with logparser, chart etc I'd be glad to help you.

    Igor.

  • 06-06-2005, 5:13 PM In reply to

    Igor, it seems you've become the guru on the office chart component :-)

    What do you think about writing a doc with a few lines of config.js examples showing all the tasks that you've got so far - changing the chart's title font, colors, sizes, etc. - and then ask Mike to post your doc somewhere on the site?

Page 1 of 2 (17 items) 1 2 Next >
Microsoft Communities