diff --git a/docs/assets/css/index.css b/docs/assets/css/index.css index cde25df..5e27e1a 100755 --- a/docs/assets/css/index.css +++ b/docs/assets/css/index.css @@ -1,4 +1,8 @@ body { + /* container styles */ + max-width: 720px; + margin: auto; + font-family: "proxima-nova", sans-serif; font-size: 15px; color: #6c7680; @@ -25,11 +29,32 @@ blockquote { color: #36414C; } +header { + margin: 4rem 0; /* SAME 1 */ + font-size: 1.6em; + font-weight: 300; + text-align: center; +} +header .lead-text { + line-height: 3rem; + margin: 2rem 0; +} +.demo-tip { + margin-top: 1rem; /* SAME 2 */ + font-size: 1rem; +} +section { + margin: 4em 0; /* SAME 1 */ +} +h1 { + font-size: 3.5rem; + margin-bottom: 1.5rem; +} h1, h6 { font-weight: 700; } -h1 { - font-size: 2.13em; +.btn { + outline: none !important; } .blue.button { color: #fff; @@ -45,127 +70,28 @@ h1 { padding: 12px 24px 10px; border-bottom: 3px solid rgba(0, 0, 0, 0.2); } -.row.section, -section { - padding: 70px 0 70px; -} -.row.section p, -section p { - color: #6c7680; -} -.hero { - padding: 70px 0; - font-size: 1.6em; - font-weight: 300; - text-align: center; -} - a { color: #5E64FF; - } - a, - a:focus, - a:hover { - transition: color 0.3s, border 0.3s, background-color 0.3s; } -.group, .border-bottom { - border-bottom: 1px solid #d1d8dd; -} -.container, .navbar, footer { - max-width: 900px; - margin: auto; +a, a:focus, a:hover { + transition: color 0.3s, border 0.3s, background-color 0.3s; } -/* frappe-theme end */ - -/*buttons*/ -/* -.active { - background-color: #fff; - color: #000; - } - -.btn { - padding: .5em 1.25em; - border-radius:.25em; - cursor: pointer; - transition: all 0.3s ease 0s; - border-bottom: 3px solid #00000030; -} -.btn-secondary { - padding: 0.5em 1.25em; - border-right: 1px solid #e2e2ec; - border-left: 1px solid #e2e2ec; - border-top: 1px solid #e2e2ec; - background-color: #fafafe; +/* BaseCSS */ +.margin-top { + margin-top: 1rem; /* SAME 2 */ } - -.btn-secondary:hover{ - background: rgb(255, 255, 255); - color: #36414c; -} */ - -/* custom */ -.page-header { - width: 100%; - text-align: center; - color: #fff; - padding: 2em 0; -} -.jumbotron { - padding: 2rem 2rem; -} -.project-name { - padding-top: 1.8em; - font-size: 2.5em; -} -.project-tagline { - font-size: 1em; - opacity: 0.7; - padding: 2em; -} -.btn-transparent { - margin: 0 0.5em; - color: #fff; - background: rgba(255, 255, 255, 0.1); - border: 1px solid rgba(255, 255, 255, 0.4); -} -.btn-transparent:hover { - color: #fff; - background: rgba(255, 255, 255, 0.3); -} - -.main-content { - padding: 2em; +.mv1 { + margin: 2em 0 1em 0; } - -.main-content .row { - margin-bottom: 20px; +.border { + border: 1px solid #ddd; + border-radius: 3px; } -hr { - margin-bottom: 2rem; -} -.step-explain { - margin-top: 30px; -} - -pre.highlight { - background: #f7f7f7; - border-radius: 3px; -} -.btn { - outline: none !important; -} -.dashboard-section h1 { - margin-left: -2px; -} -.data-container { - padding: 20px; - padding-bottom: 0px; -} +/* Moon images */ .image-container { padding: 3px; } @@ -173,22 +99,11 @@ pre.highlight { display: block; width: 100%; } -.data p { +.content-data p { margin-bottom: 5px; font-size: 12px; } -.margin-vertical-px { - margin: 15px 0px; -} - -.margin-vertical-rem { - margin: 2em 0 1em 0; -} -.border { - border: 1px solid #ddd; - border-radius: 3px; -} .text-center { text-align: center; diff --git a/docs/assets/js/data.js b/docs/assets/js/data.js index 43580d0..f679316 100644 --- a/docs/assets/js/data.js +++ b/docs/assets/js/data.js @@ -1,5 +1,4 @@ -import { SEC_IN_DAY, MONTH_NAMES_SHORT, clone, timestampToMidnight, timestampSec, addDays } from '../../../src/js/utils/date-utils'; -import { getRandomBias } from '../../../src/js/utils/helpers'; +import { MONTH_NAMES_SHORT } from '../../../src/js/utils/date-utils'; // Composite Chart // ================================================================================ @@ -178,28 +177,3 @@ export const moonData = { // ================================================================================ -let today = new Date(); -let start = clone(today); -addDays(start, 4); -let end = clone(start); -start.setFullYear( start.getFullYear() - 2 ); -end.setFullYear( end.getFullYear() - 1 ); - -export let dataPoints = {}; - -let startTs = timestampSec(start); -let endTs = timestampSec(end); - -startTs = timestampToMidnight(startTs); -endTs = timestampToMidnight(endTs, true); - -while (startTs < endTs) { - dataPoints[parseInt(startTs)] = Math.floor(getRandomBias(0, 5, 0.2, 1)); - startTs += SEC_IN_DAY; -} - -export const heatmapData = { - dataPoints: dataPoints, - start: start, - end: end -}; diff --git a/docs/assets/js/demoConfig.js b/docs/assets/js/demoConfig.js new file mode 100644 index 0000000..f696dc6 --- /dev/null +++ b/docs/assets/js/demoConfig.js @@ -0,0 +1,54 @@ +import { lineCompositeData, barCompositeData } from './data'; + +export default { + lineComposite: { + elementID: "#chart-composite-1", + options: { + title: "Fireball/Bolide Events - Yearly (reported)", + data: lineCompositeData, + type: "line", + height: 190, + colors: ["green"], + isNavigable: 1, + valuesOverPoints: 1, + + lineOptions: { + dotSize: 8 + } + } + }, + + barComposite: { + elementID: "#chart-composite-2", + options: { + data: barCompositeData, + type: "bar", + height: 210, + colors: ["violet", "light-blue", "#46a9f9"], + valuesOverPoints: 1, + axisOptions: { + xAxisMode: "tick" + }, + barOptions: { + stacked: 1 + } + } + }, + + demoMain: { + elementID: "", + options: { + title: "My Awesome Chart", + data: "typeData", + type: "axis-mixed", + height: 300, + colors: ["purple", "magenta", "light-blue"], + maxSlices: 10, + + tooltipOptions: { + formatTooltipX: d => (d + '').toUpperCase(), + formatTooltipY: d => d + ' pts', + } + } + } +} \ No newline at end of file diff --git a/docs/assets/js/index.js b/docs/assets/js/index.js index 502e709..c1ac20e 100755 --- a/docs/assets/js/index.js +++ b/docs/assets/js/index.js @@ -1,45 +1,19 @@ import { shuffle, getRandomBias } from '../../../src/js/utils/helpers'; import { HEATMAP_COLORS_YELLOW, HEATMAP_COLORS_BLUE } from '../../../src/js/utils/constants'; +import { SEC_IN_DAY, clone, timestampToMidnight, timestampSec, addDays } from '../../../src/js/utils/date-utils'; import { fireballOver25, fireball_2_5, fireball_5_25, lineCompositeData, - barCompositeData, typeData, trendsData, moonData, heatmapData } from './data'; - + barCompositeData, typeData, trendsData, moonData } from './data'; +import demoConfig from './demoConfig'; +// import { lineComposite, barComposite } from './demoConfig'; // ================================================================================ -let c1 = document.querySelector("#chart-composite-1"); -let c2 = document.querySelector("#chart-composite-2"); - let Chart = frappe.Chart; // eslint-disable-line no-undef -let lineCompositeChart = new Chart (c1, { - title: "Fireball/Bolide Events - Yearly (reported)", - data: lineCompositeData, - type: 'line', - height: 190, - colors: ['green'], - isNavigable: 1, - valuesOverPoints: 1, +let lc = demoConfig.lineComposite; +let lineCompositeChart = new Chart (lc.elementID, lc.options); - lineOptions: { - dotSize: 8 - }, - // yAxisMode: 'tick' - // regionFill: 1 -}); - -let barCompositeChart = new Chart (c2, { - data: barCompositeData, - type: 'bar', - height: 210, - colors: ['violet', 'light-blue', '#46a9f9'], - valuesOverPoints: 1, - axisOptions: { - xAxisMode: 'tick' - }, - barOptions: { - stacked: 1 - }, - -}); +let bc = demoConfig.barComposite; +let barCompositeChart = new Chart (bc.elementID, bc.options); lineCompositeChart.parent.addEventListener('data-select', (e) => { let i = e.index; @@ -288,6 +262,32 @@ eventsChart.parent.addEventListener('data-select', (e) => { // Heatmap // ================================================================================ +let today = new Date(); +let start = clone(today); +addDays(start, 4); +let end = clone(start); +start.setFullYear( start.getFullYear() - 2 ); +end.setFullYear( end.getFullYear() - 1 ); + +let dataPoints = {}; + +let startTs = timestampSec(start); +let endTs = timestampSec(end); + +startTs = timestampToMidnight(startTs); +endTs = timestampToMidnight(endTs, true); + +while (startTs < endTs) { + dataPoints[parseInt(startTs)] = Math.floor(getRandomBias(0, 5, 0.2, 1)); + startTs += SEC_IN_DAY; +} + +const heatmapData = { + dataPoints: dataPoints, + start: start, + end: end +}; + let heatmapArgs = { title: "Monthly Distribution", data: heatmapData, diff --git a/docs/assets/js/index.min.js b/docs/assets/js/index.min.js index 6973d37..aaeac4a 100644 --- a/docs/assets/js/index.min.js +++ b/docs/assets/js/index.min.js @@ -46,12 +46,6 @@ var HEATMAP_COLORS_YELLOW = ['#ebedf0', '#fdf436', '#ffc700', '#ff9100', '#06001 // Universal constants -/** - * Returns the value of a number upto 2 decimal places. - * @param {Number} d Any number - */ - - /** * Returns whether or not two given arrays are equal. * @param {Array} arr1 First array @@ -120,6 +114,7 @@ var MONTH_NAMES_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", +// https://stackoverflow.com/a/11252167/6495043 function clone(date) { @@ -160,8 +155,6 @@ function addDays(date, numberOfDays) { date.setDate(date.getDate() + numberOfDays); } -// Composite Chart -// ================================================================================ var reportCountList = [152, 222, 199, 287, 534, 709, 1179, 1256, 1632, 1856, 1850]; var lineCompositeData = { @@ -274,69 +267,70 @@ var moonData = { // ================================================================================ -var today = new Date(); -var start = clone(today); -addDays(start, 4); -var end = clone(start); -start.setFullYear(start.getFullYear() - 2); -end.setFullYear(end.getFullYear() - 1); - -var dataPoints = {}; - -var startTs = timestampSec(start); -var endTs = timestampSec(end); - -startTs = timestampToMidnight(startTs); -endTs = timestampToMidnight(endTs, true); +var demoConfig = { + lineComposite: { + elementID: "#chart-composite-1", + options: { + title: "Fireball/Bolide Events - Yearly (reported)", + data: lineCompositeData, + type: "line", + height: 190, + colors: ["green"], + isNavigable: 1, + valuesOverPoints: 1, + + lineOptions: { + dotSize: 8 + } + } + }, -while (startTs < endTs) { - dataPoints[parseInt(startTs)] = Math.floor(getRandomBias(0, 5, 0.2, 1)); - startTs += SEC_IN_DAY; -} + barComposite: { + elementID: "#chart-composite-2", + options: { + data: barCompositeData, + type: "bar", + height: 210, + colors: ["violet", "light-blue", "#46a9f9"], + valuesOverPoints: 1, + axisOptions: { + xAxisMode: "tick" + }, + barOptions: { + stacked: 1 + } + } + }, -var heatmapData = { - dataPoints: dataPoints, - start: start, - end: end + demoMain: { + elementID: "", + options: { + title: "My Awesome Chart", + data: "typeData", + type: "axis-mixed", + height: 300, + colors: ["purple", "magenta", "light-blue"], + maxSlices: 10, + + tooltipOptions: { + formatTooltipX: function formatTooltipX(d) { + return (d + '').toUpperCase(); + }, + formatTooltipY: function formatTooltipY(d) { + return d + ' pts'; + } + } + } + } }; -// ================================================================================ - -var c1 = document.querySelector("#chart-composite-1"); -var c2 = document.querySelector("#chart-composite-2"); - var Chart = frappe.Chart; // eslint-disable-line no-undef -var lineCompositeChart = new Chart(c1, { - title: "Fireball/Bolide Events - Yearly (reported)", - data: lineCompositeData, - type: 'line', - height: 190, - colors: ['green'], - isNavigable: 1, - valuesOverPoints: 1, +var lc = demoConfig.lineComposite; +var lineCompositeChart = new Chart(lc.elementID, lc.options); - lineOptions: { - dotSize: 8 - } - // yAxisMode: 'tick' - // regionFill: 1 -}); - -var barCompositeChart = new Chart(c2, { - data: barCompositeData, - type: 'bar', - height: 210, - colors: ['violet', 'light-blue', '#46a9f9'], - valuesOverPoints: 1, - axisOptions: { - xAxisMode: 'tick' - }, - barOptions: { - stacked: 1 - } - -}); +var bc = demoConfig.barComposite; +var barCompositeChart = new Chart(bc.elementID, bc.options); lineCompositeChart.parent.addEventListener('data-select', function (e) { var i = e.index; @@ -575,6 +569,32 @@ eventsChart.parent.addEventListener('data-select', function (e) { // Heatmap // ================================================================================ +var today = new Date(); +var start = clone(today); +addDays(start, 4); +var end = clone(start); +start.setFullYear(start.getFullYear() - 2); +end.setFullYear(end.getFullYear() - 1); + +var dataPoints = {}; + +var startTs = timestampSec(start); +var endTs = timestampSec(end); + +startTs = timestampToMidnight(startTs); +endTs = timestampToMidnight(endTs, true); + +while (startTs < endTs) { + dataPoints[parseInt(startTs)] = Math.floor(getRandomBias(0, 5, 0.2, 1)); + startTs += SEC_IN_DAY; +} + +var heatmapData = { + dataPoints: dataPoints, + start: start, + end: end +}; + var heatmapArgs = { title: "Monthly Distribution", data: heatmapData, @@ -650,4 +670,3 @@ document.querySelector('.export-heatmap').addEventListener('click', function () }); }()); -//# sourceMappingURL=index.min.js.map diff --git a/docs/docs.html b/docs/docs.html new file mode 100644 index 0000000..e69de29 diff --git a/docs/index.html b/docs/index.html index 9a1e6c0..3154ae6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,32 +22,19 @@ -
-
-
-

Frappe Charts

-

GitHub-inspired simple and modern SVG charts for the web

-

with zero dependencies.

-
- -
-
-

Click or use arrow keys to navigate data points

-
-
-
-
-
- -
-
- -
-
-
Create a chart
-
  <!--HTML-->
+    
+

Frappe Charts

+

GitHub-inspired simple and modern SVG charts for the web
with zero dependencies.

+
+

Click or use arrow keys to navigate data points

+
+
+ +
+
Create a chart
+
  <!--HTML-->
   <div id="chart"></div>
-
  // Javascript
+      
  // Javascript
   let chart = new frappe.Chart( "#chart", { // or DOM element
     data: {
       labels: ["12am-3am", "3am-6am", "6am-9am", "9am-12pm",
@@ -87,130 +74,91 @@
 
   chart.export();
 
- - - -
-
- - - -
-
- -
- -
-
-
-
-
- Update Values -
-
-
- - - - -
-
-
+
+
+ + + +
+
+ +
+ -
-
-
- Plot Trends -
- -
- - - - -
-
- -
- -
-
+
+
Update Values
+
+ +
+ + + + +
+
+ +
+
Plot Trends
+ -
-
-
- Listen to state change -
-
-
-
-
-
-
-
- -
-
-
Europa
-

Semi-major-axis: 671034 km

-

Mass: 4800000 x 10^16 kg

-

Diameter: 3121.6 km

-
-
-
-
-
  ...
-    isNavigable: 1, // Navigate across data points; default 0
+      
+ + + + +
+
+ +
+
+ +
+
Listen to state change
+
+
+
+
+
+
+ +
+
+
Europa
+

Semi-major-axis: 671034 km

+

Mass: 4800000 x 10^16 kg

+

Diameter: 3121.6 km

+
+
+
+
  ...
+  isNavigable: 1, // Navigate across data points; default 0
   ...
 
   chart.parent.addEventListener('data-select', (e) => {
     update_moon_data(e.index); // e contains index and value of current datapoint
   });
-
-
- -
-
-
- And a Month-wise Heatmap -
-
-
- - -
-
- - - -
-
- -
-
  let heatmap = new frappe.Chart("#heatmap", {
+    
+
+    
+
+ And a Month-wise Heatmap +
+
+
+ + +
+
+ + + +
+
+ +
+
  let heatmap = new frappe.Chart("#heatmap", {
     type: 'heatmap',
     title: "Monthly Distribution",
     data: {
@@ -222,141 +170,126 @@
     countLabel: 'Level',
     discreteDomains: 0  // default: 1
     colors: ['#ebedf0', '#c0ddf9', '#73b3f3', '#3886e1', '#17459e'],
-                  // Set of five incremental colors,
-                  // preferably with a low-saturation color for zero data;
-                  // def: ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127']
+                // Set of five incremental colors,
+                // preferably with a low-saturation color for zero data;
+                // def: ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127']
   });
-
-
- -
-

- See the Pen Frappe Charts Demo - by Prateeksha Singh (@pratu16x7) on - CodePen. -

- -
- -
-
-
Available options:
-

-  ...
-  {
-    data: {
-      labels: [],
-      datasets: [],
-      yRegions: [],
-      yMarkers: []
+    
+
+    
+
Demo
+

+ See the Pen Frappe Charts Demo + by Prateeksha Singh (@pratu16x7) on + CodePen. +

+ +
+ +
+
Available options
+

+    ...
+    {
+      data: {
+        labels: [],
+        datasets: [],
+        yRegions: [],
+        yMarkers: []
+      }
+      title: '',
+      colors: [],
+      height: 200,
+
+      tooltipOptions: {
+        formatTooltipX: d => (d + '').toUpperCase(),
+        formatTooltipY: d => d + ' pts',
+      }
+
+      // Axis charts
+      isNavigable: 1,        // default: 0
+      valuesOverPoints: 1,   // default: 0
+      barOptions: {
+        spaceRatio: 1        // default: 0.5
+        stacked: 1           // default: 0
+      }
+
+      lineOptions: {
+        dotSize: 6,          // default: 4
+        hideLine: 0,         // default: 0
+        hideDots: 1,         // default: 0
+        heatline: 1,         // default: 0
+        regionFill: 1        // default: 0
+      }
+
+      axisOptions: {
+        yAxisMode: 'span',   // Axis lines, default
+        xAxisMode: 'tick',   // No axis lines, only short ticks
+        xIsSeries: 1         // Allow skipping x values for space
+                              // default: 0
+      },
+
+      // Pie/Percentage charts
+      maxLegendPoints: 6,    // default: 20
+      maxSlices: 10,         // default: 20
+
+      // Percentage chart
+      barOptions: {
+        height: 15           // default: 20
+        depth: 5             // default: 2
+      }
+
+      // Heatmap
+      discreteDomains: 1,    // default: 1
     }
-    title: '',
-    colors: [],
-    height: 200,
+    ...
 
-    tooltipOptions: {
-      formatTooltipX: d => (d + '').toUpperCase(),
-      formatTooltipY: d => d + ' pts',
-    }
-
-    // Axis charts
-    isNavigable: 1,        // default: 0
-    valuesOverPoints: 1,   // default: 0
-    barOptions: {
-      spaceRatio: 1        // default: 0.5
-      stacked: 1           // default: 0
-    }
-
-    lineOptions: {
-      dotSize: 6,          // default: 4
-      hideLine: 0,         // default: 0
-      hideDots: 1,         // default: 0
-      heatline: 1,         // default: 0
-      regionFill: 1        // default: 0
-    }
-
-    axisOptions: {
-      yAxisMode: 'span',   // Axis lines, default
-      xAxisMode: 'tick',   // No axis lines, only short ticks
-      xIsSeries: 1         // Allow skipping x values for space
-                           // default: 0
-    },
+  // Updating values
+  chart.update(data);
 
-    // Pie/Percentage charts
-    maxLegendPoints: 6,    // default: 20
-    maxSlices: 10,         // default: 20
+  // Axis charts:
+  chart.addDataPoint(label, valueFromEachDataset, index)
+  chart.removeDataPoint(index)
+  chart.updateDataset(datasetValues, index)
 
-    // Percentage chart
-    barOptions: {
-      height: 15           // default: 20
-      depth: 5             // default: 2
-    }
+  // Exporting
+  chart.export();
 
-    // Heatmap
-    discreteDomains: 1,    // default: 1
-  }
-  ...
+  // Unbind window-resize events
+  chart.unbindWindowEvents();
 
-    // Updating values
-    chart.update(data);
-
-    // Axis charts:
-    chart.addDataPoint(label, valueFromEachDataset, index)
-    chart.removeDataPoint(index)
-    chart.updateDataset(datasetValues, index)
-
-    // Exporting
-    chart.export();
-
-    // Unbind window-resize events
-    chart.unbindWindowEvents();
-
-  
-
-
- -
-
-
Install
-

Install via npm

-
  npm install frappe-charts
-

And include it in your project

-
  import { Chart } from "frappe-charts"
-

... or include it directly in your HTML

-
  <script src="https://unpkg.com/frappe-charts@1.1.0"></script>
-

Use as:

-
  new Chart();          // ES6 module
+
+ + +
+
Install
+

Install via npm

+
  npm install frappe-charts
+

And include it in your project

+
  import { Chart } from "frappe-charts"
+

... or include it directly in your HTML

+
  <script src="https://unpkg.com/frappe-charts@1.1.0"></script>
+

Use as:

+
  new Chart();          // ES6 module
                         // or
   new frappe.Chart();   // Browser
- -
-
- - -
-
- -
- -

- Documentation - GitHub -

-

- Star -

-

License: MIT

-
-
-
- -
- - - - -