Histogram Chart

Histograms can be created with the function createHistogram in addition to setting the data as tabulated frequencies.

# histogram-1


Data

The data in json format in shown below. You can edit the data and its configuration in JS Fiddle through the file menu under File → Edit in JS Fiddle. For convience you can click this .

You can also see the data and in a table format through the toolbar on the right top by clicking on the table icon or through the file menu under Explore → Table. See additional information under User Interfaces. For convience you can click this .

{
   "m" : {
      "Description" : "Patients with advanced cancers of the stomach, bronchus, colon, ovary or breast were treated with ascorbate. The purpose of the study was to determine if the survival times differ with respect to the organ affected by the cancer.",
      "Name" : "Cancer Survival",
      "Reference" : "Cameron, E. and Pauling, L. (1978) Supplemental ascorbate in the supportive treatment of cancer :  re-evaluation of prolongation of survival times in terminal human cancer. Proceedings of the National Academy of Science USA, 75. Also found in :  Manly, B.F.J. (1986) Multivariate Statistical Methods :  A Primer, New York :  Chapman & Hall, 11. Also found in :  Hand, D.J., et al. (1994) A Handbook of Small Data Sets, London :  Chapman & Hall, 255."
   },
   "x" : {
      "Description" : ["Survival time in days"]
   },
   "y" : {
      "data" : [
        [124],
        [42],
        [25],
        [45],
        [412],
        [51],
        [1112],
        [46],
        [103],
        [876],
        [146],
        [340],
        [396],
        [81],
        [461],
        [20],
        [450],
        [246],
        [166],
        [63],
        [64],
        [155],
        [859],
        [151],
        [166],
        [37],
        [223],
        [138],
        [72],
        [245],
        [248],
        [377],
        [189],
        [1843],
        [180],
        [537],
        [519],
        [455],
        [406],
        [365],
        [942],
        [776],
        [372],
        [163],
        [101],
        [20],
        [283],
        [1234],
        [89],
        [201],
        [356],
        [2970],
        [456],
        [1235],
        [24],
        [1581],
        [1166],
        [40],
        [727],
        [3808],
        [791],
        [1804],
        [3460],
        [719]
      ],
      "desc" : ["days"],
      "smps" : ["Survival"],
      "vars" : ["s1","s2","s3","s4","s5","s6","s7","s8","s9","s10","s11","s12","s13","s14","s15","s16","s17","s18","s19","s20","s21","s22","s23","s24","s25","s26","s27","s28","s29","s30","s31","s32","s33","s34","s35","s36","s37","s38","s39","s40","s41","s42","s43","s44","s45","s46","s47","s48","s49","s50","s51","s52","s53","s54","s55","s56","s57","s58","s59","s60","s61","s62","s63","s64"]
   },
   "z" : {
      "Organ" : ["Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Stomach","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Bronchus","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Colon","Ovary","Ovary","Ovary","Ovary","Ovary","Ovary","Breast","Breast","Breast","Breast","Breast","Breast","Breast","Breast","Breast","Breast","Breast"]
   }
}

Configuration

The configuration for the visualization above is shown below. You can always access the data and its configuration in any CanvasXpress visualization through the file menu under File → Reproducible Research → Show JSON code. See additional information under User Interface - Menus. For convience you can click this .

{
   "axisTitleFontStyle" : "italic",
   "citation" : "Cameron, E. and Pauling, L. (1978). Proceedings of the National Academy of Science USA, 75.",
   "graphType" : "Scatter2D",
   "histogramBins" : 50,
   "showTransition" : "false",
   "theme" : "CanvasXpress",
   "title" : "Patients with advanced cancers of the stomach,\\nbronchus, colon, ovary or breast treated with ascorbate.",
   "xAxisTitle" : "Survival (days)",
   "yAxisTitle" : "Number of Subjects"
}

Functions

In this example a function is called after the visualization is rendered to show the programatic access of a CanvasXpress object. The first line in the code below access the CanvasXpress instance by accessing it through the id of the canvas in the DOM and the next line(s) apply the corresponding functions. See additional information under Instances.

var cX = CanvasXpress.$("canvasId");
cX.createHistogram();

R Code

The R code for the visualization above is shown below. For convenience the data and the meata data in the excert is shown in a url accessible tab delimited file to facilitate readability. You can always access the full R code in any CanvasXpress visualization through the file menu under File → Reproducible Research → Show R code. See additional information under User Interface. For convience you can click this .

library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/cX-cancersurvivalt-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
x=read.table("https://www.canvasxpress.org/data/cX-cancersurvivalt-smp.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
z=read.table("https://www.canvasxpress.org/data/cX-cancersurvivalt-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  smpAnnot=x,
  varAnnot=z,
  axisTitleFontStyle="italic",
  citation="Cameron, E. and Pauling, L. (1978). Proceedings of the National Academy of Science USA, 75.",
  graphType="Scatter2D",
  histogramBins=50,
  showTransition=FALSE,
  theme="CanvasXpress",
  title="Patients with advanced cancers of the stomach,\nbronchus, colon, ovary or breast treated with ascorbate.",
  xAxisTitle="Survival (days)",
  yAxisTitle="Number of Subjects",
  afterRender=list(list("createHistogram"))
)

# Events and Functionality

Out of the box events

Events are pre-configured in all CanvasXpress visualizations. Refer to documentation to further customize events. Most visualizations have mouseover, click, dbl-click, wheel, context-menu, drag and drop. Press the 'ESC' key to reset the plot.

User Interfaces for exploring and configuring visualization

All visualization come with multiple user interfaces to allow data exploration and configuration. Dbl-click to bring configurator, context-menu to open menus, mouse-over top right to visualization to show toolbar and select either the funnel to open filters and data table or the tools to open the data explorer. See further documentation under User Interfaces.

Drag'n Drop files on the CanvasXpress Visualization

You can drag and drop any delimited text file on the visualization to create a new CanvasXpress plot. Similarly, you can drag and drop formated XML files from Wikipathways, KeGG, Metabase or GML. Furthermore, you can also drag and drop png or json files previously saved in CanvasvasXpress to re-create the visualization.