Giter Site home page Giter Site logo

better-access-charts's Introduction

Better-Access-Charts

Better charts for Access with charts.js

Why Better charts for Access?

Microsoft Access badly needs modern charts. The original charts in MS Access date from the 90s of the previous century. Microsoft has given the charts in Access a lift. They called it "Modern Charts".

There are countless JavaScript libraries on the world wide web that you can use to create cool charts. This project makes use of this. We create charts using the Chart.js library and display them in the edge browser control. The whole logic is hidden in some class modules.

Take a look at the demo and let yourself be inspired by the possibilities.

grab-landing-page

You want to give it a try?

  1. Download the latest release
  2. Unpack the files to a trusted folder
  3. Run the database
  4. Push the button: "Create Chart"

How to integrate into your own database?

1. Import of the class modules

First, all modules with the name "BAC_*" must be imported from the demo database into your Access database.

2. Insert edge browser control on form

The second step is to add an edge browser control to display the chart on a form. It is best to give the control a meaningful name. This is required later in the VBA code. I like to use the name "ctlEdgeBrowser" for this.

3. First lines of code for the basic functionality

The best thing to do is to add another button. In the click event, paste the following code:

Dim myChart As BAC_Chart  
Set myChart = BAC.Chart(Me.ctlEdgeBrowser)  
myChart.CreateChart  
  • In line 1 a variable of the type BAC_Chart is declared.
  • In line 2 a new instance of this class is created and the edge browser control is assigned to the class module.
  • The chart is created in line 3.

When you run this code, you will see a chart with some data. At the moment no data source is assigned. In such a case, Better-Access Charts simply shows a standard data source with 6 entries. This is particularly practical for our example. We have now done a quick test and fundamentally implemented the chart.

4. Add a data source and define the chart type

In order for the chart to show something, it needs a data source. You can use the DataSource.ObjectName property for this, for example. Enter the name of a table or a query that contains the data to be displayed.

You can specify one or more field names using the DataSource.DataFieldNames property. If you specify multiple field names, a data series is drawn for each field. You use the DataSource.LabelFieldName attribute to specify the field from which the names of the data points are taken.

Finally, use the ChartType property to select which of the nine possible chart types should be created.

The necessary VBA code could look like this, for example:

myChart.DataSource.ObjectName = "tbl_DemoData"
myChart.DataSource.DataFieldNames = Array("Dataset1", "Dataset2", "Dataset3")
myChart.DataSource.LabelFieldName = "DataLabel"
myChart.ChartType = chChartType.Line
  • In line 1, the table "tbl_Demo_Data" is specified as the data source.
  • Line 2 names three fields for three data series.
  • Line 3 defines the name of the label field.
  • In line 4, a line chart is selected as the chart type.

5. Set further attributes for the chart

The next step is to adapt the chart to your own needs. For example, you can define a title, label the axes or adjust the default font size.

The project currently has 21 subclasses with lots of properties. You can see all of them in the documentation on the Wiki. I have also presented the individual progress in the blog.

As you can see, there are a multitude of sources. Take a look around and make use of the options provided.

better-access-charts's People

Contributors

kdgundermann avatar naincykumariknoldus avatar sten-schmidt avatar team-moeller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

better-access-charts's Issues

add a property to specify the path to chart.js

Such a property can be handy if one uses several databases in different folders.
You will not want to copy a folder with chart.js to each folder with a database using Better Access Charts

Provide a solution for Null-values

If the data source does not contain a value in a data field, an error message appears when the HTML file is created.
A solution is needed for this.

let the axis start at zero

At the moment the axis are starting at the lowest value.
Make it possible to specify, that the axis start at zero.

add a property to bind a datasource

add a property to bind a recordset, a table or a query as datasource for the chart
one should specify the column names for the data and the lables

Improve readme

Can you please update the readme file to know what this project is about?

make data labels available

At the moment you cannot show data labels.
This should be possible.
There are plugins out there to solve this issue.

Multiple Charts on one form

First of all, amazing project and very usefull, my compliments.
Not an issue, just a extra feature. I had problems with multiple charts on one form (to create a dashboard with charts), the latest chart I created was shown in the web browser control.

I changed the private constant "HtmlFileName" to a public property. this public property must then be set with all the other parameters (uniquely from the other charts offcourse). This made it work for me, better solutions are always welcome.

Improve the color mapping

Make sure that the color mapping is per data series for line charts and per value for pie charts.

Getting this to work with Chartjs 3.4.1

Hi,

First off - great work. My journey to get better charts in Access brought me here, and I'm glad it did. Now I am just navigating through this code and I'm wondering if there are plans to update this db to use the latest Chartjs version - 3.4.1. I was using this Chartjs version in a different project where I was testing connections to SQL Server via PHP then outputting to a chart using the latest version of Chartjs. I tried simple updates to your code to change it to use the 3.4.1 version, but I was getting scripting errors.

Regardless, thanks for posting this code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.